Skip to content

fix(web): a new root carries the speed, so a moved chord sounds in its new key - #35

Merged
benjamin-small merged 1 commit into
mainfrom
notes-root-carries-speed
Oct 12, 2026
Merged

benjamin-small merged 1 commit into
mainfrom
notes-root-carries-speed

Conversation

@benjamin-small

Copy link
Copy Markdown
Owner

Problem

In chord mode, pressing a new root (e.g. C major → D major) changed the labels but not what played. The speed counts the root's swings per second and every other note runs at a ratio to it; both chords are 4 : 5 : 6, so at an unchanged speed they sound (and draw) identically. Verified in the browser: after Real pitch at C4 (262 Hz), pressing D4 left the speed at 262 Hz.

Fix

On any root change (chip press or pasted link, when both the old and new root exist) the speed is multiplied by midiToHz(new) / midiToHz(old), clamped to 0.25–1000 Hz. A running Real-pitch glide still stops. Applies in single-note mode too.

Validation

  • vitest 396/396 (5 new tests: scaling, chord move, clamp at the top, empty pick, pasted link; one existing link test now expects the SetSpeed before Play), svelte-check 0 errors, cargo fmt/cargo test pass
  • Browser: Real pitch on C4 major → 262 Hz; press D4 → 294 Hz; press G3 → 196 Hz; no console errors

…s new key

The speed counts the root's swings and the other notes swing at ratios to it, so moving a chord (C major to D major, both 4:5:6) at the same speed played and drew exactly the old chord under new names. A root change from a chip or a link now scales the speed by the step between the roots, clamped to the slider's range; at Real pitch the new root sounds at its own pitch.
@benjamin-small
benjamin-small merged commit bd3cd36 into main Oct 12, 2026
6 checks passed
@benjamin-small
benjamin-small deleted the notes-root-carries-speed branch October 12, 2026 23:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant