0

I'm recording my voice through a Bluetooth headset (ERA JAWBONE) and playing it in realtime on the phone speaker. This works with the following code:

    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();
    }

But my headset is picking up every sound in the room and starts to echo. When I use the headset to make a call my voice is clear. According to the specs the JawBone uses NoiseAssassin, but I'm pretty sure that it isn't activated when I'm using the code above. Nor is the noisesuppressor or echocanceler available on my device.

Is there a way to filter out the noise and have just a clear voice coming from the phone speaker?

Diego
  • 4,011
  • 10
  • 50
  • 76
  • I have same problem with you. Do you resolve it? This is my project https://www.dropbox.com/s/0wjll7q01ahg402/AudioDemo51.rar?dl=0 – John Jan 05 '15 at 14:26
  • No - haven't found the answer yet. Let me know if you make any progress. – Diego Jan 06 '15 at 19:01
  • I spend 2 week to find what is happen. And I found that if we turn off the speaker(only use the earphone), the echo sound does not appear. However, my main goal uses speaker. So, I do not resolve it, This is my new code and system design https://drive.google.com/folderview?id=0B7E5Nuki4eZhNmt3SXBwZWhlckE&usp=sharing – John Jan 07 '15 at 02:10

0 Answers0