blazoncek / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
MIT License
31 stars 0 forks source link

audioreactive for 8266 devices #37

Closed softhack007 closed 6 days ago

softhack007 commented 2 years ago

This is mainly a discussion tracker/reminder, to collect ideas from ongoing chat in a central place. The overall objective is to create a (maybe simplified) version of audioreactive that would run on ESP8266.

Some aspects (incomplete)

1) We have an old version of SR WLED for 8266, however that one will not work with the new code design of WLED. See https://github.com/atuline/WLED/tree/ESP8266. Sound input is either I2S (fixed pins that are not availeable on every board), or analog ADC using pin A0. Support volume reactive effects only; no 2D or frequency effects.

2) A minimal solution could be to only have UDP sound sync, so the 8266 acts as a "slave" that needs another ESP32 to run sound analysis and FFT. Drawback: UDP multicast is not very reliable with typical "consumer grade" wifi equipment.

3) another option would be to strip down the current usermod, leaving out the FFT part. As a starting point, I've committed a simple code for reading sound input - see https://github.com/blazoncek/WLED/commit/86e8ee334f464e54db7c7c1216feb76bdd7ec774

4) with some tweaking, we might be able to create a simplified (less accurate) FFT analysis for 8266. I'd expect that the FFT code will run slower by a factor of 8 or more, because 8266 does not have float support in hardware. However that would only work if we can also use I2S for reading sound input at a reasonable sampling rate. Might need some deeper thinking.

5) analogRead() on 8266 is very slow, and can deliver a fresh sample approx each 5 millis only. So not an option for FFT input.

6) peak detection (aka onset/beat detection) will not be possible without FFT. Update: simple detection of a "fat beats" (every few seconds) might still be possible (see https://github.com/atuline/WLED/commit/4fc76138fbee787dabb2eb817a910f34fe303a97), but nothing like what the ESP32 version (with FFT) can achieve.

From my perspective, there is no schedule for this yet, also we don't have consensus if it would make any sense (technically).

What do you think?

blazoncek commented 2 years ago

My recommendation would be to add simple volume detection and nothing more. This does not need to be included in current audioreactive usermod but can be completely separate ESP8266 only usermod. It does not need to be perfect as the basic idea is just to have something that will react to sound.

dosipod commented 2 years ago

Simple volume detection for 8266 is enough .Having the ability to use audio sync is also one of the best features available and could be a good idea to keep it

softhack007 commented 2 years ago

Two questions from my side:

blazoncek commented 2 years ago

I am primarily interested in the simplest solution of using analog microphone on A0. Since that is most often available in some commercial products and also easy to put together as DIY (wearable LED outfit or portable party light).

As far as UDP sync goes I see limited use as UDP is unreliable and can be (partially) replaced by DDP virtual leds. It is not useless though.

dosipod commented 2 years ago

When testing on esp32s ,we have also started to notice UDP unreliability with some setups ( specially using MQTT ) . Setups with DDP is a lot more stable but might not be useful in case of a requirement for customized external control such as Home Assistant and individual led control . It is also interesting that when testing with apps like LedFX and Jinx we did not face any issues with UDP . So might be some of the UDP concerns are not fully related to WLED but to the way apps are set to interact with it.