From cb049fb58d5f495809c58c90f3aa5b108fe3465b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20M=C3=B6hle?= <91616163+softhack007@users.noreply.github.com> Date: Mon, 11 May 2026 17:29:58 +0200 Subject: [PATCH 1/4] AR bugfix: auto-suspend local audio in all realtime modes * Modernize auto-suspend condition - DDP, DMX and TPM2NET were missing (thanks @blazoncek for the hint) --- usermods/audioreactive/audio_reactive.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/usermods/audioreactive/audio_reactive.cpp b/usermods/audioreactive/audio_reactive.cpp index 5ffc7968aa..55d88cc39b 100644 --- a/usermods/audioreactive/audio_reactive.cpp +++ b/usermods/audioreactive/audio_reactive.cpp @@ -1533,14 +1533,9 @@ class AudioReactive : public Usermod { // We cannot wait indefinitely before processing audio data if (strip.isUpdating() && (millis() - lastUMRun < 2)) return; // be nice, but not too nice - // suspend local sound processing when "real time mode" is active (E131, UDP, ADALIGHT, ARTNET) - if ( (realtimeOverride == REALTIME_OVERRIDE_NONE) // please add other overrides here if needed - &&( (realtimeMode == REALTIME_MODE_GENERIC) - ||(realtimeMode == REALTIME_MODE_E131) - ||(realtimeMode == REALTIME_MODE_UDP) - ||(realtimeMode == REALTIME_MODE_ADALIGHT) - ||(realtimeMode == REALTIME_MODE_ARTNET) ) ) // please add other modes here if needed - { + // suspend local sound processing when "real time mode" is active (E131, UDP, ADALIGHT, ARTNET, DDP, DMX) + // exception: sound input is still needed when useMainSegmentOnly - other segments are still running with local input. + if (realtimeMode && !realtimeOverride && !useMainSegmentOnly) { #if defined(ARDUINO_ARCH_ESP32) && defined(WLED_DEBUG) if ((disableSoundProcessing == false) && (audioSyncEnabled == 0)) { // we just switched to "disabled" DEBUG_PRINTLN(F("[AR userLoop] realtime mode active - audio processing suspended.")); From 98e0bc64893ef5e636472a57c2ac8f101a2710df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20M=C3=B6hle?= <91616163+softhack007@users.noreply.github.com> Date: Mon, 11 May 2026 17:36:40 +0200 Subject: [PATCH 2/4] AR: minor update for better compatibility with arduino-esp32 V3.x WiFiUDP.flush() -> WiFiUDP.clear() --- usermods/audioreactive/audio_reactive.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/usermods/audioreactive/audio_reactive.cpp b/usermods/audioreactive/audio_reactive.cpp index 55d88cc39b..8bdc40714b 100644 --- a/usermods/audioreactive/audio_reactive.cpp +++ b/usermods/audioreactive/audio_reactive.cpp @@ -1300,7 +1300,12 @@ class AudioReactive : public Usermod { size_t packetSize = fftUdp.parsePacket(); #ifdef ARDUINO_ARCH_ESP32 - if ((packetSize > 0) && ((packetSize < 5) || (packetSize > UDPSOUND_MAX_PACKET))) fftUdp.flush(); // discard invalid packets (too small or too big) - only works on esp32 + if ((packetSize > 0) && ((packetSize < 5) || (packetSize > UDPSOUND_MAX_PACKET))) + #if ESP_IDF_VERSION_MAJOR < 5 + fftUdp.flush(); // discard invalid packets (too small or too big) - only works on esp32 + #else + fftUdp.clear(); // function was renamed in newer frameworks + #endif #endif if ((packetSize > 5) && (packetSize <= UDPSOUND_MAX_PACKET)) { //DEBUGSR_PRINTLN("Received UDP Sync Packet"); @@ -1612,7 +1617,11 @@ class AudioReactive : public Usermod { have_new_sample = receiveAudioData(); if (have_new_sample) last_UDPTime = millis(); #ifdef ARDUINO_ARCH_ESP32 + #if ESP_IDF_VERSION_MAJOR < 5 else fftUdp.flush(); // Flush udp input buffers if we haven't read it - avoids hickups in receive mode. Does not work on 8266. + #else + else fftUdp.clear(); // function was remaned in newer framework versions + #endif #endif lastTime = millis(); } From e59ecafd06495160f0810c70e697f997e3131336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20M=C3=B6hle?= <91616163+softhack007@users.noreply.github.com> Date: Mon, 11 May 2026 17:42:44 +0200 Subject: [PATCH 3/4] Fix typo in comment for fftUdp.clear() function --- usermods/audioreactive/audio_reactive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usermods/audioreactive/audio_reactive.cpp b/usermods/audioreactive/audio_reactive.cpp index 8bdc40714b..594b73830f 100644 --- a/usermods/audioreactive/audio_reactive.cpp +++ b/usermods/audioreactive/audio_reactive.cpp @@ -1620,7 +1620,7 @@ class AudioReactive : public Usermod { #if ESP_IDF_VERSION_MAJOR < 5 else fftUdp.flush(); // Flush udp input buffers if we haven't read it - avoids hickups in receive mode. Does not work on 8266. #else - else fftUdp.clear(); // function was remaned in newer framework versions + else fftUdp.clear(); // function was renamed in newer frameworks #endif #endif lastTime = millis(); From 4c78949a21114f4d7d2dd8cb39f5fdfa5f20444a Mon Sep 17 00:00:00 2001 From: Frank <91616163+softhack007@users.noreply.github.com> Date: Fri, 15 May 2026 20:06:31 +0200 Subject: [PATCH 4/4] minor clarification explain rationale behind one line that differs from 8266 code. The initial "unlock" ensures that FFT_Task can initialize even when in sound receive mode -> might cause some RAM allocation even when not strictly needed, but also ensures a clean start-up of audio processing. --- usermods/audioreactive/audio_reactive.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/usermods/audioreactive/audio_reactive.cpp b/usermods/audioreactive/audio_reactive.cpp index 594b73830f..a5ff961d59 100644 --- a/usermods/audioreactive/audio_reactive.cpp +++ b/usermods/audioreactive/audio_reactive.cpp @@ -1726,7 +1726,7 @@ class AudioReactive : public Usermod { ); } micDataReal = 0.0f; // just to be sure - if (enabled) disableSoundProcessing = false; + if (enabled) disableSoundProcessing = false; // allows FFT_Task to run at least once, even when loop() might disable again updateIsRunning = init; }