<!--
{
  "availability" : [
    "iOS: 2.0.0 -",
    "iPadOS: 2.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.2.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "AudioToolbox",
  "identifier" : "/documentation/AudioToolbox/AudioFileReadBytes(_:_:_:_:_:)",
  "metadataVersion" : "0.1.0",
  "role" : "Function",
  "symbol" : {
    "kind" : "Function",
    "modules" : [
      "Audio Toolbox"
    ],
    "preciseIdentifier" : "c:@F@AudioFileReadBytes"
  },
  "title" : "AudioFileReadBytes(_:_:_:_:_:)"
}
-->

# AudioFileReadBytes(_:_:_:_:_:)

Reads bytes of audio data from an audio file.

```
func AudioFileReadBytes(_ inAudioFile: AudioFileID, _ inUseCache: Bool, _ inStartingByte: Int64, _ ioNumBytes: UnsafeMutablePointer<UInt32>, _ outBuffer: UnsafeMutableRawPointer) -> OSStatus
```

## Parameters

`inAudioFile`

The audio file whose bytes of audio data you want to read.

`inUseCache`

Set to `true` if you want to cache the data. You should cache reads and writes if you read or write the same portion of a file multiple times. To request that the data not be cached, if possible, set to `false`. You should not cache reads and writes if you read or write data from a file only once.

`inStartingByte`

The byte offset of the audio data you want to be returned.

`ioNumBytes`

On input, a pointer to the number of bytes to read. On output, a pointer to the number of bytes actually read.

`outBuffer`

A pointer to user-allocated memory large enough for the requested bytes.

## Return Value

A result code. See Result Codes.

## Discussion

In most cases, you should use [`AudioFileReadPackets(_:_:_:_:_:_:_:)`](/documentation/AudioToolbox/AudioFileReadPackets(_:_:_:_:_:_:_:)) instead of this function.

This function returns `eofErr` when the read operation encounters the end of the file.  Note that Audio File Services only reads one 32-bit chunk of a file at a time.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)