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.