Slashdot Mirror


Software Based Echo Cancellation?

tcyun asks: "I am helping to put together a small studio for a project at my workplace which will require some audio mixing. We have been able to find software solutions (often times open source) for almost all of our needs except for echo cancellation. I have done the requisite searches and have found a large number of hardware based echo cancellation devices, but have not found a purely software based solution. Is anybody aware of one?"

"For some more information, my office is trying to get a small system up and running that will allow multiple locations to video conference together. We have some specific requirements and have a fairly good handle on the entire video part of the problem.

However, we are running into problems with parts of our audio mix. The first issue is something that (I believe) is called 'mix minus.' This means that in a group conference, speakers do not have audio sent back to their location. (This is important for various psychology and network latency related issues.) There are several hardware based solutions that are available and we have some software based options.

The larger problem is echo cancellation. As many people may need to speak at once (and to avoid the requirement of having individuals constantly muting their microphones), we would like an echo cancellation component. The ideal would be a software solution that we could run locally, perhaps in conjunction with the same code running on the remote systems. However, most of the solutions we have found are hardware based (DSPs, ASICs, etc.).

The technology used on the studio side as well as the host side will involve various operating systems. We are trying to avoid avoid relying on specific OTC hardware solutions (namely, sound cards) as we would like to be able to create a solution that would function over time, particularly as specific hardware solutions tend quickly to horizon. So, having nice code that could be compiled on different systems would be a plus. Ideally, we would like to minimize the amount of hardware necessary, so an echo cancellation algorithm that could run in conjunction with other processes would be nice, but it is not a requirement."

