title: Calculating the Frame Rate and Size for a Timed Stream of a Byte Array
body: <p>This question might be a little tricky.</p>
  
  <p>I am trying to send a Byte[] over a Windows Socket with a System.Timer.</p>
  
  <p>The Data is a wav file, the common encoding is 8Khz 16bits per sample.</p>
  
  <p>This article explains in some detail what I am trying to do: <a href="http://www.eetimes.com/document.asp?doc_id=1277103" rel="nofollow">Creating audio applications with Bluetooth</a></p>
  
  <blockquote>
    <p>In an MP3 application, suppose the device is sending an MP3 stream from a file encoded at 128 kbit/sec and 48 kHz sample frequency. This means an MP3 audio frame 384 bytes long is sent every 24.0 msec. So, if the device simply sets a periodic timer for 24.0 msec and sends a packet when the timer expires the constant bit rate will be maintained.</p>
  </blockquote>
  
  <p>My question is, how are these figures derived? How is it that audio frame is <strong>384</strong> bytes long and how do we know the periodic timer is <strong>24.0 msec</strong> </p>
  
  <p>How are these figures calculated from the Encoding format: 128 kbit/sec and 48 kHz sample frequency?</p>
  
  <p>Math I have tried:</p>
  
  <pre><code>double BitsPerSample = 128000;
  double SamplesPerSecond = 48000;
  
  // 1 for Mono, 2 for Stereo:
  double Channels = 2;
  
  double SingleFramePeriod = 1 / SamplesPerSecond;
  double BitsPerSecond = SamplesPerSecond * BitsPerSample * Channels;
  double BytesPerSecond = ( BitsPerSecond / 8 );
  double BytesPerFrame = (1 / (BitsPerSecond / 8));
  </code></pre>
  
  <p>None of which give me the above figures.</p>