As the update of Android 5.0L mentioned (http://geeknizer.com/audio-improvements-in-android-5-0-l-audiophile/), Android starts to support 96000Hz sampling rate. However when I try to do this on my Galaxy S6:
void checkAvailableSampleRate(){
for (int rate : new int[] {44100, 48000, 96000}) { // add the rates you wish to check against
int bufferSize = AudioRecord.getMinBufferSize(rate, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT);
if (bufferSize > 0) {
// buffer size is valid, Sample rate supported
Log.d(C.LOG_TAG,"Sample rate "+rate+" is supportted");
// just used for debugging
AudioRecord temp = new AudioRecord(MediaRecorder.AudioSource.MIC, rate, AudioFormat.CHANNEL_IN_STEREO, AudioFormat.ENCODING_PCM_16BIT, bufferSize);
Log.d(C.LOG_TAG,"make audioRecord successfully ");
}
}
}
I am unable to make 96000Hz work....
Here is the output I got:
Sample rate 44100 is supportted
Make audioRecord successfully
Sample rate 48000 is supportted
Make audioRecord successfully
Sample rate 96000 is supportted
My app crashes here so it means I can get the minBuffer when sample rate is set to 96000Hz but unable to create a AudioRecord instance.
and here is the error:
java.lang.IllegalArgumentException: 96000Hz is not a supported sample rate.
It is weird to me that AudioRecord.getMinBufferSize() works fine with 96000Hz but app crashes when I try to create a 96000Hz AudioRecord.
Has anyone has tried to record 96000Hz audio in Android?
-------------------------------------
Here is the update of my gradle setting:
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "edu.umich.cse.echotag"
minSdkVersion 21
targetSdkVersion 21
ndk {
moduleName "detection"
}
} ....