From 31badb0e66bd8ec2b3ad374d9d75e7c67e1f87a4 Mon Sep 17 00:00:00 2001 From: Frank Date: Thu, 24 Aug 2023 22:50:50 +0200 Subject: [PATCH] 8266 onUpdateBegin, and minor cleanup * 8266 audioreactive: added minimal `onUpdateBegin()` * small cleanups --- usermods/audioreactive/audio_reactive.h | 38 +++++++++++++++++++++---- wled00/wled.h | 2 +- 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index f23170fd..bd14f638 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -37,7 +37,7 @@ #endif // high-resolution type for input filters -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) +#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && defined(ARDUINO_ARCH_ESP32) #define SR_HIRES_TYPE double // ESP32 and ESP32-S3 (with FPU) are fast enough to use "double" #else #define SR_HIRES_TYPE float // prefer faster type on slower boards (-S2, -C3) @@ -987,11 +987,11 @@ class AudioReactive : public Usermod { const uint16_t delayMs = 10; // I don't want to sample too often and overload WLED uint16_t audioSyncPort= 11988;// default port for UDP sound sync +#ifdef ARDUINO_ARCH_ESP32 // used for AGC int last_soundAgc = -1; // used to detect AGC mode change (for resetting AGC internal error buffers) double control_integrated = 0.0; // persistent across calls to agcAvg(); "integrator control" = accumulated error -#ifdef ARDUINO_ARCH_ESP32 // variables used by getSample() and agcAvg() int16_t micIn = 0; // Current sample starts with negative values and large values, which is why it's 16 bit signed double sampleMax = 0.0; // Max sample over a few seconds. Needed for AGC controler. @@ -1018,7 +1018,7 @@ class AudioReactive : public Usermod { static const char _name[]; static const char _enabled[]; static const char _inputLvl[]; -#if !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) +#if defined(ARDUINO_ARCH_ESP32) && !defined(CONFIG_IDF_TARGET_ESP32S2) && !defined(CONFIG_IDF_TARGET_ESP32C3) && !defined(CONFIG_IDF_TARGET_ESP32S3) static const char _analogmic[]; #endif static const char _digitalmic[]; @@ -1747,6 +1747,9 @@ class AudioReactive : public Usermod { delay(100); if (enabled) connectUDPSoundSync(); initDone = true; + DEBUGSR_PRINT(F("AR: init done, enabled = ")); + DEBUGSR_PRINTLN(enabled ? F("true.") : F("false.")); + USER_FLUSH(); } @@ -1996,7 +1999,7 @@ class AudioReactive : public Usermod { memset(fftAvg, 0, sizeof(fftAvg)); memset(fftResult, 0, sizeof(fftResult)); for(int i=(init?0:1); i