Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use echo cancellation module in PulseAudio?

I trying to make PulseAudio echo canceller work.

I have two applications - recorder and player, both use PulseAudio. I create player and recorder like this:

 // pulseAudio
 pa_simple *paS=0;
 pa_sample_spec ss;

void initPulseAudio()
 {
     ss.format = PA_SAMPLE_S16LE;
     ss.channels = 1;
     ss.rate = 8000;


     paS = pa_simple_new(NULL,               // Use the default server.
                       "bottomPlayer",           // Our application's name.
                       PA_STREAM_PLAYBACK,
                       NULL,               // Use the default device.
                       "playStream",            // Description of our stream.
                       &ss,                // Our sample format.
                       NULL,               // Use default channel map
                       NULL,               // Use default buffering attributes.
                       NULL               // Ignore error code.
                       );

     if(!paS)
     {
         fprintf(stderr,
                 "unable to create recorder\n");
         myExit(1);
       }
 }

All is working, except echo cancellation. I have enabled it with

pactl load-module module-echo-cancel

but there is no difference with and without that module - echo exists. I am new with PulseAudio, and was unable to find good manual about echo canceller usage. What should i add or adjust in my devices setup to make it work?

OS - linux, now it is ubuntu, but finally it will be openWrt

like image 965
Raiv Avatar asked Nov 13 '12 15:11

Raiv


People also ask

How does audio echo cancellation work?

The echo cancellation circuitry examines the sound going into the microphone and compares it with the sound coming from the far end; it then cancels out the sound detected in both signals as that can only be the sound from the far end.

How do I cancel acoustic echo cancellation?

Open the Control Panel and click on Sound. Select the Recording tab, right-click the microphone being used, and select Properties. Select the Enhancements tab, disable all enhancements, and click Apply.

How do I get rid of background noise in Ubuntu?

head to Settings | Sound | Input and change your input device to the one that has (echo cancelled) at the end of it. That is it, you have echo cancellation enabled in Ubuntu.

How do I run Cadmus?

Download the latest cadmus. AppImage file on the releases page. Once downloaded, open the file in your chosen file explorer to run it (requires AppImage Launcher), or run chmod +x cadmus.


1 Answers

I'm assuming you're using PulseAudio 1.0 or above. For both the player and recorder streams, you need to set the "filter.want" property to "echo-cancel". We don't expose a way to do this using the simple API, so you will need to take a the slightly uglier route of setting the PULSE_PROP environment variable like this before you create the stream would do the trick:

setenv("PULSE_PROP", "filter.want=echo-cancel", 1);

p.s.: For really high quality echo cancelling, you want PulseAudio 2.0 or above, with the webrtc-audio-processing support built -- how easy it is to get this depends on whether your distribution already has this packaged up or not.

like image 183
Ford_Prefect Avatar answered Sep 25 '22 02:09

Ford_Prefect