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
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.
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.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With