Customizing Audio Tools Library for Adaptive Noise Cancellation on ESP32 #1475
-
Hey there, I am currently working on a project that aims to eliminate ambient noise while wearing headphones that do not have active noise cancellation capabilities. My physical setup includes an INMP441 microphone as one of my audio inputs, and a PCM5102 DAC breakout board as my audio output. This involves using an adaptive FIR filter (LMS algorithm, such as what is done here: https://github.com/wespo/LMS/blob/master/LMS.h) to effectively cancel out the noise that the microphone is collecting by using the filter output to find the difference between it and the desired signal that will be sent to the DAC alongside the desired signal (can be music via Bluetooth, or zero if the music isn't playing). I am using an ESP32-WROOM-32E devkit and working in the Arduino IDE. Project Overview The project is ambitious, so the first step I took was to send the microphone audio as-is to the DAC. If I could get that audio to my ears, then I could experiment with filtering techniques to see what I could do about generating anti-noise. Using the example streams-i2s-i2s-2, I was able to successfully transfer data from the microphone to the DAC and the audio quality is great, albeit with a minor delay. Technical Challenges and Debugging Steps
The audio quality produced by my code is not good; it has a consistently higher pitch and exhibits static/clipping distortion, which is unusable for my application. The only benefit is that the audio is sent to the DAC instantaneously, without the small delay I notice from the streams-i2s-i2s-2 code. I have confirmed that the microphone, DAC, and Bluetooth module all work perfectly when tested separately, which leads me to believe the issue is likely due to how I'm integrating everything in my code. Integration and Library Use Specific Questions
Any thoughts or comments would be greatly appreciated. Also, please let me know if there is any other information or details I may have left out that would help to provide a more accurate resolution to the issue at hand, I know there is a lot going on here. Thanks! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
I suggest that you read the chapter about 'using Filters' in the Wiki and maybe read the 'The most important basics' as a precondition, which also answers some of your questions. In order to decrease the delay you can decrease the I2S buffer size and count settings. You can use the same values that you used above! The INMP441 is tricky to use, so don't ignore the advice given in the External 'ADCs and Microphones' chapter One of the goals of my library was really, that you can do exactly the same, like in your example, but with much fewer lines of code: But the called functionality is the same. |
Beta Was this translation helpful? Give feedback.
I suggest that you read the chapter about 'using Filters' in the Wiki and maybe read the 'The most important basics' as a precondition, which also answers some of your questions.
In order to decrease the delay you can decrease the I2S buffer size and count settings. You can use the same values that you used above!
The INMP441 is tricky to use, so don't ignore the advice given in the External 'ADCs and Microphones' chapter
One of the goals of my library was really, that you can do exactly the same, like in your example, but with much fewer lines of code: But the called functionality is the same.