正如提到的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但无法创建AudioRecord实例时,我可以获得minBuffer。

这是错误:



对我来说很奇怪,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"
        }
    } ....

最佳答案

操作系统可能支持96k,但是硬件也需要支持96k才能使该工作正常。
getMinBufferSize可能不是检查硬件支持的采样率的可靠方法。
看到这里How can I find out what Sampling rates are supported on my tablet?
AudioManager可以查询设备的本机参数。如果要检查是否支持96k,这可能会很有用。

        AudioManager am = (AudioManager) this.getSystemService(Context.AUDIO_SERVICE);
        Log.d(TAG, "onCreate: "+am.getProperty(AudioManager.PROPERTY_OUTPUT_FRAMES_PER_BUFFER));
        Log.d(TAG, "onCreate: "+am.getProperty(AudioManager.PROPERTY_OUTPUT_SAMPLE_RATE));
        Log.d(TAG, "onCreate: "+am.getProperty(AudioManager.PROPERTY_SUPPORT_MIC_NEAR_ULTRASOUND));
        Log.d(TAG, "onCreate: "+am.getProperty(AudioManager.PROPERTY_SUPPORT_SPEAKER_NEAR_ULTRASOUND));

更多阅读http://geeknizer.com/audio-improvements-in-android-5-0-l-audiophile/

希望它能对您有所帮助。

09-25 20:26