Repository navigation
Restructure: tuning engine out of Vue, scoped styles, ESLint, CI on pull requests - #3
Merged
Merged
Conversation
useTuner.ts held constants, pure pitch helpers, the state machine, the session log and the Vue refs in 629 lines. Now: - src/tuner/pitch.ts: centsBetween, isHarmonicOf, median, foldTowardTarget. - src/tuner/instruments.ts: the per-instrument settings. - src/tuner/engine.ts: createTunerEngine, the state machine with no Vue and no audio APIs: process(frame, now), selectString, setTuning, reset, and the values the UI shows in `display`. - src/tuner/sessionLog.ts: the "paste to Copilot" session log, now only in development builds; production no longer prints it on every stop. - useTuner.ts: feeds the engine, mirrors it into the same read-only refs, steers the low-pass filter and stops 2 s after "all in tune". Its API is unchanged, so GuitarTuner.vue is untouched. The overtone-fold path no longer repeats the direct path: both go through acceptPitch. The three ways it differed (it shows the folded frame's pitch, drops a continuity jump silently, and does not restart the stability timer when far off) are kept as options of FOLDED_OVERTONE, so behaviour is the same. useTuner.equivalence.test.ts proves it: the old useTuner (verbatim copy in src/test/legacyUseTuner.ts) and the new one get the same random frames, string choices, tuning changes and restarts at the same fake time, 8 sessions of 6000 steps, and everything the UI sees is equal after every step. Changing showFramePitch or resetStabilityWhenOff makes it fail. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The old useTuner copy and the test comparing it with the new engine served the previous commit; check that commit out to run them again. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
public/icons.svg is the Vite template's sprite of social icons (Bluesky, Discord, GitHub, X...); src/assets/hero.svg and src/assets/icon.svg are older copies of the splash and the icon. None is referenced by the app, index.html or the manifest. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Now that they live in src/tuner/pitch.ts they can be imported on their own: cents arithmetic and rounding, which multiples count as harmonics, the median against an octave-error spike, and when folding a harmonic down applies and when it leaves the pitch alone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
src/styles/*.css were global stylesheets imported one by one in main.ts. Each is now a <style scoped> block in its component; src/style.css stays global (theme tokens, page background, resets) and is imported first. Scoping also fixes the phone-landscape layout. GuitarTuner's landscape rules shrink the ring to 140 px, the note to 2.75rem and align the chips left, but TunerRing.css and StringChips.css were imported after GuitarTuner.css with selectors just as specific, so they won and the ring stayed at 190 px. Now the parent's rules win as intended; the two rules on TunerRing's inner note use :deep(). Checked in the browser by recording position, size and 26 style properties of every element in 10 states (phone portrait and landscape, desktop; dark and light; tuning selector and settings open): identical before and after except phone landscape, where only the chips, the ring and the note changed, as above. The listening state (in-tune colours, Stop button, locked chip) was checked with an oscillator as microphone. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
ESLint with the configuration create-vue generates: eslint-plugin-vue's recommended rules, typescript-eslint's recommended rules through @vue/eslint-config-typescript, and @vue/eslint-config-prettier so that formatting stays Prettier's job. The code already passes it. - npm run lint - .github/workflows/ci.yml: lint, tests and the type-checked build on every pull request (until now only pushes to master ran anything). - deploy.yml: lints too, before the tests and the build. Co-Authored-By: Claude Opus 5.5 <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.
Built on the tests in #2 and contains its commit: merge #2 first and this diff shrinks to the commits below. App behaviour is unchanged, except one layout bug fixed (phone landscape, see "Styles").
Engine out of Vue (
src/tuner/)useTuner.tsheld constants, pure pitch helpers, the state machine, the session log and the Vue refs in 629 lines. Now:src/tuner/pitch.tscentsBetween,isHarmonicOf,median,foldTowardTarget(now tested on their own)src/tuner/instruments.tssrc/tuner/engine.tscreateTunerEngine: the state machine, no Vue, no audio APIssrc/tuner/sessionLog.tssrc/composables/useTuner.tsGuitarTuner.vueuntouchedThe overtone-fold path no longer repeats ~60 lines of the direct path: both go through
acceptPitch. It differed in three small ways, kept as explicit options (FOLDED_OVERTONE) so behaviour is identical. They may be unintended and are worth a look:Proof of equivalence — commit 95c3f62 contains a verbatim copy of the old
useTunerand a test that feeds it and the new one the same random frames, string choices, tuning changes and restarts at the same fake time: 8 sessions × 6000 steps, everything the UI sees equal after every step. Flipping option 1 or 3 makes it fail. The next commit removes the copy and the test; check out 95c3f62 to run them.Styles
src/styles/*.csswere global and imported one by one inmain.ts; each is now a<style scoped>block in its component,src/style.cssstays global and is imported first.This fixes the phone-landscape layout:
GuitarTuner.css's landscape rules (ring 140 px, note 2.75rem, chips aligned left) lost toTunerRing.cssandStringChips.css, imported later with selectors just as specific, so the ring stayed at 190 px. Checked in the browser by recording position, size and 26 style properties of every element in 10 states (phone portrait/landscape, desktop; dark/light; tuning selector and settings open): identical before and after except phone landscape, where only the chips, the ring and the note changed. The listening state was checked with an oscillator as the microphone.Other
public/icons.svg(Vite template's social icons),src/assets/hero.svg,src/assets/icon.svg.npm run lint; the code already passed it..github/workflows/ci.yml: lint, tests and the type-checked build on every pull request (until now only pushes to master ran anything);deploy.ymllints too.Found, not changed here
StringChips.vuethe chip number is reversed: the high E shows "6" and the low E "1", while the line under the ring (and guitar convention) calls the low E string 6.tuning.strings - dishould bedi + 1.lockedStringIndex), e.g. ukulele standard → baritone.🤖 Generated with Claude Code