fix(audioreactive): skip i2s_set_clk() for PDM mode on IDF 5.x - #5807
fix(audioreactive): skip i2s_set_clk() for PDM mode on IDF 5.x#5807aenertia wants to merge 2 commits into
Conversation
i2s_set_clk() after i2s_driver_install() kills PDM mode on ESP-IDF 5.x, producing all-zero samples from the microphone. The PDM clock is configured during driver install; calling i2s_set_clk() afterwards resets it to I2S standard mode. Fix: guard i2s_set_clk() with if (!(_config.mode & I2S_MODE_PDM)) so PDM microphones (SPM1423, INMP441 in PDM mode) work correctly on IDF 5.x. Also fixes PDM channel format: uses I2S_CHANNEL_FMT_ALL_LEFT/ALL_RIGHT instead of ONLY_LEFT/ONLY_RIGHT, which is required for PDM compatibility on IDF 5.x (ONLY_* variants produce silence in PDM mode). Tested on M5StickC with SPM1423 PDM microphone.
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (1)
🚧 Files skipped from review as they are similar to previous changes (1)
Included review availability: Your plan provides up to 10 included reviews per hour; 8 remain after this review. WalkthroughPDM channel selection now uses side-specific ChangesPDM I2S configuration
Estimated code review effort: 2 (Simple) | ~10 minutes Merge Risk: ⚪ Minimal · up to The change is limited to PDM microphone clock and channel-format handling; no actionable merge-blocking risk remains beyond normal checks and review. Possibly related PRs
Suggested labels: Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as outdated.
|
@coderabbitai is this PR compatible with upcoming changes in #5764 and #5773 ? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
repo="wled/WLED"
for pr in 5807 5764 5773; do
echo "===== PR #${pr}: metadata ====="
gh pr view "$pr" --repo "$repo" --json number,title,state,isDraft,baseRefName,headRefName,mergeable,mergeStateStatus,url,body \
--jq '{number,title,state,isDraft,baseRefName,headRefName,mergeable,mergeStateStatus,url,body}'
echo "===== PR #${pr}: changed files ====="
gh pr view "$pr" --repo "$repo" --json files \
--jq '.files[] | {path, additions, deletions}'
echo "===== PR #${pr}: diff ====="
gh pr diff "$pr" --repo "$repo" --patch
done
echo "===== Local source outline ====="
ast-grep outline usermods/audioreactive/audio_source.h --items all --view expanded
echo "===== Relevant local I2S configuration ====="
rg -n -C 8 'I2S_PDM_MIC_CHANNEL|i2s_set_clk\s*\(|I2S_MODE_PDM|I2S_CHANNEL_FMT_(ONLY|ALL)_(LEFT|RIGHT)' \
usermods/audioreactive/audio_source.hLength of output: 169114
PR PR You are interacting with an AI system. |
|
@coderabbitai your .coderabbit.yaml explicitly asks to check for deleted comments in AI generated source code. Why did you miss the two deleted comments in this PR? |
|
Tip For best results, initiate chat on the files or code changes. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
echo '===== Configuration files ====='
fd -HI '^\.coderabbit\.(ya?ml)$|^AGENTS\.md$' . -d 3 -x sh -c 'echo "--- $1"; cat -n "$1"' sh {}
echo '===== PR `#5807` deleted lines and context ====='
git diff --find-renames --unified=12 origin/"$(git remote show origin | sed -n '/HEAD branch/s/.*: //p')"...HEAD -- usermods/audioreactive/audio_source.h \
|| true
echo '===== Relevant markers and comments in PR file ====='
rg -n -C 5 'AI:|I2S_PDM_MIC_CHANNEL|i2s_set_clk|//|/\*|\*/' usermods/audioreactive/audio_source.hLength of output: 75534
PR
I focused on the functional PDM change and did not perform the required removed-line review as a separate step. That omission caused the missed finding. The deleted comments should have been reviewed and either retained, moved to the new guarded path, or justified in the PR description. 🐇⬛ 🧠 Learnings usedYou are interacting with an AI system. |
|
Just some comments before I push fixup commit : IDF 4.x compatibility: #5764 relationship: |
i2s_set_clk() after i2s_driver_install() kills PDM mode on ESP-IDF 5.x, producing all-zero samples from the microphone. The PDM clock is configured during driver install; calling i2s_set_clk() afterwards resets it to I2S standard mode.
Fix: guard i2s_set_clk() with if (!(_config.mode & I2S_MODE_PDM)) so PDM microphones (SPM1423, INMP441 in PDM mode) work correctly on IDF 5.x.
Also fixes PDM channel format: uses I2S_CHANNEL_FMT_ALL_LEFT/ALL_RIGHT instead of ONLY_LEFT/ONLY_RIGHT, which is required for PDM compatibility on IDF 5.x (ONLY_* variants produce silence in PDM mode).
Tested on M5StickC with SPM1423 PDM microphone.
Summary by CodeRabbit