Saturday, April 18, 2009

More about AudioUnitSetParameter

Apple release iPhone SDK based on Mac OS 10.5, and they used a lot of concept which is used in Mac OS directly in iPhone development. But to tell the truth, even the Mac development documentation is still lack of a lot of details, so Apple just leave those jungles directly to iPhone developers. Today, let talk about AudioUnit and the parameters.

AudioUnit is a good library, it provides a lot of predefined processes for us to deal with the audio data. But I have to say, Apple, you really leave a huge jungle in AudioUnit. You can almost find no useful documents for you to understand the APIs. If you want to use an AudioUnit, you do need to invoke a lot of function in a certain sequence. Otherwise, the AudioUnit will refuse to work.

After you properly set up the AudioUnits and AUGraph, you still might be confused when you want to just some properties of a AudioUnit on the fly, you will find out that you are falling into another jungle. You will hard to know which parameter to use and how to use it. Because All you can access the parameters of an AudioUnit is AudioUnitSetParameter. If you look into this API's document, you will see what the real jungle is:

AudioUnitSetParameter
Sets the value of an audio unit parameter.

OSStatus AudioUnitSetParameter (
AudioUnit inUnit,
AudioUnitParameterID inID,
AudioUnitScope inScope,
AudioUnitElement inElement,
AudioUnitParameterValue inValue,
UInt32 inBufferOffsetInFrames
);

Parameters
inUnit
The audio unit that you want to set a parameter value for.

inID
The audio unit parameter identifier.

inScope
The audio unit scope for the parameter.

inElement
The audio unit element for the parameter.

inValue
The value that you want to apply to the parameter.

inBufferOffsetInFrames
Set this to 0. To schedule the setting of a parameter value, use the AudioUnitScheduleParameters function.

Return Value
A result code.

Availability
Available in iPhone OS 2.0 and later.
See Also
AudioUnitGetParameter
AudioUnitScheduleParameters
Declared In
AUComponent.h


See, the first parameter is easy to understand, it means which AudioUnit you want to set/change a parameter with.
the second one will be a little confused, because you need to find out each AudioUnit has which kind of parameters at all. Well, to tell the truth, if you don't know a parameter name, there is no way for you to jump to the parameters defination! So, here is what might be help to you. [Click Here(Local help URL, if you don't have iPhone SDK documentations installed in your system, don't click this URL)]. And don't forget to bookmark it! ;-p

No comments:

Post a Comment