title: Resample audio using libsamplerate in windows phone
body: <p>I'm trying to re-sample captured 2channel/48khz/32bit audio to 1channel/8khz/32bit using libsamplerate in a windows phone project using WASAPI.</p>
  
  <p>I need to get 160 frames from 960 original frames by re-sampling.After capturing audio using <code>GetBuffer</code>  method I send the captured BYTE array of 7680 byte to the below method:</p>
  
  <pre><code>void BackEndAudio::ChangeSampleRate(BYTE* buf)
  {
  
  int er2;
  st=src_new(2,1,&amp;er2);
  //SRC_DATA sd defined before
  sd=new SRC_DATA;
  
  
  BYTE *onechbuf = new BYTE[3840];
  int outputIndex = 0;
  
  //convert Stereo to Mono
  for (int n = 0; n &lt; 7680; n+=8)
  {
      onechbuf[outputIndex++] = buf[n];
      onechbuf[outputIndex++] = buf[n+1];
      onechbuf[outputIndex++] = buf[n+2];
      onechbuf[outputIndex++] = buf[n+3];
  }
  
  float *res1=new float[960];
  res1=(float *)onechbuf;
  
  float *res2=new float[160];
  
  //change samplerate
  sd-&gt;data_in=res1;
  sd-&gt;data_out=res2;
  sd-&gt;input_frames=960;
  sd-&gt;output_frames=160;
  sd-&gt;src_ratio=(double)1/6;
  sd-&gt;end_of_input=1;
  int er=src_process(st,sd);
  
  transportController-&gt;WriteAudio((BYTE *)res2,640);
  
  delete[] onechbuf;
  src_delete(st);
  delete sd;
  
  }
  </code></pre>
  
  <p>src_process method returns no error and <code>sd-&gt;input_frames_used</code> set to 960 and <code>sd-&gt;output_frames_gen</code> set to 159 but the rendering output is only noise.
  I use the code in a real-time VoIP app.
  What could be the source of problem ?</p>