|
18 | 18 | const chordName = event.currentTarget.dataset.chord; |
19 | 19 |
|
20 | 20 | // Use the first position's MIDI notes from chord-db |
21 | | - const fingerings = getChordFingerings(chordName); |
| 21 | + const result = getChordFingerings(chordName); |
22 | 22 |
|
23 | | - if (!fingerings || fingerings.length === 0) { |
| 23 | + if (!result || !result.positions || result.positions.length === 0) { |
24 | 24 | console.warn(`No fingerings found for ${chordName}`); |
25 | 25 | return; |
26 | 26 | } |
27 | 27 |
|
28 | | - const firstPosition = fingerings[0]; |
| 28 | + const firstPosition = result.positions[0]; |
29 | 29 | const midi = firstPosition.midi; |
30 | 30 |
|
31 | 31 | player.play(midi, 15); |
32 | | -
|
33 | | - // Get chord info for callback |
34 | | - const chord = Chord.get(chordName); |
35 | 32 | } |
36 | 33 |
|
37 | 34 | function renderChord(element, chord) { |
38 | 35 | if (!element) return; |
39 | 36 |
|
40 | 37 | // Standard chord rendering |
41 | | - const variations = getChordVariations(chord); |
| 38 | + const { positions } = getChordVariations(chord); |
42 | 39 |
|
43 | | - if (!variations || variations.length === 0) { |
| 40 | + if (!positions || positions.length === 0) { |
44 | 41 | console.warn(`No fingerings found for ${chord}`); |
45 | 42 | return; |
46 | 43 | } |
47 | 44 |
|
48 | 45 | // Use the first variation |
49 | | - const chordData = variations[0]; |
| 46 | + const chordData = positions[0]; |
50 | 47 | // Create the SVGuitar instance |
51 | 48 | const chart = new SVGuitarChord(element); |
52 | 49 | chart |
|
81 | 78 | }); |
82 | 79 |
|
83 | 80 | $effect(() => { |
84 | | - const triads = Mode.triads(scale.type, scale.tonic); |
| 81 | + const triads = Mode.triads(scale.type, scale.tonic).map((chord) => |
| 82 | + chord.replace("E#", "F").replace("B#", "C"), |
| 83 | + ); |
85 | 84 |
|
86 | 85 | // Sort chords so diminished chords appear last |
87 | 86 | chords = triads.sort((a, b) => { |
|
0 commit comments