title: Swift - How to get the current volume from the microphone input (AVAudioPCMBuffer)
body: <p>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. </p>
  
  <p>So I'm asking, how do I see how loud the input is before streaming it to the other device. </p>
  
  <p>I'm recording audio using a AVAudioPlayerNode attached to an AVAudioEngine. I then use the following to actually record: </p>
  
  <pre><code>localInput?.installTap(onBus: 0, bufferSize: 4096, format: localInputFormat) {
      (buffer, when) -&gt; Void in
  </code></pre>
  
  <p>Here, buffer is an AVAudioPCMBuffer, so I need to be able to see the volume from this buffer.</p>
  
  <p>Thanks!</p>