atuline / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP32 over WiFi.
GNU General Public License v3.0
867 stars 130 forks source link

Soundreactive wled noise issue #167

Closed ArduinoNerdBheeshma closed 2 years ago

ArduinoNerdBheeshma commented 2 years ago

Describe the bug

Hello I'm making a diy nanoleaf with about 565 neopixels, a 5v 20a power supply, esp32 dev and a max 4466 electret mic. The esp boot cycles on power up but sometimes turns on fine. But when I turn on a music effect the leds bounce around in complete silence. Decreasing the gain on the max4466 does solve this issue but it becomes too un sensitive. Pls help To Reproduce Squinch:19 gain:5 ADC:34 Taped to my TV's speaker Depth: halfway Gain on mic board: unknown

Expected behavior The whole strip is off at silence’’ Reacts to music that is a bit faint too Reacts to bass Reacts to bass in rapid succession Maybe reacting to lyrics as well Maybe react to speech in the bg*

WLED version Esp32 dev

ArduinoNerdBheeshma commented 2 years ago

Update- Line in works but with bass only. Leds react only when bass is played. Also I misspelled depth it's intensity

atuline commented 2 years ago

Some questions:

You might want to check the quality of your power, because a squelch (and not squinch) of 19 should cut out a considerable amount of background noise. The microphones do not work below 60Hz.

Please note that there is a considerable amount of interference from the WiFi on the ADC. See Noise Article and that a better bet is to use an I2S microphone such as the INMP441 or ICS-43434. The noise issues are documented in our SR Wiki.

As for reacting to music that's faint, you would use Automatic Gain Control, however that's a tricky beast, because the device will no longer differentiate between quiet passages in a song and louder ones. Everything will look loud.

I recommend that you use a test sketch such as this sample sketch to ensure you don't have issues.

Please compare your results to Noise and Spikes article.

dosipod commented 2 years ago

Hello ,

I think I have seen you asking this question in wled discord or forum , please drop by the soundreactve channel as I have already replicated your setup with max4466 , 512 pixel ws2812b matrix and line-in on multiple MCUs with very good results and no noticeable ambient noise or interference issues .

As this seems to be a user setup/hw related , I think having a github bug report for WLED it is not accurate , kindly close the same .

If you drop by wled discord or forum and would like me to directly assist in isolating your issue then I am available with the name ALDIY .

Cheers , AL

softhack007 commented 2 years ago

Hi,

I have a similar setup with analogue MAX4466 microphone and ESP32 board (a "Lolin32 lite"). The mic itself seems to be very good, sensitive even with sound sources several meters away (clapping of hands, trampling feet, ..).

Squinch:19 gain:5 ADC:34 Taped to my TV's speaker

In contrast, the following works for me:

. However I found that there are several other hardware/wiring aspects that might introduce noise:

-> 1. use an input that is not related to "ADC2", i.e. the second ADC converter of the chip. This is used for Wifi, and the ports connected to it will not deliver meaningful values. --> Don't use these GPIOs: 00, 02, 04, 12, 13, 14, 15, 25, 26, 27

-> 2. stabilise the 3.3V power line. Its the ADC reference, so any noise (due to variations in power draw) affects analogue readings. --> For my board, I've seen great improvements after connecting a 1000µF capacitor between 3.3v and GND.. If you have, try to use a "low ESR" capacitor for this.

hope this helps :-)

softhack007 commented 2 years ago

Apart from that, there seem to be some sources of "artificial spikes" in the code for reading the MIC input and performing FFT. I managed to eliminated some of them in my own copy of the code, however it still needs a lot of cleanup before I can make a PR.

Some problems I found, especially for the FFT analysis:

I'm trying to make a PR with my proposal on how the code might be improved. However it may take some time...

atuline commented 2 years ago

Sounds like some real good additions/fixes. You might also want to talk to Haribo on the WLED Discord. He's been involved with the sound stuff as well.

softhack007 commented 2 years ago

Thanks, will try to chat with him 👍 once I have cleaned up my patched code a bit.

Btw, I've spotted something strange in the agcAvg()code: https://github.com/atuline/WLED/blob/575853db3af7ef4402b3f129c1a6012a23a7ed4e/wled00/audio_reactive.h#L203

Maybe this should be if (tmpAgc > 255) tmpAgc = 255;? At least it looks strange to me, that the AGC multiplier is reset to zero each time that it reaches 255.

atuline commented 2 years ago

That's most likely my fault, and I'll have to try and remember what I had in mind there. I hastily added the tmpAgc variable once I realized the multi tasking nature for use with segments and that I could not have interim values of sampleAgc.

Edit: Oh, and we typically work on dev and leave Master to @THATDONFC who merges dev and upstream WLED to make our Master.

softhack007 commented 2 years ago

Back to the question from @ArduinoNerdBheeshma - Another problem with analogue microphones, especially MAX4466, is they are really sensitive to Vcc voltage "noise" ripples. I was able to reduce the wifi-related noise with a capacitor. However also make sure not to power the LED strip directly from the ESP32 board (neither from 3.3V nor 5V). Each time that the strip lights up, it draws power and this will add loud noise to the microphone ADC readings.