---
title: "AudioFileReadBytes(_:_:_:_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/audiofilereadbytes(_:_:_:_:_:)"
---

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

Reads bytes of audio data from an audio file.

## Declaration

```swift
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

Return Value A result code. See Result Codes.

## Discussion

Discussion In most cases, you should use 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.

## See Also

### Reading and Writing Audio Files

- [AudioFileWriteBytes(_:_:_:_:_:)](audiotoolbox/audiofilewritebytes(_:_:_:_:_:).md)
- [AudioFileReadPacketData(_:_:_:_:_:_:_:)](audiotoolbox/audiofilereadpacketdata(_:_:_:_:_:_:_:).md)
- [AudioFileWritePackets(_:_:_:_:_:_:_:)](audiotoolbox/audiofilewritepackets(_:_:_:_:_:_:_:).md)
