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?
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.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With