Android examples for Media:Audio
Check correct buffer size for your AudioRecord instance
//package com.java2s; import android.media.AudioRecord; public class Main { /**/*w w w. j a v a 2 s .c o m*/ * Check correct buffer size for your AudioRecord instance * * @param audioSource * the audio source * @param fs * the fs * @param channelConfiguration * the channel configuration * @param audioEncoding * the audio encoding * @return the int */ public static int checkCorrectBufferSize(int audioSource, int fs, int channelConfiguration, int audioEncoding) { for (int buffer : new int[] { 256, 512, 1024, 2048, 4096 }) { // add the rates you wish to check against AudioRecord audioRecordTemp = new AudioRecord(audioSource, fs, channelConfiguration, audioEncoding, buffer); if (audioRecordTemp != null && audioRecordTemp.getState() == AudioRecord.STATE_INITIALIZED) { return buffer; } } return 0; } }