Link: http://developer.apple.com/library/ios/#samplecode/SpeakHere/Introduction/Intro.html
Just some gotcha's and points to note:
You need to call AudioQueueSetProperty to enable the level metering feature in the first place:
UInt32 enableMetering = 1; AudioQueueSetProperty(audioQueue, kAudioQueueProperty_EnableLevelMetering, &enableMetering, sizeof(UInt32)); |
The number returned by the AudioQueue will be a negative number with a maximum value of 0. To convert it to a number on a linear scale (i.e. gain level), use the following formula:
float level = pow(10., 0.05 * averagePower); |
Where averagePower is the value returned by the AudioQueue for the audio level average power.
The rest should be pretty straight-forward from studying the example.
Links and References:
- http://stackoverflow.com/questions/1149092/how-do-i-attenuate-a-wav-file-by-a-given-decibel-value
- http://stackoverflow.com/questions/1281494/how-to-obtain-accurate-decibel-leve-with-cocoa
- http://stackoverflow.com/questions/9403094/ios-audioqueue-kaudioqueueerr-invalidpropertyvalue-for-property-kaudioqueueprop
No comments:
Post a Comment