Audio File Services


This document describes Audio File Services, a C programming interface that enables you to read or write a wide variety of audio data to or from disk or a memory buffer.

With Audio File Services you can:

  • Create, initialize, open, and close audio files

  • Read and write audio files

  • Optimize audio files

  • Work with user data and global information


Getting and Setting Audio File Properties

Optimizing Audio Files

func AudioFileOptimize(AudioFileID) -> OSStatus

Consolidates audio data and performs other internal optimizations of the file structure.


Data Types

typealias AudioFileID

An opaque data type that represents an audio file object.

typealias AudioFilePropertyID

An audio file property identifier.

struct AudioFile_SMPTE_Time

A data structure for describing SMPTE (Society of Motion Picture and Television Engineers) time.

struct AudioFileMarker

Annotates a position in an audio file.

struct AudioFileMarkerList

A list of markers associated with an audio file, including their SMPTE time type, the number of markers, and the markers themselves.

struct AudioFileRegion

An audio file region specifies a segment of audio data.

struct AudioFileRegionList

A list of the audio file regions in a file.

struct AudioFilePacketTableInfo

Contains information about the number of valid frames in a file and where they begin and end.


typealias AudioFileTypeID

Operating system constants that indicate the type of file to be written or a hint about what type of file to expect from data provided.

Audio File Loop Direction Constants

The playback direction of a looped segment of an audio file.

Audio File Marker Types

A type of marker within a file used in the mType field of the AudioFileMarker structure.

struct AudioFileRegionFlags

Flags that specify a playback direction for an AudioFileRegion structure.

Audio File Packet Translation Flags

Flag used with the mFlags field of the AudioBytePacketTranslation structure.

Info String Keys

Key values of properties to get and set using Audio File Services functions and provide a common way to get the same information out of several different kinds of files.

Audio File Properties

Properties used by the functions described in getting and setting pieces of data in audio files. See Working with Global Information for details.

Audio File Global Info Properties

Access these properties using the functions described in Working with Global Information.

Result Codes

This table lists the result codes defined for Audio File Services.

var kAudioFileUnspecifiedError: OSStatus

An unspecified error has occurred.

var kAudioFileUnsupportedDataFormatError: OSStatus

The data format is not supported by this file type.

var kAudioFileBadPropertySizeError: OSStatus

The size of the property data was not correct.

var kAudioFilePermissionsError: OSStatus

The operation violated the file permissions. For example, an attempt was made to write to a file opened with the kAudioFileReadPermission constant.

var kAudioFileNotOptimizedError: OSStatus

The chunks following the audio data chunk are preventing the extension of the audio data chunk. To write more data, you must optimize the file.

var kAudioFileInvalidChunkError: OSStatus

Either the chunk does not exist in the file or it is not supported by the file.

var kAudioFileDoesNotAllow64BitDataSizeError: OSStatus

The file offset was too large for the file type. The AIFF and WAVE file format types have 32-bit file size limits.

var kAudioFileInvalidPacketOffsetError: OSStatus

A packet offset was past the end of the file, or not at the end of the file when a VBR format was written, or a corrupt packet size was read when the packet table was built.

var kAudioFileInvalidFileError: OSStatus

The file is malformed, or otherwise not a valid instance of an audio file of its type.

var kAudioFileOperationNotSupportedError: OSStatus

The operation cannot be performed. For example, setting the kAudioFilePropertyAudioDataByteCount constant to increase the size of the audio data in a file is not a supported operation. Write the data instead.