I am recording audio from the microphone and streaming that audio to another device. Currently, this audio is sent across the stream even when the user isn't talking. But I've noticed that a lot of streaming services don't actually send your mic input when they detect that there is very little noise coming from it.
So I'm asking, how do I see how loud the input is before streaming it to the other device.
I'm recording audio using a AVAudioPlayerNode attached to an AVAudioEngine. I then use the following to actually record:
localInput?.installTap(onBus: 0, bufferSize: 4096, format: localInputFormat) {
(buffer, when) -> Void in
Here, buffer is an AVAudioPCMBuffer, so I need to be able to see the volume from this buffer.
Thanks!