Domanda

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

È stato utile?

Soluzione

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.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top