Skip to content

Commit 96ad7f2

Browse files
authored
Merge pull request wled#5514 from wled/ar-network-only
Fix incomplete support for Audio Source - Network only - 8266 Audio Reactive
2 parents a7db33d + acb883d commit 96ad7f2

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

‎platformio.ini‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -379,6 +379,7 @@ board = nodemcuv2
379379
board_build.ldscript = ${common.ldscript_4m1m}
380380
build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME=\"ESP8266\" #-DWLED_DISABLE_2D
381381
-D WLED_DISABLE_PARTICLESYSTEM2D
382+
custom_usermods = audioreactive
382383

383384
[env:nodemcuv2_compat]
384385
extends = env:nodemcuv2
@@ -388,6 +389,7 @@ platform_packages = ${esp8266.platform_packages_compat}
388389
build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEASE_NAME=\"ESP8266_compat\" #-DWLED_DISABLE_2D
389390
-D WLED_DISABLE_PARTICLESYSTEM2D
390391
;; lib_deps = ${esp8266.lib_deps_compat} ;; experimental - use older NeoPixelBus 2.7.9
392+
custom_usermods = audioreactive
391393

392394
[env:nodemcuv2_160]
393395
extends = env:nodemcuv2
@@ -403,6 +405,7 @@ board_build.ldscript = ${common.ldscript_2m512k}
403405
build_flags = ${common.build_flags} ${esp8266.build_flags} -D WLED_RELEASE_NAME=\"ESP02\"
404406
-D WLED_DISABLE_PARTICLESYSTEM2D
405407
-D WLED_DISABLE_PARTICLESYSTEM1D
408+
custom_usermods = audioreactive
406409

407410
[env:esp8266_2m_compat]
408411
extends = env:esp8266_2m
@@ -412,6 +415,7 @@ platform_packages = ${esp8266.platform_packages_compat}
412415
build_flags = ${common.build_flags} ${esp8266.build_flags_compat} -D WLED_RELEASE_NAME=\"ESP02_compat\" #-DWLED_DISABLE_2D
413416
-D WLED_DISABLE_PARTICLESYSTEM1D
414417
-D WLED_DISABLE_PARTICLESYSTEM2D
418+
custom_usermods = audioreactive
415419

416420
[env:esp8266_2m_160]
417421
extends = env:esp8266_2m

‎usermods/audioreactive/audio_reactive.cpp‎

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ static uint8_t binNum = 8; // Used to select the bin for FFT based bea
140140
#if defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3)
141141
#define UM_AUDIOREACTIVE_USE_INTEGER_FFT // always use integer FFT on ESP32-S2 and ESP32-C3
142142
#endif
143-
#endif
143+
#endif // UM_AUDIOREACTIVE_USE_ARDUINO_FFT
144144

145145
#if !defined(UM_AUDIOREACTIVE_USE_INTEGER_FFT)
146146
using FFTsampleType = float;
@@ -758,6 +758,8 @@ class AudioReactive : public Usermod {
758758
private:
759759
#ifdef ARDUINO_ARCH_ESP32
760760

761+
static constexpr uint8_t SR_DMTYPE_NETWORK_ONLY = 254;
762+
761763
#ifndef AUDIOPIN
762764
int8_t audioPin = -1;
763765
#else
@@ -1439,7 +1441,7 @@ class AudioReactive : public Usermod {
14391441
break;
14401442
#endif
14411443

1442-
case 254: // dummy "network receive only" mode
1444+
case SR_DMTYPE_NETWORK_ONLY: // dummy "network receive only" mode
14431445
if (audioSource) delete audioSource; audioSource = nullptr;
14441446
disableSoundProcessing = true;
14451447
audioSyncEnabled = 2; // force udp sound receive mode
@@ -1456,19 +1458,25 @@ class AudioReactive : public Usermod {
14561458
}
14571459
delay(250); // give microphone enough time to initialise
14581460

1459-
if (!audioSource && (dmType != 254)) enabled = false;// audio failed to initialise
1461+
if (!audioSource && (dmType != SR_DMTYPE_NETWORK_ONLY)) enabled = false;// audio failed to initialise
14601462
#endif
14611463
if (enabled) onUpdateBegin(false); // create FFT task, and initialize network
14621464

14631465

14641466
#ifdef ARDUINO_ARCH_ESP32
1465-
if (FFT_Task == nullptr) enabled = false; // FFT task creation failed
1467+
if (audioSource && FFT_Task == nullptr) enabled = false; // FFT task creation failed
14661468
if((!audioSource) || (!audioSource->isInitialized())) { // audio source failed to initialize. Still stay "enabled", as there might be input arriving via UDP Sound Sync
1467-
#ifdef WLED_DEBUG
1468-
DEBUG_PRINTLN(F("AR: Failed to initialize sound input driver. Please check input PIN settings."));
1469-
#else
1470-
DEBUGSR_PRINTLN(F("AR: Failed to initialize sound input driver. Please check input PIN settings."));
1471-
#endif
1469+
#ifdef WLED_DEBUG
1470+
#define AR_INIT_DEBUG_PRINT DEBUG_PRINTLN
1471+
#else
1472+
#define AR_INIT_DEBUG_PRINT DEBUGSR_PRINTLN
1473+
#endif
1474+
if (dmType == SR_DMTYPE_NETWORK_ONLY) {
1475+
AR_INIT_DEBUG_PRINT(F("AR: No sound input driver configured - network receive only."));
1476+
} else {
1477+
AR_INIT_DEBUG_PRINT(F("AR: Failed to initialize sound input driver. Please check input PIN settings."));
1478+
}
1479+
#undef AR_INIT_DEBUG_PRINT
14721480
disableSoundProcessing = true;
14731481
}
14741482
#endif
@@ -2123,6 +2131,9 @@ class AudioReactive : public Usermod {
21232131
uiScript.print(F("addOption(dd,'Generic PDM',5);"));
21242132
#endif
21252133
uiScript.print(F("addOption(dd,'ES8388',6);"));
2134+
uiScript.print(F("addOption(dd,'None - network receive only',"));
2135+
uiScript.print(SR_DMTYPE_NETWORK_ONLY);
2136+
uiScript.print(F(");"));
21262137

21272138
uiScript.print(F("dd=addDropdown(ux,'config:AGC');"));
21282139
uiScript.print(F("addOption(dd,'Off',0);"));

0 commit comments

Comments
 (0)