title: Converting PCM 16 bit audio to PCM 8 bit
body: <p>I want to implement in my android recording app the possibility to record using both PCM 16 bit and PCM 8 bit. I have a problem <code>converting a byte[] PCM 16 bit to 8 bit</code>, I tried different approaches, <code>but the size of the recording remained the same (for PCM 8 bit the size should be half of the PCm 16 bit)</code>. Here are those 2 approaches:</p>
  
  <p>first one:</p>
  
  <pre><code>        if(encoding == AudioFormat.ENCODING_PCM_8BIT){
              int i,j;
              int tempint;
              int len = data.length;
              for (i=1, j=0; i&lt;len; i+=2, j++){
                 tempint = ((int) data[i]) ^ 0x00000080;
                 data[j] = (byte) tempint;                    
              }
          }
  </code></pre>
  
  <p>second one:</p>
  
  <pre><code>        if(encoding == AudioFormat.ENCODING_PCM_8BIT){
              int len = data.length;
              for (int i=0, i&lt;len; i++){
                  data[i] = (byte)(data[i] &gt;&gt; 8);
              }
          }
  </code></pre>