Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AudioEffect AcousticEchoCanceler is not working with Oboe #951

Open
banburubi opened this issue Jul 21, 2020 · 6 comments
Open

AudioEffect AcousticEchoCanceler is not working with Oboe #951

banburubi opened this issue Jul 21, 2020 · 6 comments
Assignees
Labels

Comments

@banburubi
Copy link

Android version(s): 10
Android device(s): Google Pixle 3a
Oboe version: 1.4.2
App name used for testing: Similar to LiveEffect

Short description
In voice related application, I'm working on, I have a feedback loop and to avoid it I'm trying to apply Android AEC effect to Oboe Input stream. The acutal sample does not work: https://github.com/google/oboe/blob/master/docs/notes/effects.md

Steps to reproduce

In my case for AEC to be intialized properly I need to use such code in Java:

        int sampleRate = 48000;
        int channelConfig = AudioFormat.CHANNEL_IN_MONO;
        int audioFormat = AudioFormat.ENCODING_PCM_16BIT;

        int chunkSize = AudioRecord.getMinBufferSize(sampleRate, channelConfig, audioFormat);
        int bufferSize = chunkSize;

        int audioSource = MediaRecorder.AudioSource.MIC;
        record = new AudioRecord( audioSource,
                sampleRate,
                channelConfig,
                audioFormat,
                bufferSize );

        audioSessionId = record.getAudioSessionId(); //This session id is passed to Oboe through jni

a few strings below there is such an activation of AEC:

        if(AcousticEchoCanceler.isAvailable())
        {
            aec = AcousticEchoCanceler.create( sessionId );
            if(null != aec)
            {
                if ( !aec.getEnabled() )
                {
                    aec.setEnabled(true);
                }
            }
         }

Oboe stream is created later with session id from AudioRecord.

There are no errors, AEC is enabled and session id is set to Oboe Input stream. I'm still getting low-latency steam the only difference it is not Exclusive anymore (when session id is set).

I have also tried with NoiseSuppressor effect with the same result.

Expected behavior
Echo and some noise should be removed if an effect is attached.

Actual behavior
Does not work.

Looking forward to your feedback.

Thank you very much.

P.S. Probably these issues are related:
#296
#898
#85

Best,
Vladymyr.

@banburubi banburubi added the bug label Jul 21, 2020
@philburk philburk added question and removed bug labels Jul 22, 2020
@philburk
Copy link
Collaborator

Do not create an AudioRecord. Just allocate a sessionId.

AudioManager audioManager = (AudioManager) context.getSystemService(Context.AUDIO_SERVICE);
int audioSessionId = audioManager.generateAudioSessionId();

@banburubi
Copy link
Author

banburubi commented Jul 22, 2020

Thank you veyr much for the reply.

  • When I'm trying to use session id from audioManager.generateAudioSessionId() to create AcousticEchoCanceler by AcousticEchoCanceler.create( sessionId ) it returns null when I use session from AudioRecord - it is not null

  • Though I found how to make it work, it is sarting to work when I change preset on input stream creation
    builder->setInputPreset(oboe::InputPreset::VoiceCommunication), but then I'm getting not a Low-latency stream. Can I do something to keep the stream Low-latency?

@philburk
Copy link
Collaborator

I'm still getting low-latency steam the only difference it is not Exclusive anymore (when session id is set).

EXCLUSIVE streams are only supported on the new MMAP data path. Sessions and Effects are only supported on the Legacy data path. The Legacy data path will not use the FAST low-latency mixer when effects are enabled.

I will review this limitation with the team.

One way to achieve low latency with effects is to add your own effects above the OS.

@philburk philburk self-assigned this Jul 22, 2020
@banburubi
Copy link
Author

Thank you very much.
It is clear. I will try to integrate AEC from WebRTC it is just a bit more time consuming from the development perspective.

@Cova8bitdots
Copy link

@philburk
Hi, Is this issue not solved on low-latency audio thread yet?
If not, are there any way to achieve to implement in Oboe-layer?

I'm working to create karaoke-live-streaming app on Android.
There is problem when user does not use earphone( audio feedback happens )

@philburk
Copy link
Collaborator

I improved the Effects test in OboeTester.
I then tested on a Pixel 3a running RQ1A. (11).
I was able to get a low-latency input stream when I enabled the effect. I was using InputPreset=VoiceRec.
If I selected VoiceCommunication then I did not get any input signal.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants