Audio File Services

Overview

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

Symbols

Getting and Setting Audio File Properties

Optimizing Audio Files

func AudioFileOptimize(AudioFileID)

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

Callbacks

AudioFile_WriteProc

A callback for writing file data when used in conjunction with the AudioFileOpenWithCallbacks(_:_:_:_:_:_:_:) or AudioFileCreateWithURL(_:_:_:_:_:) functions.

AudioFile_GetSizeProc

Gets file data size.

AudioFile_SetSizeProc

Sets file data size.

Data Types

AudioFileID

An opaque data type that represents an audio file object.

AudioFilePropertyID

An audio file property identifier.

AudioFile_SMPTE_Time

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

AudioFileMarker

Annotates a position in an audio file.

AudioFileMarkerList

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

AudioFileRegion

An audio file region specifies a segment of audio data.

AudioFileRegionList

A list of the audio file regions in a file.

AudioFilePacketTableInfo

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

Constants

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.

Audio File Region Flags

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.