---
title: "AudioFileWriteBytes(_:_:_:_:_:)"
framework: audiotoolbox
role: symbol
role_heading: Function
path: "audiotoolbox/audiofilewritebytes(_:_:_:_:_:)"
---

# AudioFileWriteBytes(_:_:_:_:_:)

Writes bytes of audio data to an audio file.

## Declaration

```swift
func AudioFileWriteBytes(_ inAudioFile: AudioFileID, _ inUseCache: Bool, _ inStartingByte: Int64, _ ioNumBytes: UnsafeMutablePointer<UInt32>, _ inBuffer: UnsafeRawPointer) -> OSStatus
```

## Parameters

- `inAudioFile`: The audio file to which you want to write bytes of data.
- `inUseCache`: Set to true if you want to cache the data. Otherwise, set to false.
- `inStartingByte`: The byte offset where the audio data should be written.
- `ioNumBytes`: On input, a pointer the number of bytes to write. On output, a pointer to the number of bytes actually written.
- `inBuffer`: A pointer to a buffer containing the bytes to be written.

## Return Value

Return Value A result code. See Result Codes.

## Discussion

Discussion In most cases, you should use AudioFileWritePackets(_:_:_:_:_:_:_:) instead of this function.

## See Also

### Reading and Writing Audio Files

- [AudioFileReadBytes(_:_:_:_:_:)](audiotoolbox/audiofilereadbytes(_:_:_:_:_:).md)
- [AudioFileReadPacketData(_:_:_:_:_:_:_:)](audiotoolbox/audiofilereadpacketdata(_:_:_:_:_:_:_:).md)
- [AudioFileWritePackets(_:_:_:_:_:_:_:)](audiotoolbox/audiofilewritepackets(_:_:_:_:_:_:_:).md)
