Repository navigation
Conversation
AudioOutputI2S::begin() fills the DMA with silence, and AudioGeneratorWAV stops the output as soon as the last sample is queued, so whatever is still in the DMA never plays. With the default 5 x 576 frames that is 360 ms at the 8 kHz tone rate: tones up to ~360 ms were not heard at all and longer ones were cut by 360 ms. Every blocking call also waited ~70 ms for the first DMA slot. Use a 3 x 80 frame DMA for tones (30 ms) and append one DMA worth of silence to the generated wave, so the part that gets cut is silence.
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Proposed Changes
Short tones from
playTone()are not heard at all, and longer ones lose their end.AudioOutputI2S::begin()fills the DMA with silence, andAudioGeneratorWAVstops the output as soon as the last sample is queued, so whatever is still in the DMA never plays. With the default 5 x 576 frames that is 360 ms at the 8 kHz tone rate: tones up to ~360 ms are silent and longer ones are cut by 360 ms. Every blocking call also waits ~70 ms for the first DMA slot.Changes in
src/modules/others/audio.cpp:Other audio (WAV/MP3 files, RTTTL, TTS) keeps the default DMA size.
Types of Changes
Bugfix
Verification
audio.tone()from a JS script on the T-Embed CC1101 speaker:audio.tone(880, 10)took ~90 ms before and ~45 ms after (now()around the call).Testing
Tested on LilyGO T-Embed CC1101 Plus (
lilygo-t-embed-cc1101). Not tested on other I2S speaker boards.Linked Issues
None found.
User-Facing Change
Further Comments
Opened together with two other tone fixes (wrong pitch, JS non-blocking flag). The three touch
playTone()in different places and each applies todevon its own.