From f4e0ac67e0118f6ab74cbf2b19bbde6a8a5fe563 Mon Sep 17 00:00:00 2001 From: vadimwit Date: Wed, 8 Jul 2026 22:54:18 +0100 Subject: [PATCH] fix(voicings): correct movable-shape base-fret indexing in getGuitarVoicings (task L-23) strIdx = rootStr-1 read OPEN [s6..s1] backwards: every rootStr-5 shape sat 2 frets low, every rootStr-4 shape 5 frets low (A-shape C major labeled fret 1 instead of 3) in ChordDetailModal/ExplorePanel/ CurrentJamPanel; rootStr-6 was accidentally correct (same pc both ends). Now uses the shared 6-rootStr convention. Also: playChord docstring octave example corrected. Critic PASS (6 independent fret checks + 252-entry pre/post sweep, structure unchanged). Co-Authored-By: Claude Fable 5 --- src/lib/chordAudio.js | 2 +- src/lib/voicings.js | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/lib/chordAudio.js b/src/lib/chordAudio.js index 2f87a75..452faf0 100644 --- a/src/lib/chordAudio.js +++ b/src/lib/chordAudio.js @@ -264,7 +264,7 @@ export function guitarShapeToNotes(shape, opts = {}) { * Simple fallback when all you have is a bare pitch-class set (e.g. a detected * chord's tones, no voicing). Stacks the pcs ASCENDING from the first pc, which * is treated as the bass: each subsequent pc lands in the nearest position - * above the previous note — so [7, 11, 5] plays G3-B3-F4, a real shell, not a + * above the previous note — so [7, 11, 5] plays G4-B4-F5, a real shell, not a * scrambled cluster. `octave` places the bass (4 = the octave starting at * C4 = middle C; default 4; piano.js note = (octave − 3) * 12 + pc). * diff --git a/src/lib/voicings.js b/src/lib/voicings.js index 0e07e03..1644bb9 100644 --- a/src/lib/voicings.js +++ b/src/lib/voicings.js @@ -504,8 +504,11 @@ export function getGuitarVoicings(chordName) { continue } - // barre shape: compute rootFret on rootStr - const strIdx = shape.rootStr - 1 // 0=s6 … 5=s1 + // barre shape: compute rootFret on rootStr. + // OPEN is ordered [s6 … s1] and rootStr is 1-indexed with 6 = low E, + // so string N lives at index 6 - N (same convention as ChordDiagram.jsx + // and chordAudio.guitarShapeToNotes). + const strIdx = 6 - shape.rootStr // 0=s6 … 5=s1 const openPc = OPEN[strIdx] let rootFret = (rootPc - openPc + 12) % 12