Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Stripping silence from AVAudioRecorder recorded audio

I'm working on an iOS app that allows a user to record some audio. The audio is recorded using AVAudioRecorder then saved to a file.

I'd like to strip the silence from the beginning and the end of the recorded audio.

Any ideas?

like image 855
Hector Scout Avatar asked Apr 26 '11 20:04

Hector Scout


2 Answers

I am currently working no a similar task. It isn't trivial by any means. Because silence is not going to be a straightforward line of zeros. there is going to be some fluctuation.

If you're guaranteed a clean signal, it would be fairly trivial to set a marker on the first sample with an absolute value greater than say 0.001.

You can set an end marker without having to walk backwards through the file. all you do is, every sample greater than this threshold, you set the end marker to this sample.

If your input has the possibility of containing blips and squips before it starts properly, you will need a more advanced technique. Post a comment below and I will extend the answer.

like image 182
P i Avatar answered Nov 02 '22 09:11

P i


When I've built audio apps for iOS, the audio eventually ends up on a server. I don't know if your app is similar in that regard. If so, you can do what I did:

use SoX in the backend to post-process the audio, removing silence using a threshold.

If you need to do it all on the phone, it going to be harder. You should build a power level filter using OpenAL or an OpenAL wrapper library

like image 36
nont Avatar answered Nov 02 '22 11:11

nont