Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 4 of 4

Thread: Mic echo cancelation

  1. #1
    Member
    Join Date
    Jun 2020
    Location
    The Netherlands
    Posts
    24

    Mic echo cancelation

    Hi Team, how are all of you?

    Ive got a question about mic echo cancelation, and if this is doable with the teensy?

    at the moment when i speak trough the mic, i dont hear myself from the speaker, so i routed the signal also to the speaker output (just a little bit) so i have a bit of an refference that i am speaking, thus resulting in a feedbackloop(harsh resonance spike)
    So this situation is not really wanted,
    Not having a noise canceling mic (based on 2 mic's) i started to search if there are any examples to learn from.
    i saw a tiny bit of info that it is perhaps possible to que en play the audio? and perform some filtering on that audio by coping the signal in phase,
    But starting to dig a bit deeper (also on this forum) the information gets a bit blur quickly.

    if one could help me or point me in the right direction, that would be much appreciated,

    Thnx in advance,
    Danny

  2. #2
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    314
    The answer to your question depends upon another question: what algorithm would you use to adapt to and cancel the echo?

    If you're going to use a traditional algorithm like some version of LMS, you need to have enough memory and processing power in order to model the full duration of the echo.

    So, if the distance between your speaker and your microphone is 1 meter, you'd need to model 1m / 343m/s = 3 msec. At a sample rate of 44100 Hz, that represents 128-129 samples. The modeling and canceling ends up looking like an FIR filter (or two). So, basically, you need to do one (or two) FIR filters that are 128 points long. Can the Teensy support that?

    If you're using a Teensy 3.5, 3.6, or 4.1, I think that you can definitely do it. If you're using a lesser Teensy, I'm not so sure.

    Chip

  3. #3
    Member
    Join Date
    Jun 2020
    Location
    The Netherlands
    Posts
    24
    Hi chip, thnx for the answer.
    I guess i have a basic setup, small speaker and small table mic, diy equipment to fit the teensy 4.0 and its audio breakoutboard. I use it for some hobby ham radio stuff, and to educate myself. But the response when I talk in the mic isnít there (other than a led) so thatís were the idea came from to feed my own voice a bit back to me over the speakers, also as indication that I wonít start screaming in the mic 😅, this idea I got from headphones/headsets that have a similar option so that the operators in a control room wonít raise their voices louder and louder.

    At the moment I am using the audio design tool, and impressed by the things that it offers, but just with a lpf and hpf filter to filter everything accept my voice, isnít enough unfortunately and starts to resonate.

    I believe I have found (I thought u were in this project as well?) janbobís float32-lib, but the novice as I am, the starting point to ďplay aroundĒ with this is a bit unclear for me, and what the proper route would be to address this? Also an possibility is that I am way overthinking this and that there would be an much easier solution to suppress the feedback.

    Thanks for your advice
    Danny

  4. #4
    Senior Member
    Join Date
    Oct 2015
    Location
    Vermont, USA
    Posts
    314
    There may indeed be an easier way than my assumption of needing a closed-loop adaptive algorithm. It'd be great if someone else could chime in if they know an easier way. An easier way would be great!

    If the only way is the way that I'm familiar with, it's the closed-loop nature of these algorithms that make them qualitatively different from the other algorithms in the Teensy Audio Library supports. None of these algorithm blocks require you to have a connection that loops back on itself like these cancelation algorithms require. Therefore, there are no examples in the Teensy Audio Library that you can learn from to see how closed-loop adaptive processing is done.

    You also mentioned the OpenAudio library (https://github.com/chipaudette/OpenAudio_ArduinoLibrary). Sadly, it doesn't have any closed-loop algorithms either. Like the Teensy audio library, everything is open-loop.

    In the Tympan Library (https://github.com/Tympan/Tympan_Library), we do have a feedback cancelation algorithm (see "AudioEffectFeedbackCancel.h"), which does require a closed-loop configuration of audio connections in order to do its job. This particular algorithm was designed for suppressing feedback and not for being an echo canceller, but I think that they both require the same kind of structure. So, it could be helpful...but I could be wrong.

    As another option, I think that the ARM CMSIS math library (for Teensy 3.x and higher) has an LMS algorithm and a normalized LMS algorithm in it, but I've never used them, nor do I know how to set them up or how to tune them.

    Oh yeah, whether trying the algorithm in the Tympan Library or the ones in the CMSIS library, tuning the settings of adaptive algorithms can be tricky. Adaptive closed-loop algorithms can behave very unexpectedly. If you don't have much experience in this area, be prepared for some frustration.

    Or, maybe you'll sail through easily and have total victory! If you do, share your findings!
    Last edited by chipaudette; 09-14-2021 at 09:40 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •