title: Writing WebRTC (AudioTrackSinkInterface) raw audio to disc
body: <p>I'm trying to record the audio transferred by a WebRTC <code>PeerConnection</code> <code>MediaStream</code>. I added a sink to the audio track which implements <code>AudioTrackSinkInterface</code>. It implements the <code>OnData</code> method:</p>
  
  <pre><code>void TestAudioTrackSink::OnData(const void* audio_data, int bits_per_sample, int sample_rate, size_t number_of_channels, size_t number_of_frames) {
      size_t valueCount = number_of_channels * number_of_frames;
      int16_t *_data = (int16_t*)audio_data;
  
      f.write((char*)&amp;_data, sizeof(int16_t) * valueCount);
      f.flush();
  }
  </code></pre>
  
  <p><code>f</code> is an <code>ofstream</code>. <em>Bits per sample</em> is 16, <em>sample rate</em> is 16000, <em>channels</em> is 1, <em>frames</em> is 160.</p>
  
  <p>But when I open the created file with AudaCity raw import (signed 16bit PCM, little endian, mono, sample rate 16000) I am not getting meaningful audio.</p>
  
  <p>How to I correctly write that raw audio date?</p>