我正在通过蓝牙耳机 (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,但我很确定当我使用上面的代码时它没有被激活。我的设备上也没有噪音抑制器或回声消除器。
有没有办法过滤掉噪音,让手机扬声器发出清晰的声音?