feat: guitar voicing templates

This commit is contained in:
2026-04-09 00:31:25 +02:00
parent aeb9dfff67
commit ac65be1bb9

View File

@@ -0,0 +1,88 @@
export interface GuitarVoicingTemplate {
/** 6 strings low→high; 0 = root position, 1 = one fret above root, null = muted */
frets: (number | null)[];
/** Fret (0-based relative) where a full barre is drawn, or null */
barre: number | null;
/** Which open string carries the root — determines transposition offset */
rootString: 'E' | 'A';
}
/**
* Moveable barre-chord templates keyed by tonal chord type name.
* Verified fingerings at root = E (E-shape) or root = A (A-shape).
* To add a new quality: look up `Chord.get('<example>').type` in tonal,
* then define the fingering at root E or A and add it here.
*/
export const GUITAR_VOICINGS: Record<string, GuitarVoicingTemplate> = {
// ── E-shape (root on 6th string) ──────────────────────────────────────
// E major open: [0,2,2,1,0,0] E B E G# B E
'major': {
frets: [0, 2, 2, 1, 0, 0],
barre: null,
rootString: 'E',
},
// E7: [0,2,0,1,0,0] E B D G# B E
'dominant seventh': {
frets: [0, 2, 0, 1, 0, 0],
barre: null,
rootString: 'E',
},
// Emaj7: [0,2,1,1,0,0] E B D# G# B E
'major seventh': {
frets: [0, 2, 1, 1, 0, 0],
barre: null,
rootString: 'E',
},
// Eaug: [0,3,2,1,1,0] E C(=B#) E G# C E
'augmented': {
frets: [0, 3, 2, 1, 1, 0],
barre: null,
rootString: 'E',
},
// Esus4: [0,2,2,2,0,0] E B E A B E
'suspended fourth': {
frets: [0, 2, 2, 2, 0, 0],
barre: null,
rootString: 'E',
},
// ── A-shape (root on 5th string) ──────────────────────────────────────
// Am open: [x,0,2,2,1,0] A E A C E
// barre: 0 so that transposed versions (Bm, Cm, etc.) draw the barre bar;
// the renderer suppresses the barre when baseFret===0 (open position = no barre needed)
'minor': {
frets: [null, 0, 2, 2, 1, 0],
barre: 0,
rootString: 'A',
},
// Am7: [x,0,2,0,1,0] A E G C E
'minor seventh': {
frets: [null, 0, 2, 0, 1, 0],
barre: null,
rootString: 'A',
},
// AmMaj7: [x,0,2,1,1,0] A E G# C E
'minor major seventh': {
frets: [null, 0, 2, 1, 1, 0],
barre: null,
rootString: 'A',
},
// Adim: [x,0,1,2,1,x] A Eb A C (string 1 muted)
'diminished': {
frets: [null, 0, 1, 2, 1, null],
barre: null,
rootString: 'A',
},
// Am7b5 (half-dim): [x,0,1,0,1,x] A Eb G C
'half-diminished': {
frets: [null, 0, 1, 0, 1, null],
barre: null,
rootString: 'A',
},
// Asus2: [x,0,2,2,0,0] A E A B E
'suspended second': {
frets: [null, 0, 2, 2, 0, 0],
barre: null,
rootString: 'A',
},
};