iphoneavaudiorecorderdecibelmeter

Confusion with meters in AVAudioRecorder


Simply put, I'm trying to lip-sync something based on the decibel reading from the mic input stream of an iPhone, and the values I'm getting aren't quite what I'm after. I'm using AVAudioRecorder's peakPowerForChannel and averagePowerForChannel. (I'm aware that this is a rather simplistic lip-sync technique, but quality isn't a major concern).

When the number of decibels increases, the meters react as I'd like them to (higher value when louder, so I can map this to the open-ness of the mouth) but when the sound stops quickly, the values decrease slowly, as though the sound was trailing off (i.e. fading to silence over a second or two) - not what I'd like.

Is there a way of configuring the AVAudioRecorder so that it doesn't have this 'fade' effect, or can I do something with the values that it gives me to get the desired output? Alternatively, is there another tool I can use?

Thanks!


Solution

  • The meter ballistics on AVAudioPlayer are what you'd expect for displaying traditional audio meters: Instantaneous for increases in amplitude, but lowpassed for decreases.

    For the Talking Carl-type thing where you animate a character based on recorded audio you'll have to get at the raw audio and tweak your own metering response as appropriate. If you're animating the character live (i.e., while the user talks in the device's microphone) you'll probably want to use AudioQueue or RemoteIO to get at the audio data. Otherwise, if you're just processing an audio file after it's been recorded, you can get the data you need using ExtAudioFile.