24 of 211 comments (clear)

  1. Hardware Audio Tools by saveth · · Score: 5, Informative

    The reason you're finding more hardware tools than software tools for echo cancellation, among other things, is that the telecommunications industry demands these sorts of things with much more fervor than the average consumer. Echo cancellation devices (for example, a codec with echo cancellation built in, running on a DSP) are used extensively in cellular telephones, voice routers, and this sort of thing. Your best bet, in this respect, is to find a company that is willing to release the source code to the software that is running on your hardware.

    Alas, I do not know of any software, especially open source or free, that provides a full suite of audio processing utilities. Why is it that you're against using hardware, in the first place? Too expensive? Those are the breaks.

    1. Re:Hardware Audio Tools by newerbob · · Score: 2, Informative
      You don't want echo cancellation, you want an acoustically dead studio.

      Put foam on the walls.

      --

      --
      Ask the Ya-Hoot Oracle Anything!
  2. Noise gate by joshwa · · Score: 3, Informative

    As many people may need to speak at once (and to avoid the requirement of having individuals constantly muting their microphones),

    Why not just install a noise gate at the microphone inputs?

    For the non-audio-inclined slashdotters, a noise gate sets a minimum sound level threshold before the signal is transmitted.

    1. Re:Noise gate by Anonymous Coward · · Score: 3, Informative

      >>For the non-audio-inclined slashdotters, a >
      >>noise gate sets a minimum sound level threshold
      >>before the signal is transmitted.

      I'm no audio engineer, but it's obvious it wouldn't work.

      Person A talks into Microphone A - also picked up with a delay in Mic B.

      a)You want to cancel the echo from Mic B - so you use a noise gate. it works as long as i don't talk loud enough to cross the threshold on Mic B. Given that this is in a conference setting, the mic of the person next to me is going to pick me up without that huge of difference from the mic right in front of me. Whats the difference between me speaking loudly and the person next to me speaking somewhat softly? Not much and the gate doesn't know any different.

      b)To screw things up we only have to get over the threashold. So I'm speaking AND a neighbor starts to speak. So the sound at his mic is his voice + my voice. The total is over the threashold. Again - the gate does nothing.

  3. Asterisk PBX by Anonymous Coward · · Score: 5, Informative

    There's an excellent open-source PBX called Asterisk. Among other things, it provides an MMX-optimized echo-canceller. Look here

  4. Tough Problem by mellifluous · · Score: 3, Informative

    Maybe someone at /. will find an answer for you, but I would be surprised to see this implemented in any kind of stand alone SW package. Because it is a specialized real-time application requiring fast feedback, it makes sense to implement it as an embedded system (i.e. in hardware).

  5. Classic application! by spaceyhackerlady · · Score: 3, Informative

    Echo cancellation is a classic application of adaptive filters. Every reference ever published on the subject discusses it. I like Haykin's book myself.

    I just did a search on Google and came up with 4000 references.

    The underlying theory is pretty hairy, but the implementation of an algorithm like LMS is straightforward.

    ...laura

    1. Re:Classic application! by Erandir · · Score: 3, Informative
      Laura's right: you'll find the maths and the algorithms for echo cancellation in most textbooks on adaptive filtering. Check out the July 1999 issue of the IEEE Signal Processing Magazine (it shouldn't be too hard to get hold of it, most university libraries' engineering section should have it) -- it is an issue dedicated to "Adaptive Algorithms and Echo Cancellation". All the maths and algorithms you need are discussed there. Yes, you do need a good background in linear algebra to follow the underlying theory, but the algorithms should be easier to implement, and you're likely to find source code for most of them on the web (LMS filtering is used in many other applications too).

      Echo cancellation is a common design problem in hands-free telephone systems and conference systems; there is lots of literature on the subject. See the references in the articles I mention above.

    2. Re:Classic application! by Anonymous Coward · · Score: 1, Informative

      An LMS implementation of a noise canceller is about ten lines of Matlab (or Siglab) code. It will look something like this:

      % ref is your noise reference
      % ypri is your input signal mixed with the noise

      alpha = 0.2; % Time constant.. play with this
      L = 30; % Filter length. Play with this too.

      W_adap=0*(1:L); %initialize filter weights to zero
      pow = 1; % initial input power estimate
      beta=alpha/L; % normalize the time constant

      % You'd be doing this forever %
      for n = ((L-1)/2)+1:(length(ref)-(L-1)/2)

      % e is the cleaned up signal
      e(n) = ypri(n) - W_adap*ref((n-(L-1)/2):(n+(L-1)/2))';

      % mu is your update coefficient
      mu = alpha/L/pow;

      % W_adap are your filter weights.
      % This updates them
      W_adap = W_adap + mu*e(n)*ref(n-(L-1)/2:n+(L-1)/2);

      % This updates your power estimate, which you
      % will use for the next cut of mu
      pow = (1.-beta)*pow + beta*abs(ref(n))^2;
      end

      %% An SNR estimate
      % snrtot =sum(e.^2)/sum(ypri.^2);

      This may not be state of the art, but it will give you a very noticeable improvement. You may want to shift the center of your filter in time a little.

      There's a lot of variations on this problem, so do check out Haykin (or recent literature) if this doesn't do it for you.

      Luck,
      Jordan

  6. Forget software, get hardware by ttyp0 · · Score: 3, Informative

    I remember when I worked at Tellabs we had a product, EC-8000 Digital Echo Canceller Might be worth a look.

  7. Searches for echo cancellation software by Seth+Finkelstein · · Score: 5, Informative
    Am I misunderstanding the question? A Google search for "echo cancellation" software turns up quite a bit.

    Notably, a lead such as: http://www.nist.gov/speech/tests/ctr/h5e_97/echoca n.htm

    The echo cancelling software (ec_v2.5.tar.gz) that is applied to telephone data, may be obtained from Mississippi State University.

    The LDC has provided a perl script (mu_ec.perl) that will take a sphere-headered, 2-channel mu-law waveform file as input, apply the MSU/ISIP echo cancellation software, and produce a sphere-headered, 2-channel mu-law waveform file as output.

    Sig: What Happened To The Censorware Project (censorware.org)

    1. Re:Searches for echo cancellation software by stilwebm · · Score: 3, Informative

      This is a good start. Note that the perl script linked to above only provides raw data to the ec.exe binary, but the source code is linked to on that page. Also, there is more information and the source code at http://www.isip.msstate.edu/projects/speech/softwa re/legacy/fir_echo_canceller/. Nevertheless, consider:

      * In running the echo canceller on sparcs (ss20, SPARCserver-1000), it takes between 3 and 4 times realtime to operate.


      Now a Pentium III 800 will probably run it in a fraction of the time for an SS20, say 1/2 realtime to 1/4 realtime. But if it is for a mixing project, there will be several streams to process. I wonder if the cost of having to use a dedicated computer for software processing will outweigh the cost of dedicated DSP hardware?

  8. Re:Hardware Audio Tools (alternative?) by Harley · · Score: 2, Informative

    I was amazed at all the processing going on inside the DSP back when I tested, and later debugged/coded, modems for a living. When you mentioned echo cancellation, it was the first thing that popped into my head.

    A logical extension of this for your application would be to try to get your hands on some source code from a "Soft" modem. The idea was to move the most intensive processing out of the DSP and onto the PC processor since they were, in theory, becoming powerful enough to handle all the operations in real-time. Actual performance of these types of modems is a completely separate story, but the echo cancellation code is out there somewhere. At thing point it should just be a matter of getting your hands on it.

  9. The Analog devices EZ-Kit (a 2181 demo) has it. by Ludwig668 · · Score: 5, Informative

    Check out Analog devices; their 2181 demo has echo cancellation as a part of the included software; source included.

  10. Re:One possible solution... by TuxLuvr · · Score: 2, Informative
    But that link doesn't point to a software solution at all. That's a hardware device, and it doesn't do noise/echo cancelling, it does videoconferencing. I'm sorry to say that you're a little off.

    Whoops! My bad.... I meant to post THIS link...

  11. A possible simpler solution by hidden · · Score: 3, Informative

    1) Use directional microphones, or else throat mikes. This will make the neigbour's microphone only pick some one up very quietly, if at all.

    2)if there is still some echo problem, it should be quiet enough that simple (software) noise gates should solve the problem.

  12. You need an acoustic echo canceller by Anonymous Coward · · Score: 5, Informative

    Most solutions offered by Ditech, Telogy, etc. cancel the electrical echo caused by an impedance mismatch 2 to 4-wire hybrids in the analog part of the Old Telephone Network. You seem to develop a packet-based videoconferencing system, which has no hybrid in it, so you must want to cancel acoustic echo, caused by reflection of the sound produced by the speaker-phone on the walls of a conference room.
    This is a very hard problem, because you have to modelize the environment of each conference room. You will have to guess mathematically (with the LMS algorithm for example) the echo response on a tail of at least 128ms for each room, which would take at least a few minutes to one hour on a P4 2GHz system.
    And what about if a door is suddenly closed in the conference room? Or what if the speaker phone is moved? You will have to re-modelize your echo response each time that happens, because the geometry of the room will have changed.
    The solution is surely not a software echo cancellation system, at least not before 2010.
    Think about a hardware solution, DSPs or ASICs (http://www.octasic.com)

  13. Um..one of each of these... by teamhasnoi · · Score: 3, Informative
    One (good) omnidirectional condenser Mic in center of room; everything will be in phase and mono. Send this signal to a noise gate to cancel out paper rustling, and then a compressor (hard or software). I'd guess a 1:10 (or less), with a threshold of -20db (give or take) and a soft limiter would do it. This will equalize the volumes between the loud drunk salesguy, and the quiet intern. Educate members of meeting that they need to speak confidently.

    I guess I don't see why NOT routing the audio back would be a problem, or maybe I don't understand the question.

    Otherwise, save your paper towel rolls, and hand them out before a meeting. I don't do this for a living, so YMMV.

  14. IBM Has One For License by vivekb · · Score: 2, Informative
    IBM has a software based solution (unfortunately only available as a Windows DLL) that is very impressive. I evaluated it for a project, but it wound up costing too much. Still, you could try contacting their lab in Israel.

    I doubt you will find an open source echo canceller, since acoustic echo cancellation is pretty difficult (and has generated many, many patents). Nearly everyone uses a different, proprietary algorithm.

    If you want to make one yourself, set aside about 10 months.

  15. Re:perhaps the reason you can't find it... by blair1q · · Score: 3, Informative

    A DSP is just a CPU with one or twelve little two-step and array-math hacks in it. Any CPU that's 2X faster in FLOPs can do the same thing with ordinary arithmetic code.

    There are lots of new CPUs that are faster than lots of 5-year-old DSPs.

    --Blair
    "But then Microsoft puts the code in a directory somewhere under C:\Windows and kills the market."

  16. Echo cancellation on 12 lines of code. by Petrus · · Score: 4, Informative

    #define AdaptationRate 0.99
    // Basic adaptive LMS FIR algorithm.
    float EchoCancellation(float Sample)
    {
    static float History[MAX_ECHO_DURATION+1] = 0;
    int i;
    float AdaptationRate;
    float EchoAmpl;

    for( i=0; iMAX_ECHO_DURATION; i++)
    {
    EchoAmpl = History[i]*Coef[i];
    Coef[i] *= AdaptiationRate*(Sample-EchoAmpl);
    History[i+1] = History[i];
    }

    History[0] = Sample;
    return Sample-EchoAmpl;
    }

    That's all the "basic" science.
    You might find, that for 40kHz and 250ms echo this is too computationally intensive for a single Pentium. You may need some 1200 MIPS.

    You may then:
    1. Use Athalon ;-)
    2. Convert it to pointer arithmetic
    3. Convert it to integer arighmetic
    4. Skip some samples for echo estimation, sometimes
    5. Contact me to use more clever algoritm (IIR?)
    (Petrus.Vectorius@ied.com)

    1. Re:Echo cancellation on 12 lines of code. by Petrus · · Score: 2, Informative

      There is a bug.
      The line:
      Coef[i] *= AdaptiationRate*(Sample-EchoAmpl);
      Should be
      Coef[i] += AdaptiationRate*(Sample-EchoAmpl)*History[[i];

      Otherwise the Coef[i] would always stay at 0.

  17. Use low-tech solutions first. by Lumpy · · Score: 3, Informative

    if you are creating your studio then you need to make the studio fix the problem first, dont try to compensate for a crapy studio in the recording hardware/software.

    #1- Sonex, sonex, sonex. If you dont have sonex or the crappy sonex copy or even just carpet on the walls (Yes wall carpet looks good) along with the roughest texture ceiling tiles you can buy at the home-depot (or better yet the $90,00 a 2foot square city scape audio ceiling tiles) then you are wasting your time. it takes very little to make a room acoustically deadened to the point that properly set up microphones wont pick up any perceptiable echo. (Note: if you have you're mic's set so your artists or voice talent is farther away than 3 inches from the P popping screen then you have it set wrong. also dont let the talent talk quietly, make then talk or sing loud to overcome room acoustics.

    start with the low tech, then add your high tech bandaid filters.

    --
    Do not look at laser with remaining good eye.
  18. I've worked in a radio studio by AlaskanUnderachiever · · Score: 3, Informative

    Hell I helped build one. And while there is a LOT of noise cancellation and "echo reduction" software on the market (Cool Edit Pro has a few nice plug ins) the sound quality after applying such a filter could at best be called "fair". Unfortunately your best solution is to find a high quality mic with a bit of noise cacellation (and the higher end ones can be "tuned" with a hardware equilizer) and just suck it up and BUY THE FOAM. I know it's ugly. I know it's a pain in the ass. I know it's only effective if the studio is designed well, but nothing that I have personally seen (well under 40k that is) beats the stuff. Acoustic dampening foam is your cheapest option that will still maintain audio quality to a reasonable degree.

    --
    Find out about my new childrens book: SS Death Camp Criminal Batallion Go To Monte Carlo For The Massacre