Repository navigation
Conversation
AudioFileSourceFunction passes time in seconds, so sin(hz * time) runs at hz / (2*pi): a 440 Hz tone came out at about 70 Hz. The sine wave type (waveType 1) and the ESP8266Audio example already use sin(TWO_PI * hz * time).
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
playTone()builds its square wave assin(hz * time) >= 0.AudioFileSourceFunctionpassestimein seconds ((p - sizeof(WavHeader)) / avg_bytes_per_sec), so the wave runs athz / 2π: a 440 Hz tone plays at ~70 Hz, 880 Hz at ~140 Hz. The sine branch right below (waveType == 1) and the ESP8266Audio examplePlayWAVFromFunctionalready usesin(TWO_PI * hz * time).One-line fix: add the missing
TWO_PI. Affects every_tone()/playTone()on boards that go through the I2S speaker path (not Cardputer, not M5Unified, not buzzer boards).Types of Changes
Bugfix
Verification
audio.tone(440, 1500)andaudio.tone(880, 1500)from a JS script, pitch read with a phone tuner app held at the speaker.dev@ 4fb1615)Testing
Tested on LilyGO T-Embed CC1101 Plus (
lilygo-t-embed-cc1101). Build has no new warnings.Linked Issues
None found (searched open/closed issues and PRs for tone / pitch / frequency).
User-Facing Change
Further Comments