title: Android - Audio Record - Sample rates
body: <p>I developed a game for android that uses Audio Record to get the mic input.</p>
  
  <p>You can have a glance at <a href="https://play.google.com/store/apps/details?id=fixappmedia.micro" rel="nofollow">https://play.google.com/store/apps/details?id=fixappmedia.micro</a></p>
  
  <p>The thing is that I'm using the following function to get the sample rates available on the phone:</p>
  
  <pre><code>public int getValidSampleRates() {
              int r=8000;
              for (int rate : new int[] {8000,11025,16000,22050,44100}) {  // add the rates you wish to check against
                  int bufferSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT);
                  if (bufferSize &gt; 0) {
                      r= rate;
                  }
              }
              return r;
          }
  </code></pre>
  
  <p>I tested it initially on my phone (Samsung Galaxy Vibrant) and it worked pretty well... but today I tested it on a Samsung Galaxy Ace and the sample rate didn't work...</p>
  
  <p>Any ideas on why?</p>