Hello, I'm using AVAudioRecorder to record audio from the iphone's mic but I want to discard the silence periods: start recording when detecting sound, and stop recording when next silence.
Can't figure out how to do that
Any advice?
Thanx!
Hello, I'm using AVAudioRecorder to record audio from the iphone's mic but I want to discard the silence periods: start recording when detecting sound, and stop recording when next silence.
Can't figure out how to do that
Any advice?
Thanx!
Perhaps you could use the AVAudioRecorder's support for audio level metering to keep track of the audio levels and enable recording when the levels are above a given threshold. You'd need to enable metering with:
[anAVAudioRecorder setMeteringEnabled:YES];
and then you could periodically call:
[anAVAudioRecorder updateMeters];
power = [anAVAudioRecorder averagePowerForChannel:0];
if (power > threshold && anAVAudioRecorder.recording==NO) {
[anAVAudioRecorder record];
} else if (power < threshold && anAVAudioRecorder.recording==YES) {
[anAVAudioRecorder stop];
}
Or something like that.
I've found the way based on Audio Queue Services. It is alot more complicated but alot more fun too as you define your queue buffers for the incoming audio packets.
You need to define the callback when the buffer if full, so you have the buffer full of packets that you can process as you wish, in my case to detect silence and a few more things.
Later having more time ill post the solution. If anyone urged that just cant wait drop me an email and ill be glad to help.
Check speakhere example here: http://developer.apple.com/library/ios/#samplecode/SpeakHere/Introduction/Intro.html
Hi Martha,
I am also working on a app where i need to record audio and to stop when there is silence. I have been look all over but still could not find good solution for this. I am glad you have found a solution to detect the audio silence.
Unfortunately i am unable to send you a email request as or send a private message. Very much appreciate if you could post the solution.
Hi Martha,
Did you find a solution for this? I am looking for an answer on the same problem.
Thanks, Peter