Search · Music theory
Fretboard
Chord shapes derived, not tabulated
An interactive fretboard that finds playable fingerings for any chord in any tuning by searching the neck under physical constraints. It ships no chord dictionary, which is why it works in tunings nobody has tabulated.
- TypeScript
- SVG
- Web Audio
In short
- Constraint search over hand positions, pruned by which chord tones remain reachable
- Independently derives the shapes guitarists actually use: x32010, 133211, x02210
- Works unchanged in DADGAD, open G, and on a reentrant-tuned ukulele
- Chord recognition in the other direction: an unordered set of notes back to a name
Why not ship a chord dictionary
Almost every chord app is a lookup table: a few thousand hand-entered diagrams, keyed by root and quality. It works, it is fast, and it stops dead the moment you drop the low E to D. Alternate tunings are exactly where a player most wants help, and exactly where a table has nothing to say.
Deriving the shapes instead means the tuning is an input rather than an assumption. The same code handles DADGAD, open G, a bass, and a ukulele whose fourth string is tuned above its third — none of which required a single new line.
The search
A fingering is a choice per string: mute it, play it open, or fret it somewhere the hand can reach. Fixing a hand position bounds the fretted options to a span of four frets, which turns the problem into a depth-first walk over the strings with a handful of choices each, repeated for each position on the neck.
Two prunings keep it cheap. Only frets that actually sound a chord tone are ever considered, which removes most of the branching before the search starts. And a branch is abandoned as soon as the strings still to come cannot supply the chord tones still missing. Twelve roots' worth of shapes is comfortably under a frame.
Ranking is where the musical judgement lives. Covering every chord tone dominates; after that the score rewards full voicings, open strings and the root in the bass, and penalises stretches and the number of fretted notes. It is a heuristic, not a theorem — so the test for it is that the shapes guitarists actually play come out on top.
The other direction
Naming a chord from a set of notes is the harder problem, because the answer is not unique. C-E-G-A is both C6 and Am7, and both are correct; which one you mean depends on the bass and on context.
The recogniser scores every root against every quality: chord tones present earn credit, missing tones and notes the chord cannot explain both cost. That produces a fit score that stays honest — an exact match is always exactly 1 — and leaves preference to the tiebreaks, where the bass note settles it. Under an A it reports Am7; under a C, C6; under an E, a slash chord. The score is unchanged across all three, because the fit genuinely is.
Source
- src/lib/music/fretboard.ts
- src/lib/music/chords.ts
- src/lib/music/fretboard.test.ts