Functions


AudioConverterNew
Create a new AudioConverter.
AudioConverterNewSpecific
Create a new AudioConverter using specific codecs.
AudioConverterDispose
Destroy an AudioConverter.
AudioConverterReset
Reset an AudioConverter
AudioConverterGetPropertyInfo
Returns information about an AudioConverter property.
AudioConverterGetProperty
Returns an AudioConverter property value.
AudioConverterSetProperty
Sets an AudioConverter property value.
AudioConverterFillBuffer
Converts data supplied by an input callback function.
AudioConverterConvertBuffer
Converts data from an input buffer to an output buffer.
AudioConverterFillComplexBuffer
Converts data supplied by an input callback function, supporting non-interleaved and packetized formats.

AudioConverterNew


Create a new AudioConverter.

extern OSStatus AudioConverterNew(
    const AudioStreamBasicDescription*inSourceFormat, 
    const AudioStreamBasicDescription*inDestinationFormat, 
    AudioConverterRef*outAudioConverter); 
Parameter Descriptions
inSourceFormat
The format of the source audio to be converted.
inDestinationFormat
The destination format to which the audio is to be converter.
outAudioConverter
On successful return, points to a new AudioConverter instance.
function result
An OSStatus result code.

Discussion

For a pair of linear PCM formats, the following conversions are supported:



Also, encoding and decoding between linear PCM and compressed formats is supported. Functions in AudioToolbox/AudioFormat.h return information about the supported formats. When using a codec, you can use any supported PCM format (as above); the converter will perform any necessary additional conversion between your PCM format and the one created or consumed by the codec.
Availability
Introduced in Mac OS X 10.1.

AudioConverterNewSpecific


Create a new AudioConverter using specific codecs.

extern OSStatus AudioConverterNewSpecific(
    const AudioStreamBasicDescription*inSourceFormat, 
    const AudioStreamBasicDescription*inDestinationFormat, 
    UInt32 inNumberClassDescriptions, 
    AudioClassDescription*inClassDescriptions, 
    AudioConverterRef*outAudioConverter) ; 
Parameter Descriptions
inSourceFormat
The format of the source audio to be converted.
inDestinationFormat
The destination format to which the audio is to be converter.
inNumberClassDescriptions
The number of class descriptions.
inClassDescriptions
AudioClassDescriptions specifiying the codec to instantiate.
outAudioConverter
On successful return, points to a new AudioConverter instance.
function result
An OSStatus result code.

Discussion

This function is identical to AudioConverterNew(), except that the client may explicitly choose which codec to instantiate if there is more than one choice.

Availability
Introduced in Mac OS X 10.4.

AudioConverterDispose


Destroy an AudioConverter.

extern OSStatus AudioConverterDispose(
    AudioConverterRef inAudioConverter); 
Parameter Descriptions
inAudioConverter
The AudioConverter to dispose.
function result
An OSStatus result code.
Availability
Introduced in Mac OS X 10.1.

AudioConverterReset


Reset an AudioConverter

extern OSStatus AudioConverterReset(
    AudioConverterRef inAudioConverter); 
Parameter Descriptions
inAudioConverter
The AudioConverter to reset.
function result
An OSStatus result code.

Discussion

Should be called whenever there is a discontinuity in the source audio stream being provided to the converter. This will flush any internal buffers in the converter.

Availability
Introduced in Mac OS X 10.1.

AudioConverterGetPropertyInfo


Returns information about an AudioConverter property.

extern OSStatus AudioConverterGetPropertyInfo(
    AudioConverterRef inAudioConverter, 
    AudioConverterPropertyID inPropertyID, 
    UInt32*outSize, 
    Boolean*outWritable); 
Parameter Descriptions
inAudioConverter
The AudioConverter to query.
inPropertyID
The property to query.
outSize
If non-null, on exit, the size of the property value in bytes.
outWritable
If non-null, on exit, indicates whether the property value is writable.
function result
An OSStatus result code.
Availability
Introduced in Mac OS X 10.1.

AudioConverterGetProperty


Returns an AudioConverter property value.

extern OSStatus AudioConverterGetProperty(
    AudioConverterRef inAudioConverter, 
    AudioConverterPropertyID inPropertyID, 
    UInt32*ioPropertyDataSize, 
    void*outPropertyData); 
