Investigate "all tunings half-step flat" — code is correct, add regression guard - #17
Merged
Merged
Conversation
Founder reported every tuning reads ~1 semitone flat. Investigation found NO deterministic constant bug: note-math (A4=440, MIDI formula), guitar presets, nearest-string selection, the TS YIN/MPM DSP, and the production worklet pitch chain all resolve standard guitar frequencies (82.41/110/146.83/196/246.94/329.63/440 Hz) to <0.1 cents. This adds a permanent regression test feeding exact reference pitches through frequency->MIDI->note and the nearest-string/cents path, asserting 0-cent agreement (a semitone bug would surface as ~-100c). The test passes, confirming the code is correct. The reported symptom is therefore environmental (stale cached PWA service worker / worklet, or a non-440 reference on the source), not a code constant. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
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.
Founder report
Root-cause investigation
The hypothesis was a deterministic constant bug (wrong A4, off-by-one MIDI/octave, bin/sample-rate error, shifted note table). Every candidate was checked and ruled out. The codebase is mathematically correct end-to-end.
Verified accurate to <0.1 cents at A4=440 and all standard guitar frequencies (82.41 / 110 / 146.83 / 196 / 246.94 / 329.63 Hz):
src/audio/note-math.ts:39-49440 * 2**((midi-69)/12),1200*log2()— correctsrc/audio/note-math.ts:22-37src/domain/instruments/guitar/presets.tssrc/app/state.ts:104src/audio/dsp/{yin,mpm}.tspublic/worklets/tuner-processor.jsThere is no semitone-flat constant or formula error anywhere in the source. No prior semitone fix exists in history;
productionis current withdev.What this PR does
Adds a permanent regression test (
test/unit/semitone-flat-regression.test.ts) that feeds exact reference pitches throughfrequency → MIDI → noteand the nearest-string / cents path, asserting 0-cent agreement. A genuine semitone bug would surface here as ≈ -100 cents. The test passes, codifying correctness and catching any future regression.No production-code change is made because the reported defect does not exist in the code. Fabricating a "fix" would introduce a real bug.
Most likely actual cause (for Founder follow-up, no deploy)
tuner-processor.jsfrom before the octave-gate fixes (21fbbf9). Hard-reload / clear site data and retest.Recommend the Founder hard-refresh tuner.fi (or bump the SW cache version) and retest before any further code work.
Tests
npm test→ 80 files, 299 tests, all green (includes the new regression test).🤖 Generated with Claude Code