根据Android 5.0L的更新(http://geeknizer.com/audio-improvements-in-android-5-0-l-audiophile/)提到,Android开始支持96000Hz采样率。然而当我在我的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 ");
}
}
}
我无法使96000Hz工作......
这是我的输出:
Sample rate 44100 is supportted
Make audioRecord successfully
Sample rate 48000 is supportted
Make audioRecord successfully
Sample rate 96000 is supportted
我的应用在这里崩溃,这意味着当采样率设置为96000Hz时,我可以获得minBuffer但无法创建AudioRecord实例。
以下是错误信息:
java.lang.IllegalArgumentException: 96000Hz不是支持的采样率。
对我来说很奇怪的是,AudioRecord.getMinBufferSize()在96000Hz下工作正常,但是当我尝试创建一个96000Hz的AudioRecord时,应用程序会崩溃。
有人在Android中尝试过录制96000Hz音频吗?
-------------------------------------
这是我的gradle设置更新:
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "edu.umich.cse.echotag"
minSdkVersion 21
targetSdkVersion 21
ndk {
moduleName "detection"
}
} ....