forked from theelims/ESP32-sveltekit
-
-
Notifications
You must be signed in to change notification settings - Fork 15
FastLED audio #130
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
Merged
FastLED audio #130
Changes from 1 commit
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
1497e93
Add FastLED audio
ewowi d68030f
FastLED audio tweaks
ewowi abca48e
FastLED Audio: use IO Pins, add controls
ewowi 8046fe9
add percussionType, tune readPins
ewowi 8c3a7d8
Reorganise code, use start/stopService, updatePin() check for removed
ewowi da93d5d
Fix Firmware update - exclude webflash + updatePin move
ewowi 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
Some comments aren't visible on the classic Files Changed page.
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
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
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
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
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 |
|---|---|---|
| @@ -0,0 +1,97 @@ | ||
| /** | ||
| @title MoonLight | ||
| @file D_FastLEDAudio.h | ||
| @repo https://github.com/MoonModules/MoonLight, submit changes to this file as PRs | ||
| @Authors https://github.com/MoonModules/MoonLight/commits/main | ||
| @Doc https://moonmodules.org/MoonLight/moonlight/overview/ | ||
| @Copyright © 2026 Github MoonLight Commit Authors | ||
| @license GNU GENERAL PUBLIC LICENSE Version 3, 29 June 2007 | ||
| @license For non GPL-v3 usage, commercial licenses must be purchased. Contact us for more information. | ||
| **/ | ||
|
|
||
| #pragma once | ||
|
|
||
| #if FT_MOONLIGHT | ||
|
|
||
| #include "fl/audio.h" | ||
| #include "fl/audio/audio_processor.h" | ||
| #include "fl/audio_input.h" | ||
| #include "fl/time_alpha.h" | ||
|
|
||
| #define I2S_CLK_PIN 6 // Serial Clock (SCK) (BLUE) | ||
| #define I2S_WS_PIN 4 // Word Select (WS) (GREEN) | ||
| #define I2S_SD_PIN 5 // Serial Data (SD) (YELLOW) | ||
| #define I2S_CHANNEL fl::Left | ||
|
|
||
| static fl::AudioConfigI2S i2sConfig(I2S_WS_PIN, I2S_SD_PIN, I2S_CLK_PIN, 0, I2S_CHANNEL, 44100, 16, fl::Philips); | ||
| static fl::AudioConfig config(i2sConfig); | ||
| static fl::shared_ptr<fl::IAudioInput> audioInput; | ||
|
|
||
| class FastLEDAudioDriver : public Node { | ||
| public: | ||
| static const char* name() { return "FastLED Audio"; } | ||
| static uint8_t dim() { return _NoD; } | ||
| static const char* tags() { return "☸️"; } | ||
|
|
||
| fl::AudioProcessor audioProcessor; | ||
|
|
||
| // Beat detection state | ||
| float currentBPM = 0.0f; | ||
| uint32_t lastBeatTime = 0; | ||
| uint32_t beatCount = 0; | ||
| uint32_t onsetCount = 0; | ||
|
|
||
| void setup() override { | ||
| Node::setup(); // !! | ||
|
|
||
| fl::string errorMsg; | ||
| audioInput = fl::IAudioInput::create(config, &errorMsg); | ||
| audioInput->start(); | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| audioProcessor.onBeat([&]() { | ||
| beatCount++; | ||
| lastBeatTime = fl::millis(); | ||
| sharedData.beat = true; | ||
| EXT_LOGD(ML_TAG, "BEAT #: %d", beatCount); | ||
| }); | ||
|
|
||
| audioProcessor.onVocalStart([&]() { sharedData.vocalsActive = true; }); | ||
|
|
||
| audioProcessor.onVocalEnd([&]() { sharedData.vocalsActive = false; }); | ||
|
|
||
| audioProcessor.onVocalConfidence([](float confidence) { | ||
| static uint32_t lastPrint = 0; | ||
| if (fl::millis() - lastPrint > 200) { | ||
| sharedData.vocalConfidence = confidence; | ||
| EXT_LOGD(ML_TAG, "Vocal confidence: %f", confidence); | ||
| lastPrint = fl::millis(); | ||
| } | ||
| }); | ||
|
|
||
| audioProcessor.onBass([](float level) { | ||
| if (level > 0.01f) { | ||
| sharedData.bassLevel = level; | ||
| EXT_LOGD(ML_TAG, "Bass: %f", level); | ||
| } | ||
| }); | ||
|
ewowi marked this conversation as resolved.
|
||
|
|
||
| audioProcessor.onTreble([](float level) { | ||
| if (level > 0.01f) { | ||
| sharedData.trebleLevel = level; | ||
| EXT_LOGD(ML_TAG, "Treble: %f", level); | ||
| } | ||
| }); | ||
| } | ||
|
|
||
| void loop20ms() override { | ||
| while (fl::AudioSample sample = audioInput->read()) { | ||
| audioProcessor.update(sample); | ||
| } | ||
|
|
||
| sharedData.beat = false; | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
Outdated
|
||
|
|
||
| ~FastLEDAudioDriver() override {} | ||
| }; | ||
|
|
||
| #endif | ||
2 changes: 1 addition & 1 deletion
2
src/MoonLight/Nodes/Drivers/D_FastLED.h → ...MoonLight/Nodes/Drivers/D_FastLEDDriver.h
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
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
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
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
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
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 3265
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 92
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 92
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 47
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 811
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 2738
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 181
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 2966
🏁 Script executed:
Repository: MoonModules/MoonLight
Length of output: 3009
Add
-D FASTLED_RMT5=0to force legacy RMT4 driver and prevent ISR handler degradation.The FASTLED_BUILD string aligns correctly with the pinned commit. However, platform 55.03.37 uses ESP-IDF 5.5+ with Arduino core 3.x, which causes FastLED to default to the RMT5 driver. RMT5 has documented ISR handler lifecycle issues (see FastLED issue
#1903) causing repeated "Handler detached" messages and severe performance drops (~2 FPS). Add-D FASTLED_RMT5=0to the [moonlight] build_flags to force the stable legacy RMT4 driver.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not true on newest FastLED
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🌐 Web query:
💡 Result:
I couldn’t find any FastLED change/issue (through the public repo + recent searches) specifically tied to a “handler detached” message for the ESP32 RMT5 driver in February 2026—so there doesn’t appear to be a known “Feb 2026” targeted fix labeled that way. (If you have the exact log line + platform/core version, I can search more precisely.)
What is documented/fixed recently around ESP32 RMT5 stability:
-D FASTLED_RMT5=0(typically requires older ESP32 Arduino core / IDF4-era setups; also note RMT4 and RMT5 can’t coexist). [3]Most actionable next step: confirm whether your “handler detached” happens only with DMA enabled. If yes, try updating FastLED (>= 3.10.1) first. [1] If it persists, try
FASTLED_RMT5=0(RMT4) or switch to a non-RMT driver as above. [3]Sources:
[1] FastLED releases (3.10.1 notes: DMA mode accidentally set true, breaking RMT5) https://github.com/fastled/fastled/releases
[2] FastLED issue
#2082(RMT5 + Wi‑Fi flicker; buffering/priority limits/knobs discussion) FastLED/FastLED#2082[3] FastLED repository documentation (RMT4 vs RMT5 selection;
FASTLED_RMT5=0; alternative drivers) https://github.com/FastLED/FastLED@ewowi, thank you for the correction! I appreciate you letting me know that the RMT5 "Handler detached" issues have been resolved in the newest FastLED version.Since you originally provided the learning about RMT5 issues (learning ID
9bb17d59-f1a1-4505-b40f-39a68c64be29) and you're now confirming it's no longer applicable with the latest FastLED, would you like me to remove that outdated learning from the knowledge base? This will prevent it from being referenced in future reviews.✏️ Learnings added
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes remove it please
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ewowi, I've removed the outdated learning about the FastLED RMT5 driver issues. The knowledge base now reflects the current state: that RMT5 issues have been resolved in FastLED as of commit 27c99130c83ab666c4c6dbf389425fec5f27db05 (master 20260222), and the-D FASTLED_RMT5=0workaround is no longer needed. Thank you for keeping the information up to date!🐰💭
(Learning tidied up!)
/) /)
( •.• )
/>📝✨
⛔ Learnings removed
🧠 Learnings used
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Disabling RMT5 should not be necessary now? The RMT5 driver now allocates more memory during WIFI active mode. Please let me know if this isn't the case. RMT5 will have stress testing either this week if ai credits sustain. Otherwise post friday on refresh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.