title: Java - Convert 16bit Mono PCM raw data to stereo
body: <p>I am mixing two 16bit PCM samples into a short buffer.</p>
  
  <pre><code>// This is our buffer for PCM audio data
  mp3Buffer = new short[minBufferSize];
  wavBuffer = new short[minBufferSize];
  mixedBuffer = new short[minBufferSize];
  </code></pre>
  
  <p>I am filling these buffers with samples from both the mp3 and wav files.  I found out that the wav file will always be in mono and the mp3 will always be stereo.</p>
  
  <p>I've read that if you "Just allocate a buffer twice the size of the original PCM data, and for every sample in the original buffer put it twice in the new buffer"</p>
  
  <pre><code>short[] stereoWavBuffer = new short[minBufferSize];
  int k = 1;
  for (int j = 0; j &lt; minBufferSize / 2; j += 2)
  {
      stereoWavBuffer[j] = wavBuffer[j];
      stereoWavBuffer[k] = wavBuffer[k];
       k += 2;
  
                  }
                  // TO DO -  Add the 2 buffers together
  
                  for (int i = 0; i &lt; minBufferSize; i++){
                      mixedBuffer[i] = (short)(mp3Buffer[i] + stereoWavBuffer[i]);
                  }
  
  
                  track.write(mixedBuffer, 0, minBufferSize); 
  }
  </code></pre>
  
  <p>How can I accomplish this? I tried this but the wav audio now is at regular speed but sounds like  chipmunk.</p>