WLED/usermods/audioreactive
Frank 4245767357
fix for partly uninitialized sound sync packets (audioreactive)
audioSyncPacket contains four "invisible" padding bytes added by the compiler. These need to be initialized to zero, as future versions of the protocol will make use of these fields.
2023-10-08 19:54:14 +02:00
..
audio_reactive.h fix for partly uninitialized sound sync packets (audioreactive) 2023-10-08 19:54:14 +02:00
audio_source.h fix wrong signature of SPH0654::initialize() 2023-09-19 15:27:41 +02:00
readme.md Spelling check by @wthomson (#2940) 2022-12-10 16:12:55 +01:00

Audioreactive usermod

Enabless controlling LEDs via audio input. Audio source can be a microphone or analog-in (AUX) using an appropriate adapter. Supported microphones range from analog (MAX4466, MAX9814, ...) to digital (INMP441, ICS-43434, ...).

Does audio processing and provides data structure that specially written effects can use.

does not provide effects or draw anything to an LED strip/matrix.

Additional Documentation

This usermod is an evolution of SR-WLED, and a lot of documentation and information can be found in the SR-WLED wiki:

Supported MCUs

This audioreactive usermod works best on "classic ESP32" (dual core), and on ESP32-S3 which also has dual core and hardware floating point support.

It will compile succesfully for ESP32-S2 and ESP32-C3, however might not work well, as other WLED functions will become slow. Audio processing requires a lot of computing power, which can be problematic on smaller MCUs like -S2 and -C3.

Analog audio is only possible on "classic" ESP32, but not on other MCUs like ESP32-S3.

Currently ESP8266 is not supported, due to low speed and small RAM of this chip. There are however plans to create a lightweight audioreactive for the 8266, with reduced features.

Installation

using customised arduinoFFT library for use with this usermod

Add -D USERMOD_AUDIOREACTIVE to your PlatformIO environment build_flags, as well as https://github.com/blazoncek/arduinoFFT.git to your lib_deps. If you are not using PlatformIO (which you should) try adding #define USERMOD_AUDIOREACTIVE to my_config.h and make sure you have arduinoFFT library downloaded and installed.

Customised arduinoFFT library for use with this usermod can be found at https://github.com/blazoncek/arduinoFFT.git

using latest (develop) arduinoFFT library

Alternatively, you can use the latest arduinoFFT development version. ArduinoFFT develop library is slightly more accurate, and slighly faster than our customised library, however also needs additional 2kB RAM.

  • build_flags = -D USERMOD_AUDIOREACTIVE -D UM_AUDIOREACTIVE_USE_NEW_FFT
  • lib_deps= https://github.com/kosme/arduinoFFT#develop @ 1.9.2

Configuration

All parameters are runtime configurable. Some may require a hard reset after changing them (I2S microphone or selected GPIOs).

If you want to define default GPIOs during compile time, use the following (default values in parentheses):

  • -D SR_DMTYPE=x : defines digital microphone type: 0=analog, 1=generic I2S (default), 2=ES7243 I2S, 3=SPH0645 I2S, 4=generic I2S with master clock, 5=PDM I2S
  • -D AUDIOPIN=x : GPIO for analog microphone/AUX-in (36)
  • -D I2S_SDPIN=x : GPIO for SD pin on digital microphone (32)
  • -D I2S_WSPIN=x : GPIO for WS pin on digital microphone (15)
  • -D I2S_CKPIN=x : GPIO for SCK pin on digital microphone (14)
  • -D MCLK_PIN=x : GPIO for master clock pin on digital Line-In boards (-1)
  • -D ES7243_SDAPIN : GPIO for I2C SDA pin on ES7243 microphone (-1)
  • -D ES7243_SCLPIN : GPIO for I2C SCL pin on ES7243 microphone (-1)

NOTE I2S is used for analog audio sampling. Hence, the analog buttons (i.e. potentiometers) are disabled when running this usermod with an analog microphone.

Advanced Compile-Time Options

You can use the following additional flags in your build_flags

  • -D SR_SQUELCH=x : Default "squelch" setting (10)
  • -D SR_GAIN=x : Default "gain" setting (60)
  • -D I2S_USE_RIGHT_CHANNEL: Use RIGHT instead of LEFT channel (not recommended unless you strictly need this).
  • -D I2S_USE_16BIT_SAMPLES: Use 16bit instead of 32bit for internal sample buffers. Reduces sampling quality, but frees some RAM ressources (not recommended unless you absolutely need this).
  • -D I2S_GRAB_ADC1_COMPLETELY: Experimental: continously sample analog ADC microphone. Only effective on ESP32. WARNING this will cause conflicts(lock-up) with any analogRead() call.
  • -D MIC_LOGGER : (debugging) Logs samples from the microphone to serial USB. Use with serial plotter (Arduino IDE)
  • -D SR_DEBUG : (debugging) Additional error diagnostics and debug info on serial USB.

Release notes