-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Audioreactive bugfix: auto-suspend in all realtime modes, but stay active when "Use main segment only" #5599
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+14
−10
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
cb049fb
AR bugfix: auto-suspend local audio in all realtime modes
softhack007 98e0bc6
AR: minor update for better compatibility with arduino-esp32 V3.x
softhack007 e59ecaf
Fix typo in comment for fftUdp.clear() function
softhack007 4c78949
minor clarification
softhack007 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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"); | ||
|
|
@@ -1533,14 +1538,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.")); | ||
|
|
@@ -1617,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 renamed in newer frameworks | ||
| #endif | ||
| #endif | ||
| lastTime = millis(); | ||
| } | ||
|
|
@@ -1722,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 | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. PS: this is safe even with "init == true" => |
||
| updateIsRunning = init; | ||
| } | ||
|
|
||
|
|
||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.