views:

45

answers:

1

Hi ppl,

Is there any way to let's say, user clicks a button, and then he needs to say something to the mic, but only after he finishes to talk to the mic, the app will wait 5 seconds, and then the app will do something. is there any code or example for this? to check if there is an input to the mic or not.

thanks in advance!

A: 

If you're recording with AVAudioRecorder, you have the ability to enable metering and get basic power metrics for your current recording. One way to determine silence for a period of time is to sample the average power and peak power over a time period of your choosing (1/2 second to a few seconds). If the ratio remains low enough during that arbitrary period, the input has been relatively quiet and you can end the recording. You can view the docs for that class here. If you're using Audio Queue Services, this may be a little more involved, but the concept is the same.

warrenm