ofxEchoCancel + soundStream

I’m trying to use the ofxEchoCancel addon to process signals coming from ofSoundstream. I need to remove echo from the audioIn() and audioOut() buffers.
Has anyone tried this addon? I can’t figure out how to use it…

this addon is meant to be used to cancel echo from network streams not from in/out since that will also create a feedback loop that the library that it uses won’t usually be able to cancel.

But could it be used to cancel echo from two different inputs without sending it to any output??. I’m using tio mics on stage, and I have mic1 signal entering also into mic2, with less intensity of course and a few ms delayed.
I just want to analyze the two audio signals isolated, no need to output them to any speaker.

Thanks in advance!

that should work i guess although i’ve never tried it. there’s some limitations to the usage of the underlying library, mainly, the sampling rate needs to be 32000Hz and the buffers need to have a length of 10ms so on the audioIn you’ll need to copy the input to the webrtc::AudioFrame in chunks of that size, if you are using mono 32000Hz that would be 3200 samples.

the initialization will look something like:


    frame._payloadDataLengthInSamples = samplesIn10MS;
    frame._audioChannel = 2;
    frame._frequencyInHz = 32000;

and then copy the float input into the frame using

frame._payLoadData[i] = input[j]*std::numeric_limits<short>::max();

if you want to remove mic1 from mic2 you should pass the input from mic1 in echoCancel.analyzeReverse() and mic2 in echoCancel.process(), the resulting output will be in the frame you pass to process

you can specify the delay in ms using echoCancel.getAudioProcessing()->set_stream_delay_ms(ms);

there’s more information in the library headers, specially in libs/webrt-audio-processing/src/modules/audio_processing/interface/audio_processing.h

I tried to test it but it tells me that webrtc::Audioframe class has no member ‘_payLoadData’. However, working with a 3200 sample buffer is a problem. For all the audio analyzing processes i’m working with, I need a buffer size 2^x (512,1024,2048,etc). Thanks a lot anyway!

yes, the variable is _payloadData. Also you can still use power of 2 block sizes but create 3200 blocks from that by, for example, accumulating several 512 blocks and passing them to the echo cancel module, store the remainder and use it in the next block