蓝牙耳机拾取噪音 - 如何激活NoiseAssassin等噪音抑制器

时间:2014-08-31 17:58:57

标签: bluetooth android-audiomanager audiorecord audiotrack noise-reduction

我通过蓝牙耳机(ERA JAWBONE)录制我的声音并在手机扬声器上实时播放。这适用于以下代码:

    buffer = new byte[buffersize];

    android.os.Process.setThreadPriority(
                android.os.Process.THREAD_PRIORITY_URGENT_AUDIO);
    aManager.startBluetoothSco();
    aManager.setBluetoothScoOn(true);
    aManager.setMode(AudioManager.MODE_NORMAL);

    arec = new AudioRecord(
                MediaRecorder.AudioSource.VOICE_RECOGNITION,
                hz,
                AudioFormat.CHANNEL_IN_MONO,
                AudioFormat.ENCODING_PCM_16BIT,
                buffersize); 

    if (AcousticEchoCanceler.isAvailable()) {
        AcousticEchoCanceler echoCanceller =        AcousticEchoCanceler.create(arec.getAudioSessionId());
        if (echoCanceller != null) {
            echoCanceller.setEnabled(true);
        }
    } else { Log.e(TAG, "Echo Canceler not available");}

    if (NoiseSuppressor.isAvailable()) {
        NoiseSuppressor noiseSuppressor = NoiseSuppressor.create(arec.getAudioSessionId());
        if (noiseSuppressor != null) {
            noiseSuppressor.setEnabled(true);
        }
    } else { Log.e(TAG, "Noise Suppressor not available");}


atrack = new AudioTrack(AudioManager.STREAM_MUSIC,
                    hz,
                    AudioFormat.CHANNEL_OUT_MONO,
                    AudioFormat.ENCODING_PCM_16BIT,
                    buffersize,
                    AudioTrack.MODE_STREAM);

    atrack.setPlaybackRate(pbhz);
    }


    aManager.setStreamSolo(AudioManager.STREAM_MUSIC, true);

    arec.startRecording();
    atrack.play();
    onRecording=true;

    Runnable runnable = new Runnable() {
          @Override
          public void run() {
              while (onRecording) {
                 arec.read(buffer, 0, buffersize);

                 atrack.write(buffer, 0, buffer.length);
             }          
            }
        };
        new Thread(runnable).start();
    }

但是我的耳机正在拾取房间里的每一个声音并开始回响。当我使用耳机拨打电话时,我的声音很清晰。根据规范,JawBone使用NoiseAssassin,但我很确定当我使用上面的代码时它没有被激活。我的设备上也没有可用的noisesuppressor或echocanceler。

有没有办法过滤掉噪音,只有来自手机扬声器的清晰声音?

0 个答案:

没有答案