0

I am trying to understand how to properly use two WebRtcAecm functions. It seems there are the two main functions that are used for echo cancellation on mobile.

The first one is WebRtcAecm_BufferFarend:

int32_t WebRtcAecm_BufferFarend(void* aecmInst,
                            const int16_t* farend,
                            int16_t nrOfSamples);

I guess this is where we pass in the audio data that we receive from the remote end. Do we keep calling this method as we continue to receive audio packets? Also, does the function make a copy of the passed-in buffer so that we could reuse the same buffer for the next packet?

The other function is WebRtcAecm_Process:

int32_t WebRtcAecm_Process(void* aecmInst,
                       const int16_t* nearendNoisy,
                       const int16_t* nearendClean,
                       int16_t* out,
                       int16_t nrOfSamples,
                       int16_t msInSndCardBuf);

In a code snippet on the Internet, I saw that the same pointer was being used for nearendNoisy and nearendClean. Shouldn't nearendClean parameter be null if we don't do any noise suppression?

Finally, is there any issue in calling these two methods in two different threads? Our remote audio receiver code is in one thread and our microphone listener code is in another thread.

Thank you in advance for your help.

Zong
  • 6,160
  • 5
  • 32
  • 46
Peter
  • 11,260
  • 14
  • 78
  • 155

1 Answers1

0

I've post a project on github which will show you exactly how to call these functions.

nearendClean can be set to NULL indeed, and I always set it to NULL, cus' my NS is after AECM procession.

Holp I helped :)

Bill Hoo
  • 647
  • 5
  • 21
  • Hi billhoo. I executed your example and its output was a new file. But when I played it, didn't have any sound (even human's voice in input file). Can you help me? Thanks. – Spinning Dec 11 '13 at 08:17
  • @Spinning Hi, I take the same PCM audio as both nearend and farend signals, and set the delay to 10ms, so the ideal output is no sound at all. BTW, after a long long time to optimize my program with AECM(even APM), I still cannot get it work 100% perfect in a real time VoIP call. So if you wanna use AECM, prepare to its feedback. More info. can be found in [google aecm issues](https://code.google.com/p/webrtc/issues/list?can=2&q=aecm&colspec=ID+Pri+Mstone+ReleaseBlock+Area+Status+Owner+Summary&x=mstone&y=owner&cells=tiles) – Bill Hoo Dec 11 '13 at 14:45
  • @Billhoo: Thanks a lot. BTW, do you have any example about NS in webrtc? I saw your comment on another question is you were successfull with NS/ADV on mobile. – Spinning Jan 02 '14 at 09:39
  • @Spinning Implements NS and VAD on android is much more simple than AECM, so I have no demo for that. You just need wrap the WebRTC_NS interfaces into JNI functions and call them from Android java layer, iOS is the same. Regards. – Bill Hoo Jan 02 '14 at 12:23
  • @Billhoo: Thanks, I will try. But how do you split input into LBand and HBand? – Spinning Jan 03 '14 at 03:05