Parameter Descriptions
inAudioConverter
The AudioConverter to query.
inPropertyID
The property to fetch.
ioPropertyDataSize
On entry, the size of the memory pointed to by outPropertyData. On successful exit, the size of the property value.
outPropertyData
On exit, the property value.
function result
An OSStatus result code.
Availability
Introduced in Mac OS X 10.1.

AudioConverterSetProperty


Sets an AudioConverter property value.

extern OSStatus AudioConverterSetProperty(
    AudioConverterRef inAudioConverter, 
    AudioConverterPropertyID inPropertyID, 
    UInt32 inPropertyDataSize, 
    const void*inPropertyData); 
Parameter Descriptions
inAudioConverter
The AudioConverter to modify.
inPropertyID
The property to set.
inPropertyDataSize
The size in bytes of the property value.
inPropertyData
Points to the new property value.
function result
An OSStatus result code.
Availability
Introduced in Mac OS X 10.1.

AudioConverterFillBuffer


Converts data supplied by an input callback function.

extern OSStatus AudioConverterFillBuffer(
    AudioConverterRef inAudioConverter, 
    AudioConverterInputDataProc inInputDataProc, 
    void*inInputDataProcUserData, 
    UInt32*ioOutputDataSize, 
    void*outOutputData); 
Parameter Descriptions
inAudioConverter
The AudioConverter to use.
inInputDataProc
A callback function which supplies the input data.
inInputDataProcUserData
A value for the use of the callback function.
ioOutputDataSize
On entry, the size of the buffer pointed to by outOutputData. On exit, the number of bytes written to outOutputData
outOutputData
The buffer into which the converted data is written.
function result
An OSStatus result code.

Discussion

Produces a buffer of output data from an AudioConverter. The supplied input callback function is called whenever necessary.

NOTE: AudioConverterFillBuffer is limited to simpler conversions that do not involve multiple deinterleaved buffers or packetized formats. Use AudioConverterFillComplexBuffer for those cases.

Availability
Introduced in Mac OS X 10.1.

AudioConverterConvertBuffer


Converts data from an input buffer to an output buffer.

extern OSStatus AudioConverterConvertBuffer(
    AudioConverterRef inAudioConverter, 
    UInt32 inInputDataSize, 
    const void*inInputData, 
    UInt32*ioOutputDataSize, 
    void*outOutputData); 
Parameter Descriptions
inAudioConverter
The AudioConverter to use.
inInputDataSize
The size of the buffer inInputData.
inInputData
The input audio data buffer.
ioOutputDataSize
On entry, the size of the buffer outOutputData. On exit, the number of bytes written to outOutputData.
outOutputData
The output data buffer.
function result
Produces a buffer of output data from an AudioConverter, using the supplied input buffer.

WARNING: this function will fail for any conversion where there is a variable relationship between the input and output data buffer sizes. This includes sample rate conversions and most compressed formats. In these cases, use AudioConverterFillBuffer. Generally this function is only appropriate for PCM-to-PCM conversions where there is no sample rate conversion.
Availability
Introduced in Mac OS X 10.1.

AudioConverterFillComplexBuffer


Converts data supplied by an input callback function, supporting non-interleaved and packetized formats.

extern OSStatus AudioConverterFillComplexBuffer(
    AudioConverterRef inAudioConverter, 
    AudioConverterComplexInputDataProc inInputDataProc, 
    void*inInputDataProcUserData, 
    UInt32*ioOutputDataPacketSize, 
    AudioBufferList*outOutputData, 
    AudioStreamPacketDescription*outPacketDescription) ; 
Parameter Descriptions
inAudioConverter
The AudioConverter to use.
inInputDataProc
A callback function which supplies the input data.
inInputDataProcUserData
A value for the use of the callback function.
ioOutputDataPacketSize
On entry, the capacity of outOutputData expressed in packets in the converter's output format. On exit, the number of packets of converted data that were written to outOutputData.
outOutputData
The converted output data is written to this buffer.
outPacketDescription
If non-null, and the converter's output uses packet descriptions, then packet descriptions are written to this array. It must point to a memory block capable of holding *ioOutputDataPacketSize packet descriptions. (See AudioFormat.h for ways to determine whether an audio format uses packet descriptions).
function result
An OSStatus result code.

Discussion

Produces a buffer list of output data from an AudioConverter. The supplied input callback function is called whenever necessary.

Availability
Introduced in Mac OS X 10.2

(Last Updated July 18, 2005)