---
name: "afWriteFrames"
section: "3"
platform: "linux"
package: "audiofile"
version: "0.3.6-12"
release: "Arch Linux 2026-11-01"
platforms: ["linux"]
url: "https://new.carta.tech/afWriteFrames"
---

# afWriteFrames(3)

write sample frames to a track in an audio file

## NAME

afWriteFrames - write sample frames to a track in an audio file

## SYNOPSIS

```
#include <audiofile.h>
```

```
AFframecount afWriteFrames(AFfilehandle file, int track, const void *data,
    AFframecount count);
```

## DESCRIPTION

afWriteFrames attempts to write up to *count* frames of audio data from the buffer *data* to the audio file handle *file*.

## PARAMETERS

*file* is a valid file handle returned by [**afOpenFile**(3)](/afOpenFile/3.md).

*track* is always AF\_DEFAULT\_TRACK for all currently supported file formats.

*data* is a buffer of sample frames to be written to the file.

*count* is the number of sample frames to be written.

## RETURN VALUE

afWriteFrames returns the number of sample frames successfully written to *file*.

## ERRORS

afWriteFrames can produce these errors:

AF\_BAD\_FILEHANDLE

the file handle was invalid

AF\_BAD\_TRACKID

the track is not AF\_DEFAULT\_TRACK

AF\_BAD\_WRITE

writing audio data to the file failed

AF\_BAD\_LSEEK

seeking within the file failed

## SEE ALSO

[**afReadFrames**(3)](/afReadFrames/3.md)

## AUTHOR

Michael Pruett \<michael@68k.org\>
