Aircoookie / WLED

Control WS2812B and many more types of digital RGB LEDs with an ESP8266 or ESP32 over WiFi!
https://kno.wled.ge
MIT License
14.27k stars 3.04k forks source link

Feature request: Audio input over UDP (from PC or Raspberry Pi) #3141

Open WouterGritter opened 1 year ago

WouterGritter commented 1 year ago

Is your feature request related to a problem? Please describe. I have various WLED esps/strips in my living room, and it would be very annoying to run an analog audio cable to every esp.

Describe the solution you'd like A UDP audio input stream function, just like the sync function.

Describe alternatives you've considered I have written a python script that uses the UDP sync function to update my strips at 50-100hz, based on an audio input on a raspberry pi (connected to my tv to sync with music/my sound bar). This works great and amazing, and is very instant, however this way I have to reimplement every effect that uses the audio input, and I cannot use these effects on WLED itself. Seeing that such a datastream gets handled perfectly (I'm using ESP8266's) I think that streaming the audio would also work great (maybe with some preprocessing on the "server" side with the audio input)

Additional context I would be willing to implement this feature myself, so some pointers on where to look, what to look out for and things to consider would be awesome. I'll also update this issue with a link to my python script if other people would like to try it out!

Since WLED currently works with an analog audio input on the esp8266, I'm wondering if you could also make this work with a separate esp8266 for the audio input and UDP streaming. Currently, my setup involves a raspberry pi running a python script.

softhack007 commented 1 year ago

Hi, Audio receiving over network is not planned yet, but let's see what the future may bring.

Actually you already have a few options today, depending on the kind of ESPs you use: 1) use UDP sound sync. This requires the audioreactive usermod on all devices, so its (currently) not an option for ESP8266. a) from an ESP32 with audioreactive usermod and I2S microphone, to other ESP32 devices with audioreactive usermod but no physical audio input. b) from an external computer to ESP32s with audioreactive usermod. See our docs about the UDP sound sync format. There is also a library contributed by a user that might help.

2) Use one ESP32 with audioreactive usermod, and control other devices (ESP32 or ESP8266) via DDP. Instead of sending audio, this directly sends the LED animations to all devices.

The downside of UDP sound sync - which is based on the multicast protocol - is that it depends on the capabilities of your Wifi router. Many "consumer grade" routers cannot support multicast reliably, or will even block the protocol after a few minutes. DDP might be more reliable, depending on your router.

The audioreactive usermod (and UDP sound sync) is currently only available for ESP32, but we are working on a reduced audioreactive for 8266, which would bring UDP sound receive to these tiny old chips.

DjordjeMandic commented 4 months ago

The downside of UDP sound sync - which is based on the multicast protocol - is that it depends on the capabilities of your Wifi router. Many "consumer grade" routers cannot support multicast reliably, or will even block the protocol after a few minutes. DDP might be more reliable, depending on your router.

I guess its fine then with ethernet?

softhack007 commented 4 months ago

I guess its fine then with ethernet?

I'm not sure. In case the router has problems with multicast, then connecting to the same router by ethernet will not solve the problem.