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

# afInitCompression(3)

initialize compression for a track in an audio file setup

## NAME

afInitCompression - initialize compression for a track in an audio file setup

## SYNOPSIS

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

```
void afInitCompression(AFfilesetup setup, int track, int compression);
```

## PARAMETERS

setup is a valid file setup returned by [**afNewFileSetup**(3)](/afNewFileSetup/3.md).

track specifies a track within the audio file setup. track is always AF\_DEFAULT\_TRACK for all currently supported file formats.

compression is an identifier specifying the compression type (such as AF\_COMPRESSION\_G711\_ULAW) to be used for audio data in the track.

## DESCRIPTION

Given an AFfilesetup structure created with [**afNewFileSetup**(3)](/afNewFileSetup/3.md) and a track identified by track (AF\_DEFAULT\_TRACK for all currently supported file formats), afInitCompression initializes the track to the specified compression.

The following compression types are currently supported:

AF\_COMPRESSION\_NONE

no compression

AF\_COMPRESSION\_G711\_ULAW

CCITT G.711 mu-law encoding

AF\_COMPRESSION\_G711\_ALAW

CCITT G.711 A-law encoding

AF\_COMPRESSION\_IMA

IMA ADPCM encoding

AF\_COMPRESSION\_MS\_ADPCM

MS ADPCM encoding

AF\_COMPRESSION\_FLAC

FLAC

AF\_COMPRESSION\_ALAC

Apple Lossless Audio Codec

## ERRORS

afInitCompression can produce the following errors:

AF\_BAD\_FILESETUP

setup represents an invalid file setup.

AF\_BAD\_TRACKID

track represents an invalid track identifier.

AF\_BAD\_COMPTYPE

compression represents an invalid compression type.

## SEE ALSO

[**afNewFileSetup**(3)](/afNewFileSetup/3.md), [**afInitSampleFormat**(3)](/afInitSampleFormat/3.md)

## AUTHOR

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