From aef16b519938675b2d0fc8f58a3da48e93df0228 Mon Sep 17 00:00:00 2001 From: Ewoud Date: Fri, 18 Nov 2022 16:57:07 +0100 Subject: [PATCH] platformio: add squelch, gain, profile defaults and mic / lineIn envs audio_reactive.h: - add SR_SQUELCH, SR_GAIN and SR_FREQ_PROF - Set AGC default to 1 - Rename DMTYPE to SR_DMTYPE platformio.ini: - _base entries: remove env: - wemos_shield_esp32_4MB_max_base - add wemos_shield_esp32_4MB_ICS4343x_max - add wemos_shield_esp32_4MB_SPM1423_max - add wemos_shield_esp32_4MB_LineIn_max - update esp32_pico_4MB_max --- platformio.ini | 114 +++++++++++++++--------- usermods/audioreactive/audio_reactive.h | 24 +++-- usermods/audioreactive/readme.md | 2 +- 3 files changed, 90 insertions(+), 50 deletions(-) diff --git a/platformio.ini b/platformio.ini index 05e0ef0d..6da450ed 100644 --- a/platformio.ini +++ b/platformio.ini @@ -41,7 +41,7 @@ ; MoonModules entries ; =================== -; default_envs = esp32_4MB_min, esp32_4MB_max, esp32_16MB_max, esp8266_4MB_min, esp32_4MB_PSRAM_max, esp32S3_8MB_max, wemos_shield_esp32_4MB_max, wemos_shield_esp32_16MB_max, esp32_pico_4MB_max +; default_envs = esp32_4MB_min, esp32_4MB_max, esp32_16MB_max, esp8266_4MB_min, esp32_4MB_PSRAM_max, esp32S3_8MB_max, wemos_shield_esp32_4MB_max, wemos_shield_esp32_4MB_ICS4343x_max, wemos_shield_esp32_4MB_SPM1423_max, wemos_shield_esp32_4MB_LineIn_max, wemos_shield_esp32_16MB_max, esp32_pico_4MB_max ; default_envs = esp32_4MB_min default_envs = esp32_4MB_max ; recommended default ; default_envs = esp32_16MB_max @@ -52,6 +52,9 @@ default_envs = esp32_4MB_max ; recommended default ; default_envs = esp32_4MB_PSRAM_max ; default_envs = esp32S3_8MB_max ; default_envs = wemos_shield_esp32_4MB_max +; default_envs = wemos_shield_esp32_4MB_ICS4343x_max +; default_envs = wemos_shield_esp32_4MB_SPM1423_max +; default_envs = wemos_shield_esp32_4MB_LineIn_max ; default_envs = wemos_shield_esp32_16MB_max ; default_envs = esp32_pico_4MB_max @@ -591,7 +594,7 @@ lib_deps_max = ; base entries (without WLED_RELEASE_NAME) ; esp32_4MB_min_base: basis for min entries and for max_base -[env:esp32_4MB_min_base] +[esp32_4MB_min_base] board = esp32dev platform = ${esp32.platform} upload_speed = 460800 ; or 921600 @@ -604,15 +607,15 @@ board_build.f_flash = 80000000L ; use full 80MHz speed for flash (default = 40Mh board_build.flash_mode = dio ; (dio = dual i/o; more compatible than qio = quad i/o) ;esp32_4MB_max_base: basis for max entries, uses esp32_4MB_min_base, build_flags_max and lib_deps_max -[env:esp32_4MB_max_base] -extends = env:esp32_4MB_min_base -build_flags = ${env:esp32_4MB_min_base.build_flags} ${common_mm.build_flags_max} -lib_deps = ${env:esp32_4MB_min_base.lib_deps} ${common_mm.lib_deps_max} -board_build.partitions = ${env:esp32_4MB_min_base.board_build.partitions} +[esp32_4MB_max_base] +extends = esp32_4MB_min_base +build_flags = ${esp32_4MB_min_base.build_flags} ${common_mm.build_flags_max} +lib_deps = ${esp32_4MB_min_base.lib_deps} ${common_mm.lib_deps_max} +board_build.partitions = ${esp32_4MB_min_base.board_build.partitions} ; board_build.partitions = tools/WLED_ESP32-wrover_4MB.csv ;esp32_4MB_V4_max_base: basis for V4 entries, uses build_flags_min, build_flags_max, lib_deps_min and lib_deps_max -[env:esp32_4MB_V4_min_base] +[esp32_4MB_V4_min_base] board = esp32dev upload_speed = 460800 ; or 921600 platform = ${esp32.platformV4} @@ -626,11 +629,11 @@ board_build.f_flash = 80000000L ; use full 80MHz speed for flash (default = 40Mh board_build.flash_mode = dio ; (dio = dual i/o; more compatible than qio = quad i/o) ;lib_ignore = IRremoteESP8266 ; use with WLED_DISABLE_INFRARED for faster compilation -[env:esp32_4MB_V4_max_base] -extends = env:esp32_4MB_V4_min_base -build_flags = ${env:esp32_4MB_V4_min_base.build_flags} ${common_mm.build_flags_max} -lib_deps = ${env:esp32_4MB_V4_min_base.lib_deps} ${common_mm.lib_deps_max} -board_build.partitions = ${env:esp32_4MB_V4_min_base.board_build.partitions} +[esp32_4MB_V4_max_base] +extends = esp32_4MB_V4_min_base +build_flags = ${esp32_4MB_V4_min_base.build_flags} ${common_mm.build_flags_max} +lib_deps = ${esp32_4MB_V4_min_base.lib_deps} ${common_mm.lib_deps_max} +board_build.partitions = ${esp32_4MB_V4_min_base.board_build.partitions} ;board_build.flash_mode = qio ; (dio = dual i/o; more compatible than qio = quad i/o) ; end of base entries @@ -639,8 +642,8 @@ board_build.partitions = ${env:esp32_4MB_V4_min_base.board_build.partitions} ; esp32_4MB_min: bin entry, uses esp32_4MB_min_base [env:esp32_4MB_min] -extends = env:esp32_4MB_min_base -build_flags = ${env:esp32_4MB_min_base.build_flags} +extends = esp32_4MB_min_base +build_flags = ${esp32_4MB_min_base.build_flags} -D WLED_RELEASE_NAME=esp32_4MB_min ; This will be included in the firmware.bin filename ; RAM: [== ] 24.1% (used 78900 bytes from 327680 bytes) ; Flash: [======== ] 83.7% (used 1315729 bytes from 1572864 bytes) @@ -656,8 +659,8 @@ build_flags = ${env:esp32_4MB_min_base.build_flags} ; esp32_4MB_max: bin entry, uses esp32_4MB_max_base [env:esp32_4MB_max] -extends = env:esp32_4MB_max_base -build_flags = ${env:esp32_4MB_max_base.build_flags} +extends = esp32_4MB_max_base +build_flags = ${esp32_4MB_max_base.build_flags} -D WLED_RELEASE_NAME=esp32_4MB_max ; This will be included in the firmware.bin filename ; RAM: [== ] 24.4% (used 79804 bytes from 327680 bytes) ; Flash: [========= ] 88.7% (used 1394813 bytes from 1572864 bytes) @@ -667,10 +670,10 @@ build_flags = ${env:esp32_4MB_max_base.build_flags} ; esp32_16MB_max: bin entry, uses esp32_4MB_max_base and adds 16MB settings [env:esp32_16MB_max] -extends = env:esp32_4MB_max_base +extends = esp32_4MB_max_base board = esp32_twilord ; "TwilightLord" ESP32 with 16MB Flash board_build.partitions = tools/WLED_ESP32_16MB.csv ; for esp32_twilord with 16MB flash -build_flags = ${env:esp32_4MB_max_base.build_flags} +build_flags = ${esp32_4MB_max_base.build_flags} -D WLED_RELEASE_NAME=esp32_16MB_max ; This will be included in the firmware.bin filename ; RAM: [== ] 24.4% (used 79804 bytes from 327680 bytes) ; Flash: [======= ] 66.5% (used 1394813 bytes from 2097152 bytes) @@ -696,6 +699,7 @@ build_flags = ${common.build_flags_esp8266} -D WLED_DISABLE_HUESYNC ; -D WLED_DISABLE_2D ; -D USERMOD_AUDIOREACTIVE + ; -D USERMOD_CUSTOMEFFECTS ; to be done -UWLED_USE_MY_CONFIG ; monitor_filters = esp8266_exception_decoder ; RAM: [====== ] 58.7% (used 48056 bytes from 81920 bytes) @@ -709,8 +713,8 @@ build_flags = ${common.build_flags_esp8266} ; esp32_4MB_V4_min: bin entry compiled with ESP-IDF 4.4.1, uses esp32_4MB_V4_min_base [env:esp32_4MB_V4_min] -extends = env:esp32_4MB_V4_min_base -build_flags = ${env:esp32_4MB_V4_min_base.build_flags} +extends = esp32_4MB_V4_min_base +build_flags = ${esp32_4MB_V4_min_base.build_flags} -D WLED_RELEASE_NAME=esp32_4MB_V4_min ; This will be included in the firmware.bin filename -D WLED_WATCHDOG_TIMEOUT=0 #-D WLED_DISABLE_BROWNOUT_DET -D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup @@ -728,8 +732,8 @@ build_flags = ${env:esp32_4MB_V4_min_base.build_flags} ; esp32_4MB_V4_max: bin entry compiled with ESP-IDF 4.4.1, uses esp32_4MB_V4_max_base [env:esp32_4MB_V4_max] -extends = env:esp32_4MB_V4_max_base -build_flags = ${env:esp32_4MB_V4_max_base.build_flags} +extends = esp32_4MB_V4_max_base +build_flags = ${esp32_4MB_V4_max_base.build_flags} -D WLED_RELEASE_NAME=esp32_4MB_V4_max ; This will be included in the firmware.bin filename -D WLED_WATCHDOG_TIMEOUT=0 #-D WLED_DISABLE_BROWNOUT_DET -D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup @@ -746,10 +750,10 @@ build_flags = ${env:esp32_4MB_V4_max_base.build_flags} ; esp32_16MB_max: bin entry compiled with ESP-IDF 4.4.1, uses esp32_4MB_V4_max_base and adds 16MB settings [env:esp32_16MB_V4_max] -extends = env:esp32_4MB_V4_max_base +extends = esp32_4MB_V4_max_base board = esp32_twilord ; "TwilightLord" ESP32 with 16MB Flash board_build.partitions = tools/WLED_ESP32_16MB.csv ; for esp32_twilord with 16MB flash -build_flags = ${env:esp32_4MB_V4_max_base.build_flags} +build_flags = ${esp32_4MB_V4_max_base.build_flags} -D WLED_RELEASE_NAME=esp32_16MB_V4_max ; This will be included in the firmware.bin filename -D WLED_WATCHDOG_TIMEOUT=0 #-D WLED_DISABLE_BROWNOUT_DET -D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup @@ -759,10 +763,10 @@ build_flags = ${env:esp32_4MB_V4_max_base.build_flags} ;; experiemtal environment for boards with PSRAM (needs ESP-IDF 4.4.1). ; esp32_4MB_PSRAM_max: bin entry, uses esp32_4MB_V4_max_base and adds specific settings [env:esp32_4MB_PSRAM_max] -extends = env:esp32_4MB_V4_max_base +extends = esp32_4MB_V4_max_base board = lolin_d32_pro ;board = esp32cam -build_flags = ${env:esp32_4MB_V4_max_base.build_flags} +build_flags = ${esp32_4MB_V4_max_base.build_flags} -D WLED_RELEASE_NAME=esp32_4MB_PSRAM_max -D WLED_WATCHDOG_TIMEOUT=0 #-D WLED_DISABLE_BROWNOUT_DET -D ARDUINO_USB_CDC_ON_BOOT=0 ; needed for arduino-esp32 >=2.0.4; avoids errors on startup @@ -784,9 +788,9 @@ build_flags = ${env:esp32_4MB_V4_max_base.build_flags} ; esp32S3_8MB_max: bin entry, uses esp32_4MB_V4_max_base and adds specific settings. Override of lib_deps using lib_deps_min and lib_deps_max [env:esp32S3_8MB_max] -extends = env:esp32_4MB_V4_max_base +extends = esp32_4MB_V4_max_base board = esp32-s3-devkitc-1 -build_flags = ${env:esp32_4MB_V4_max_base.build_flags} +build_flags = ${esp32_4MB_V4_max_base.build_flags} -D WLED_RELEASE_NAME=esp32S3_8MB_max -D ARDUINO_USB_MODE=1 -D ARDUINO_USB_CDC_ON_BOOT=0 -D ARDUINO_USB_MSC_ON_BOOT=0 -D ARDUINO_USB_DFU_ON_BOOT=0 -D WLED_WATCHDOG_TIMEOUT=0 @@ -802,7 +806,7 @@ build_flags = ${env:esp32_4MB_V4_max_base.build_flags} -D HW_PIN_SDA=40 -D HW_PIN_SCL=41 -D AUDIOPIN=-1 - -D DMTYPE=1 + -D SR_DMTYPE=1 -D I2S_SDPIN=16 -D I2S_CKPIN=17 -D I2S_WSPIN=47 @@ -822,17 +826,14 @@ board_build.flash_mode = qio # ------------------------------------------------------------------------------ ;wemos_shield_esp32_4MB_max_base: base entry, uses esp32_4MB_max_base -[env:wemos_shield_esp32_4MB_max_base] -extends = env:esp32_4MB_max_base -build_flags = ${env:esp32_4MB_max_base.build_flags} +[wemos_shield_esp32_4MB_max_base] +extends = esp32_4MB_max_base +build_flags = ${esp32_4MB_max_base.build_flags} -D LEDPIN=16 -D RLYPIN=19 -D BTNPIN=17 -D IRPIN=18 -D AUDIOPIN=-1 - -D DMTYPE=1 -D I2S_SDPIN=32 -D I2S_WSPIN=15 -D I2S_CKPIN=14 ;; for regular I2S microphone - ; -D DMTYPE=5 -D I2S_SDPIN=32 -D I2S_WSPIN=15 -D I2S_CKPIN=-1 ;; for I2S PDM microphone - ; -D DMTYPE=4 -D MCLK_PIN=0 -D I2S_SDPIN=25 -D I2S_WSPIN=15 -D I2S_CKPIN=14 ;; for audio Line-In shield -D TEMPERATURE_PIN=23 -D FLD_PIN_SCL=22 -D FLD_PIN_SDA=21 -D HW_PIN_SCL=22 -D HW_PIN_SDA=21 @@ -847,27 +848,53 @@ build_flags = ${env:esp32_4MB_max_base.build_flags} ;wemos_shield_esp32_4MB_max: bin entry, uses wemos_shield_esp32_4MB_max_base [env:wemos_shield_esp32_4MB_max] -extends = env:wemos_shield_esp32_4MB_max_base -build_flags = ${env:wemos_shield_esp32_4MB_max_base.build_flags} +extends = wemos_shield_esp32_4MB_max_base +build_flags = ${wemos_shield_esp32_4MB_max_base.build_flags} -D WLED_RELEASE_NAME=wemos_shield_esp32_4MB_max ; This will be included in the firmware.bin filename + ; -D SR_DMTYPE=1 -D I2S_SDPIN=32 -D I2S_WSPIN=15 -D I2S_CKPIN=14 ;; for regular I2S microphone softhack: can be removed because this is default in code ; RAM: [== ] 24.4% (used 79820 bytes from 327680 bytes) ; Flash: [========= ] 88.6% (used 1393421 bytes from 1572864 bytes) +[env:wemos_shield_esp32_4MB_ICS4343x_max] +extends = wemos_shield_esp32_4MB_max_base +build_flags = ${wemos_shield_esp32_4MB_max_base.build_flags} + -D WLED_RELEASE_NAME=wemos_shield_esp32_4MB_ICS4343x_max ; This will be included in the firmware.bin filename + ; -D SR_DMTYPE=1 -D I2S_SDPIN=32 -D I2S_WSPIN=15 -D I2S_CKPIN=14 ;; for regular I2S microphone softhack: can be removed because this is default in code + -D SR_SQUELCH=10 -D SR_GAIN=30 -D SR_FREQ_PROF=5 ; ICS-43434 specific +; RAM: [== ] 24.4% (used 79820 bytes from 327680 bytes) +; Flash: [========= ] 88.6% (used 1393421 bytes from 1572864 bytes) + +[env:wemos_shield_esp32_4MB_SPM1423_max] +extends = wemos_shield_esp32_4MB_max_base +build_flags = ${wemos_shield_esp32_4MB_max_base.build_flags} + -D WLED_RELEASE_NAME=wemos_shield_esp32_4MB_SPM1423_max ; This will be included in the firmware.bin filename + -D SR_DMTYPE=5 -D I2S_SDPIN=32 -D I2S_WSPIN=15 -D I2S_CKPIN=-1 ; for I2S PDM microphone + -D SR_SQUELCH=3 -D SR_GAIN=40 -D SR_FREQ_PROF=5 ; ICS-43434 SPM1423 specific +; RAM: [== ] 24.4% (used 79820 bytes from 327680 bytes) +; Flash: [========= ] 88.6% (used 1393421 bytes from 1572864 bytes) + +[env:wemos_shield_esp32_4MB_LineIn_max] +extends = wemos_shield_esp32_4MB_max_base +build_flags = ${wemos_shield_esp32_4MB_max_base.build_flags} + -D WLED_RELEASE_NAME=wemos_shield_esp32_4MB_LineIn_max ; This will be included in the firmware.bin filename + -D SR_DMTYPE=4 -D MCLK_PIN=0 -D I2S_SDPIN=25 -D I2S_WSPIN=15 -D I2S_CKPIN=14 ; for audio Line-In shield + -D SR_SQUELCH=8 -D SR_GAIN=20 -D SR_FREQ_PROF=1 ; ICS-43434 SPM1423 specific + ;wemos_shield_esp32_16MB_max: bin entry, uses wemos_shield_esp32_4MB_max_base and adds 16MB settings [env:wemos_shield_esp32_16MB_max] -extends = env:wemos_shield_esp32_4MB_max_base +extends = wemos_shield_esp32_4MB_max_base board = esp32_twilord ; "TwilightLord" ESP32 with 16MB Flash board_build.partitions = tools/WLED_ESP32_16MB.csv ; for esp32_twilord with 16MB flash -build_flags = ${env:wemos_shield_esp32_4MB_max_base.build_flags} +build_flags = ${wemos_shield_esp32_4MB_max_base.build_flags} -D WLED_RELEASE_NAME=wemos_shield_esp32_16MB_max ; This will be included in the firmware.bin filename ; RAM: [== ] 24.4% (used 79820 bytes from 327680 bytes) ; Flash: [======= ] 66.4% (used 1393421 bytes from 2097152 bytes) ; ESP32 WLED pico board with builtin ICS-43432 microphpone [env:esp32_pico_4MB_max] -extends = env:esp32_4MB_max_base +extends = esp32_4MB_max_base board = pico32 -build_flags = ${env:esp32_4MB_max_base.build_flags} +build_flags = ${esp32_4MB_max_base.build_flags} -D WLED_RELEASE_NAME=esp32_pico_4MB_max ; This will be included in the firmware.bin filename -D WLED_DISABLE_BROWNOUT_DET -D SERVERNAME='"WLED-pico32"' @@ -879,7 +906,8 @@ build_flags = ${env:esp32_4MB_max_base.build_flags} -D BTNPIN=-1 -D IRPIN=-1 -D HW_PIN_SCL=22 -D HW_PIN_SDA=21 - -D DMTYPE=1 -D I2S_SDPIN=25 -D I2S_WSPIN=15 -D I2S_CKPIN=14 + -D SR_DMTYPE=1 -D I2S_SDPIN=25 -D I2S_WSPIN=15 -D I2S_CKPIN=14 + -D SR_SQUELCH=5 -D SR_GAIN=30 -D SR_FREQ_PROF=5 ; ICS-43434 specific ; -D MCLK_PIN=0 ; -D WLED_USE_MY_CONFIG ; -D WLED_DISABLE_LOXONE diff --git a/usermods/audioreactive/audio_reactive.h b/usermods/audioreactive/audio_reactive.h index 38636175..7918cd9d 100644 --- a/usermods/audioreactive/audio_reactive.h +++ b/usermods/audioreactive/audio_reactive.h @@ -56,9 +56,17 @@ constexpr SRate_t SAMPLE_RATE = 22050; // Base sample rate in Hz - 22Kh // globals static uint8_t inputLevel = 128; // UI slider value -static uint8_t soundSquelch = 10; // squelch value for volume reactive routines (config value) -static uint8_t sampleGain = 60; // sample gain (config value) -static uint8_t soundAgc = 0; // Automagic gain control: 0 - none, 1 - normal, 2 - vivid, 3 - lazy (config value) +#ifndef SR_SQUELCH + uint8_t soundSquelch = 10; // squelch value for volume reactive routines (config value) +#else + uint8_t soundSquelch = SR_SQUELCH; // squelch value for volume reactive routines (config value) +#endif +#ifndef SR_GAIN + uint8_t sampleGain = 60; // sample gain (config value) +#else + uint8_t sampleGain = SR_GAIN; // sample gain (config value) +#endif +static uint8_t soundAgc = 1; // Automagic gain control: 0 - none, 1 - normal, 2 - vivid, 3 - lazy (config value) static uint8_t audioSyncEnabled = 0; // bit field: bit 0 - send, bit 1 - receive (config value) static bool udpSyncConnected = false; // UDP connection status -> true if connected to multicast group @@ -68,7 +76,11 @@ static uint16_t attackTime = 50; // int: attack time in millisecond static uint16_t decayTime = 300; // int: decay time in milliseconds. New default 300ms. Old default was 1.40sec // user settable options for FFTResult scaling static uint8_t FFTScalingMode = 3; // 0 none; 1 optimized logarithmic; 2 optimized linear; 3 optimized sqare root -static uint8_t pinkIndex = 0; // 0: default; 1: line-in; 2: IMNP441 +#ifndef SR_FREQ_PROF + static uint8_t pinkIndex = 0; // 0: default; 1: line-in; 2: IMNP441 +#else + static uint8_t pinkIndex = SR_FREQ_PROF; // 0: default; 1: line-in; 2: IMNP441 +#endif // // AGC presets @@ -598,10 +610,10 @@ class AudioReactive : public Usermod { #else int8_t audioPin = AUDIOPIN; #endif - #ifndef DMTYPE // I2S mic type + #ifndef SR_DMTYPE // I2S mic type uint8_t dmType = 1; // 0=none/disabled/analog; 1=generic I2S #else - uint8_t dmType = DMTYPE; + uint8_t dmType = SR_DMTYPE; #endif #ifndef I2S_SDPIN // aka DOUT int8_t i2ssdPin = 32; diff --git a/usermods/audioreactive/readme.md b/usermods/audioreactive/readme.md index f14c168d..59e8e37d 100644 --- a/usermods/audioreactive/readme.md +++ b/usermods/audioreactive/readme.md @@ -20,7 +20,7 @@ All parameters are runtime configurable though some may require hard boot after If you want to define default GPIOs during compile time use the following (default values in parentheses): -- `DMTYPE=x` : defines digital microphone type: 0=analog, 1=generic I2S, 2=ES7243 I2S, 3=SPH0645 I2S, 4=generic I2S with master clock, 5=PDM I2S +- `SR_DMTYPE=x` : defines digital microphone type: 0=analog, 1=generic I2S, 2=ES7243 I2S, 3=SPH0645 I2S, 4=generic I2S with master clock, 5=PDM I2S - `AUDIOPIN=x` : GPIO for analog microphone/AUX-in (36) - `I2S_SDPIN=x` : GPIO for SD pin on digital mcrophone (32) - `I2S_WSPIN=x` : GPIO for WS pin on digital mcrophone (15)