@dsebastien/music-notation 0.6.0 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. package/README.md +28 -2
  2. package/dist/blocks/note-set-field.d.ts +3 -1
  3. package/dist/blocks/progression.d.ts +6 -0
  4. package/dist/blocks/renderers.d.ts +12 -1
  5. package/dist/blocks/scales-for.d.ts +16 -0
  6. package/dist/chord/capo.d.ts +26 -0
  7. package/dist/chord/guitar.d.ts +20 -0
  8. package/dist/chord/transitions.d.ts +15 -7
  9. package/dist/chords/chart-diagrams.d.ts +46 -0
  10. package/dist/chords/chart.d.ts +16 -0
  11. package/dist/chords/chordpro.d.ts +17 -1
  12. package/dist/chords/defines.d.ts +38 -0
  13. package/dist/circle/circle.d.ts +21 -0
  14. package/dist/cli.js +2 -2
  15. package/dist/convert/text-tab.d.ts +4 -2
  16. package/dist/fretboard/fretboard.d.ts +11 -0
  17. package/dist/fretboard/positions.d.ts +12 -5
  18. package/dist/index.d.ts +20 -5
  19. package/dist/index.js +5958 -1831
  20. package/dist/index.js.map +40 -23
  21. package/dist/keyboard/keyboard.d.ts +2 -0
  22. package/dist/keyboard/piano-chord.d.ts +44 -0
  23. package/dist/keyboard/voice-leading.d.ts +6 -0
  24. package/dist/music-notation.css +339 -0
  25. package/dist/music-notation.publish.min.js +362 -21
  26. package/dist/music-notation.tab.min.js +343 -4
  27. package/dist/playback/controls.d.ts +10 -1
  28. package/dist/playback/follow.d.ts +45 -0
  29. package/dist/playback/player.d.ts +16 -6
  30. package/dist/playback/strum-bar.d.ts +5 -0
  31. package/dist/publish/index.js +5283 -1760
  32. package/dist/publish/index.js.map +39 -22
  33. package/dist/strum/pattern.d.ts +49 -0
  34. package/dist/strum/play.d.ts +106 -0
  35. package/dist/strum/render.d.ts +17 -0
  36. package/dist/strum/voicing.d.ts +10 -0
  37. package/dist/tab/index.d.ts +2 -1
  38. package/dist/tab/index.js +353 -80
  39. package/dist/tab/index.js.map +7 -7
  40. package/dist/theory/chord-symbol.d.ts +2 -0
  41. package/dist/theory/find.d.ts +82 -0
  42. package/dist/theory/keys.d.ts +79 -0
  43. package/dist/theory/note-set.d.ts +2 -0
  44. package/dist/theory/numerals.d.ts +40 -0
  45. package/dist/theory/pitch.d.ts +4 -1
  46. package/dist/theory/transpose.d.ts +16 -4
  47. package/dist/voicings/index.js +58 -14
  48. package/dist/voicings/index.js.map +5 -5
  49. package/package.json +1 -1
@@ -0,0 +1,82 @@
1
+ import { type MusicalKey } from './keys.js';
2
+ export interface ScaleMatch {
3
+ /** "G major", "E minor pentatonic". */
4
+ name: string;
5
+ tonic: string;
6
+ /** tonal's scale type: "major", "minor pentatonic". */
7
+ type: string;
8
+ /** The scale's notes, from the tonic. */
9
+ notes: string[];
10
+ /** The scale's notes that the notes or chords don't play. */
11
+ missing: string[];
12
+ /** The notes or chord tones that aren't in the scale, as written. */
13
+ outside: string[];
14
+ }
15
+ export interface FindScalesOptions {
16
+ /**
17
+ * How to read the items: note names or chord symbols. By default, chords when any item isn't
18
+ * a plain note name (G D Em C); "G C D" reads as three notes unless you say chords. Notes with
19
+ * octaves (C4 E4 G4) are notes, unless every one could be a power chord (A5 D5 E5).
20
+ */
21
+ as?: 'notes' | 'chords';
22
+ /** Scales with up to this many outside notes are listed too (after the others); 1 by default. */
23
+ maxOutside?: number;
24
+ /** At most this many scales, 20 by default. */
25
+ limit?: number;
26
+ }
27
+ /**
28
+ * The scales that hold some notes, or the tones of some chords, best first: fewer outside notes
29
+ * first, major and minor before their modes, then pentatonic and blues scales, then the harmonic
30
+ * and melodic minor and their modes, the others last; a tonic on the first chord's root (or the
31
+ * first note) first. Each match lists its missing notes (in the scale, not played) and outside
32
+ * notes (played, not in the scale). Empty when an item doesn't read.
33
+ */
34
+ export declare function findScales(input: string | readonly string[], options?: FindScalesOptions): ScaleMatch[];
35
+ /**
36
+ * Scales to play over a chord (chord-scale): the scales on its root that hold every chord tone,
37
+ * best first (Cmaj7: C major, C lydian, C major pentatonic…; Dm7: D minor, D dorian, D phrygian…).
38
+ * Empty when the chord doesn't read.
39
+ */
40
+ export declare function scalesForChord(symbol: string, options?: {
41
+ limit?: number;
42
+ }): ScaleMatch[];
43
+ export interface ScaleChord {
44
+ /** 1-based position in the scale. */
45
+ degree: number;
46
+ root: string;
47
+ /** The triad stacked in thirds on the scale (seven-note scales); null otherwise. */
48
+ triad: string | null;
49
+ /** The seventh chord stacked in thirds (seven-note scales); null otherwise. */
50
+ seventh: string | null;
51
+ /** The triad's numeral from the scale's tonic ("ii", "bVII"); null without a triad. */
52
+ numeral: string | null;
53
+ /** Every common chord on this root whose notes are all in the scale. */
54
+ chords: string[];
55
+ }
56
+ /**
57
+ * The chords in a scale: on each note, the triad and the seventh chord stacked in thirds (for
58
+ * seven-note scales), their numeral, and every common chord whose notes are all in the scale.
59
+ * Null when the scale doesn't read.
60
+ */
61
+ export declare function chordsInScale(scaleName: string): ScaleChord[] | null;
62
+ export interface KeyCandidate extends MusicalKey {
63
+ /** Higher is likelier. */
64
+ score: number;
65
+ /** The chords that aren't in the key, as written. */
66
+ outside: string[];
67
+ }
68
+ export interface FoundKey extends KeyCandidate {
69
+ /** The likeliest keys, this one first. */
70
+ candidates: KeyCandidate[];
71
+ /** False when another key scores about as well (C major and A minor for C F G Am). */
72
+ clear: boolean;
73
+ }
74
+ /** Whether every tone of a chord is in the key (a minor key's V and vii° included). */
75
+ export declare function inKey(symbol: string, key: MusicalKey): boolean;
76
+ /**
77
+ * The most likely key of a progression: the key whose chords are in it most (a chord borrowed
78
+ * from the parallel key or a secondary dominant counts a little), with the first and last chords
79
+ * on its tonic and dominant-to-tonic moves as evidence. The tonic is spelled as the chords spell
80
+ * it (Gb major for Gb Db Ebm Cb), else the usual way. Null when a chord doesn't read.
81
+ */
82
+ export declare function findKey(chords: string | readonly string[]): FoundKey | null;
@@ -0,0 +1,79 @@
1
+ /** Modes a key can be in: major and minor, and the church modes. */
2
+ export declare const MODES: readonly ["major", "minor", "ionian", "dorian", "phrygian", "lydian", "mixolydian", "aeolian", "locrian"];
3
+ export type Mode = (typeof MODES)[number];
4
+ export interface MusicalKey {
5
+ /** "F#", "Bb". */
6
+ tonic: string;
7
+ mode: Mode;
8
+ /** "F# minor", "D dorian". */
9
+ name: string;
10
+ }
11
+ /** A note name as tonal writes it: "f#" → "F#", "E♭" → "Eb"; null when it isn't one. */
12
+ export declare function noteName(text: string): string | null;
13
+ /**
14
+ * "G", "Em", "F# minor", "Bb major", "D dorian", "c#m" → the key; null when it isn't one. A key
15
+ * with no mode is major.
16
+ */
17
+ export declare function readKey(text: string): MusicalKey | null;
18
+ /** Whether a mode has a minor third (minor, aeolian, dorian, phrygian, locrian). */
19
+ export declare const isMinorMode: (mode: Mode) => boolean;
20
+ /** The key's notes (G major: G A B C D E F#). */
21
+ export declare const keyNotes: (key: MusicalKey) => string[];
22
+ /** The tonic of the major scale whose notes a mode uses (D dorian → C, A minor → C). */
23
+ export declare function parentMajor(key: MusicalKey): string;
24
+ export interface KeySignature {
25
+ /** Sharps (positive) or flats (negative); 0 for C major and A minor. */
26
+ count: number;
27
+ /** The altered notes in the order a signature writes them: F# C# G#…, Bb Eb Ab…. */
28
+ accidentals: string[];
29
+ }
30
+ /** The key signature (D dorian has C major's: none). */
31
+ export declare function keySignature(key: MusicalKey): KeySignature;
32
+ /** Most sharps or flats a key signature has (C# major, Cb major). */
33
+ export declare const MAX_SIGNATURE = 7;
34
+ /**
35
+ * Why a key can't be written: its signature would need more than 7 sharps or flats (double sharps
36
+ * or flats), with the other spelling to write ("G# major needs 8 sharps: write Ab major"); null
37
+ * when it can.
38
+ */
39
+ export declare function keyProblem(key: MusicalKey): string | null;
40
+ /** "1♯", "3♭", "no ♯ or ♭". */
41
+ export declare const signatureText: (count: number) => string;
42
+ /** The triad or seventh chord stacked in thirds from `root` on these notes; null when unnamed. */
43
+ export declare function stackedChord(notes: string[], index: number, sevenths: boolean): string | null;
44
+ export interface Degree {
45
+ /** 1 to 7. */
46
+ number: number;
47
+ /** "b", "#", "" (or "bb", "##"). */
48
+ accidental: string;
49
+ }
50
+ /**
51
+ * The degree of a note in a key, by letters: in G, F is b7 and F# is 7. Degrees count from the
52
+ * major scale, so a minor key's own 3rd, 6th and 7th are b3, b6, b7 (bIII, bVI, bVII). With
53
+ * `minorKey`, the raised ones are #3, #6, #7: a minor key reads an unmarked VI as its own 6th
54
+ * (see readNumeral), so the mark keeps numerals reading back to the same chord.
55
+ */
56
+ export declare function degreeOf(tonic: string, note: string, minorKey?: boolean): Degree | null;
57
+ /** The numeral's text for a chord on a degree: "bVII", "ii7", "vii°", "V7". */
58
+ export declare function romanText(degree: Degree, suffix: string): string;
59
+ /**
60
+ * The Nashville number for a chord on a degree: "b7", "6m", "2m7", and "5⁷" (a seventh right after
61
+ * the number is raised, as charts write it, so it doesn't read as 57).
62
+ */
63
+ export declare function nashvilleText(degree: Degree, suffix: string): string;
64
+ /** "5⁷" → "57": superscript digits as plain ones. */
65
+ export declare const plainDigits: (text: string) => string;
66
+ export interface KeyChord {
67
+ /** 1 to 7. */
68
+ degree: number;
69
+ /** "ii", "bVII", "V7", "viiø7". */
70
+ numeral: string;
71
+ /** "Am", "F", "D7". */
72
+ symbol: string;
73
+ }
74
+ /**
75
+ * The key's seven chords, stacked in thirds on its notes: triads, or seventh chords. Numerals
76
+ * count from the major scale (A minor: i ii° bIII iv v bVI bVII; D dorian: i ii bIII IV v vi°
77
+ * bVII).
78
+ */
79
+ export declare function keyChords(key: MusicalKey, sevenths?: boolean): KeyChord[];
@@ -31,6 +31,8 @@ export interface NoteMarks {
31
31
  ghosts?: Set<number>;
32
32
  /** The ghosts as the compared scale spells them (C minor's Eb, not D#). */
33
33
  ghostNames?: Map<number, string>;
34
+ /** A chord drawn over a scale: its tones in the scale; the scale's other notes are passing. */
35
+ chordTones?: Set<number>;
34
36
  }
35
37
  /** Classes for a highlighted note: root, characteristic, different. */
36
38
  export declare function markClasses(set: NoteSet, chroma: number, marks?: NoteMarks): string;
@@ -0,0 +1,40 @@
1
+ import { type MusicalKey } from './keys.js';
2
+ /** What a chord does in its key. */
3
+ export type HarmonicFunction = 'tonic' | 'subdominant' | 'dominant' | 'secondary dominant' | 'borrowed' | 'chromatic';
4
+ export interface ProgressionChord {
5
+ /** As written: "V7/V", "6m", "Em". */
6
+ written: string;
7
+ /** The chord: "D7", "Em". */
8
+ symbol: string;
9
+ /** Its roman numeral: as written for numerals, worked out for chord names ("bVII", "V7/V"). */
10
+ numeral: string;
11
+ /** Its Nashville number ("b7", "6m", "5/3"). */
12
+ nashville: string;
13
+ function: HarmonicFunction;
14
+ }
15
+ /**
16
+ * A roman numeral or Nashville number in a key → its chord symbol; null when it doesn't read.
17
+ * Roman: case for the quality (V major, vi minor), °, ø, +, and any chord suffix (V7, ii7, Imaj7,
18
+ * vii°7, IVadd9); accidentals (bVII, #iv°); secondary chords (V/V, V7/ii, vii°/V: the chord in
19
+ * the major key of the numeral after the slash); a bass degree (I/3). Nashville: 1 5 6m 4, minor
20
+ * with m or - (6-, 2-7), b7, 5/3 (bass).
21
+ */
22
+ export declare function readNumeral(token: string, key: string | MusicalKey): string | null;
23
+ /** What a chord does in a key: its diatonic function, or secondary dominant, borrowed, chromatic. */
24
+ export declare function harmonicFunction(symbol: string, key: string | MusicalKey): HarmonicFunction | null;
25
+ /**
26
+ * A chord's numeral in a key: "bVII", "ii7", "vii°" (in minor too: the leading tone), a
27
+ * secondary dominant as "V7/V", a bass as a degree ("I/3"). Roman numerals by default, or
28
+ * Nashville numbers ("b7", "2m7", "1/3"). Null when the chord or the key doesn't read.
29
+ */
30
+ export declare function numeralOf(symbol: string, key: string | MusicalKey, style?: 'roman' | 'nashville'): string | null;
31
+ /** Tokens of a progression: spaces, commas and bar lines separate them. */
32
+ export declare const progressionTokens: (text: string) => string[];
33
+ /**
34
+ * A progression in a key: roman numerals ("I V vi IV", "ii7 V7 Imaj7", "I bVII IV", "I V/V V"),
35
+ * Nashville numbers ("1 5 6m 4") or chord names ("G D Em C"), each with its chord, numeral,
36
+ * Nashville number and function. Null when the key or a token doesn't read.
37
+ */
38
+ export declare function progressionChords(numerals: string | readonly string[], key: string | MusicalKey): ProgressionChord[] | null;
39
+ /** One token of a progression (see progressionChords); null when it doesn't read. */
40
+ export declare function progressionChord(written: string, key: MusicalKey): ProgressionChord | null;
@@ -18,7 +18,10 @@ export interface ChordSymbolParts {
18
18
  }
19
19
  /**
20
20
  * "F♯m7/C#" → root F#, suffix m7, bass C#. A slash starts a bass only when a note name follows
21
- * ("C6/9" has no bass). ♯ and ♭ become # and b.
21
+ * ("C6/9" has no bass). ♯ and ♭ become # and b. Roots and basses may have a double sharp (## or
22
+ * x, given back as ##; a root's x not before a digit) or a double flat (bb): F##dim is vii° in
23
+ * G# minor. The longest accidental wins, as a single flat does (Cb5 is a C♭ power chord, Cbb5 a
24
+ * C𝄫 one).
22
25
  */
23
26
  export declare function splitChordSymbol(symbol: string): ChordSymbolParts | null;
24
27
  /** "C4" for MIDI 60. */
@@ -1,9 +1,21 @@
1
- /** Whether a key ("F", "Bb", "Dm") is written with flats. */
1
+ /** Whether a key ("F", "Bb", "Dm") is written with flats; a tonic written with a sharp ("C#")
2
+ * is a sharp key, one written with a flat a flat key. */
2
3
  export declare function keyPrefersFlats(key: string): boolean;
4
+ /** A move from one key to another (their tonics, "G" → "F#"): chords keep their letters. */
5
+ export interface KeyMove {
6
+ from: string;
7
+ to: string;
8
+ }
3
9
  /**
4
- * Transpose a chord symbol ("F#m7/C#", +2 → "G#m7/D#"). Spelling follows `preferFlats`, or the
5
- * symbol's own when not given. Text that isn't a chord symbol comes back unchanged.
10
+ * Transpose a chord symbol ("F#m7/C#", +2 → "G#m7/D#"). Spelling follows `spelling`: flats
11
+ * (true), sharps (false), a move between two keys (each note moves by the interval between their
12
+ * tonics, so letters keep their place in the key: G → F# major turns F#dim into E#dim and C into
13
+ * B, Em → Ebm turns C into Cb), or the symbol's own when not given. Text that isn't a chord symbol
14
+ * comes back unchanged.
6
15
  */
7
- export declare function transposeChord(symbol: string, semitones: number, preferFlats?: boolean): string;
16
+ export declare function transposeChord(symbol: string, semitones: number, spelling?: boolean | KeyMove): string;
8
17
  /** Transpose a key ("Am", +3 → "Cm"), spelled the way that key is usually written. */
9
18
  export declare function transposeKey(key: string, semitones: number): string;
19
+ /** The move from a key to the same key transposed ("G", -1 → G to F#); null when the key has no
20
+ * tonic. */
21
+ export declare function keyMove(key: string, semitones: number): KeyMove | null;
@@ -141,11 +141,11 @@ function baseFretOf(frets) {
141
141
  return 1;
142
142
  return Math.min(...fretted);
143
143
  }
144
- function barresOf(voicing) {
144
+ function barresOf(voicing, capoFret) {
145
145
  const byKey = new Map;
146
146
  voicing.frets.forEach((fret, string) => {
147
147
  const finger = voicing.fingers[string];
148
- if (fret === null || fret === 0 || !finger)
148
+ if (fret === null || fret === 0 || fret === capoFret || !finger)
149
149
  return;
150
150
  const key = `${finger}@${fret}`;
151
151
  byKey.set(key, [...byKey.get(key) ?? [], string]);
@@ -169,6 +169,8 @@ var ROW = 20;
169
169
  var MARKERS = 16;
170
170
  var BASE = 30;
171
171
  var TITLE = 22;
172
+ var CAPTION = 18;
173
+ var capoCaption = (capo, sounds) => `Capo ${capo}${sounds ? `, sounds ${sounds}` : ""}`;
172
174
  function renderGuitarDiagram(doc, voicing, options = {}) {
173
175
  const strings = voicing.frets.length;
174
176
  const base = voicing.baseFret ?? baseFretOf(voicing.frets);
@@ -176,6 +178,10 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
176
178
  const rows = Math.max(4, fretted.length ? Math.max(...fretted) - base + 1 : 0);
177
179
  const orientation = options.orientation ?? "vertical";
178
180
  const vertical = orientation === "vertical";
181
+ const capo = options.capo && options.capo > 0 ? options.capo : 0;
182
+ const fromNut = capo > 0 && options.fretsFrom === "nut";
183
+ const capoFret = fromNut ? capo : null;
184
+ const caption = capo && options.caption !== false ? capoCaption(capo, options.sounds) : undefined;
179
185
  const frame = neckFrame({
180
186
  orientation,
181
187
  hand: options.hand ?? "right",
@@ -186,13 +192,26 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
186
192
  low: vertical || base > 1 ? BASE : 10,
187
193
  high: vertical ? 14 : 10,
188
194
  top: options.title ? TITLE : 4,
189
- minWidth: titleWidth(options.title)
195
+ minWidth: Math.max(titleWidth(options.title), titleWidth(caption))
190
196
  });
191
197
  const across = (string) => string * SPACING;
192
198
  const along = (row) => row * ROW;
193
199
  const at = (string, row) => frame.at(across(string), along(row));
194
- const label = options.title ? `${options.title} chord diagram` : "Chord diagram";
195
- const root = svgRoot(doc, frame.width, frame.height, "mn-guitar-chord", label);
200
+ const label = `${options.title ? `${options.title} chord diagram` : "Chord diagram"}${capo ? `, ${capoCaption(capo, options.sounds).replace(/^Capo/, "capo")}` : ""}`;
201
+ const height = frame.height + (caption ? CAPTION : 0);
202
+ const root = svgRoot(doc, frame.width, height, "mn-guitar-chord", label);
203
+ if (caption) {
204
+ root.appendChild(svgText(doc, caption, {
205
+ class: "mn-caption",
206
+ x: frame.width / 2,
207
+ y: height - 6,
208
+ "text-anchor": "middle"
209
+ }));
210
+ }
211
+ if (capo) {
212
+ root.setAttribute("data-mn-capo", String(capo));
213
+ root.setAttribute("data-mn-frets-from", fromNut ? "nut" : "capo");
214
+ }
196
215
  if (options.title) {
197
216
  root.appendChild(svgText(doc, options.title, {
198
217
  class: "mn-title",
@@ -202,9 +221,17 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
202
221
  }));
203
222
  }
204
223
  for (let row = 0;row <= rows; row++) {
205
- const cls = row === 0 && base === 1 ? "mn-nut" : "mn-fret";
224
+ const cls = row === 0 && base === 1 && (!capo || fromNut) ? "mn-nut" : "mn-fret";
206
225
  root.appendChild(svgLine(doc, at(0, row), at(strings - 1, row), cls));
207
226
  }
227
+ const capoRow = fromNut ? capo - base + 0.5 : base === 1 ? 0 : null;
228
+ if (capo && capoRow !== null && capoRow >= 0 && capoRow <= rows) {
229
+ root.appendChild(svg(doc, "rect", {
230
+ class: "mn-capo",
231
+ ...frame.box(across(0) - 8, along(capoRow) - 3, across(strings - 1) + 8, along(capoRow) + 3),
232
+ rx: 3
233
+ }));
234
+ }
208
235
  for (let s = 0;s < strings; s++) {
209
236
  root.appendChild(svgLine(doc, at(s, 0), at(s, rows), "mn-string"));
210
237
  }
@@ -212,7 +239,7 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
212
239
  const label = `${base}fr`;
213
240
  root.appendChild(vertical ? svgLabel(doc, label, frame.at(-10, along(0.5)), "mn-base-fret", options.hand === "left" ? "start" : "end") : svgLabel(doc, label, frame.at(-16, along(0.5)), "mn-base-fret"));
214
241
  }
215
- for (const barre of barresOf(voicing)) {
242
+ for (const barre of barresOf(voicing, capoFret)) {
216
243
  const middle = along(barre.fret - base + 0.5);
217
244
  root.appendChild(svg(doc, "rect", {
218
245
  class: "mn-barre",
@@ -230,7 +257,8 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
230
257
  root.appendChild(muted);
231
258
  return;
232
259
  }
233
- const open = tuning?.[s];
260
+ const openString = tuning?.[s];
261
+ const open = openString === undefined ? undefined : openString + (fromNut ? 0 : capo);
234
262
  const isRoot = options.root !== undefined && options.root !== null && open !== undefined && (open + fret) % 12 === options.root;
235
263
  const midi = {
236
264
  "data-mn-string": string,
@@ -248,6 +276,17 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
248
276
  }));
249
277
  return;
250
278
  }
279
+ if (fret === capoFret) {
280
+ const [cx, cy] = at(s, fret - base + 0.5);
281
+ root.appendChild(svg(doc, "circle", {
282
+ class: `mn-capo-open${isRoot ? " mn-root" : ""}`,
283
+ cx,
284
+ cy,
285
+ r: 4,
286
+ ...midi
287
+ }));
288
+ return;
289
+ }
251
290
  const center = at(s, fret - base + 0.5);
252
291
  const [cx, cy] = center;
253
292
  root.appendChild(svg(doc, "circle", {
@@ -262,7 +301,8 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
262
301
  root.appendChild(svgLabel(doc, text, center, "mn-dot-text"));
263
302
  });
264
303
  if (tuning) {
265
- const pitches = voicing.frets.flatMap((f, s) => f === null ? [] : [tuning[s] + f]);
304
+ const shift = fromNut ? 0 : capo;
305
+ const pitches = voicing.frets.flatMap((f, s) => f === null ? [] : [tuning[s] + shift + f]);
266
306
  root.setAttribute("data-mn-pitches", pitches.join(" "));
267
307
  root.setAttribute("data-mn-play", "chord");
268
308
  root.setAttribute("data-mn-sound", "guitar");
@@ -311,10 +351,11 @@ function midiOf(note) {
311
351
  return (Number(m[2]) + 1) * 12 + chroma - shift * 12;
312
352
  }
313
353
  var nameOf = (chroma, preferFlats = false) => (preferFlats ? FLAT_NAMES : SHARP_NAMES)[((Math.round(chroma) || 0) % 12 + 12) % 12];
354
+ var doubleSharp = (name) => name.replace(/x$/, "##");
314
355
  function splitChordSymbol(symbol) {
315
- const normalized = symbol.trim().replace(/♯/g, "#").replace(/♭/g, "b");
316
- const m = /^([A-G][#b]?)(.*?)(?:\/([A-G][#b]?))?$/.exec(normalized);
317
- return m ? { root: m[1], suffix: m[2], bass: m[3] ?? null } : null;
356
+ const normalized = symbol.trim().replace(/♯/g, "#").replace(/♭/g, "b").replace(/𝄪/g, "x").replace(/𝄫/g, "bb");
357
+ const m = /^([A-G](?:##|x(?!\d)|bb|#|b)?)(.*?)(?:\/([A-G](?:##|x|bb|#|b)?))?$/.exec(normalized);
358
+ return m ? { root: doubleSharp(m[1]), suffix: m[2], bass: m[3] ? doubleSharp(m[3]) : null } : null;
318
359
  }
319
360
  var noteOf = (midi, preferFlats = false) => `${nameOf(midi, preferFlats)}${Math.floor(midi / 12) - 1}`;
320
361
  var isFlat = (name) => /^[A-Ga-g][b♭]/.test(name.trim());
@@ -445,13 +486,16 @@ function markClasses(set, chroma, marks = {}) {
445
486
  classes.push("mn-char");
446
487
  if (marks.different?.has(chroma))
447
488
  classes.push("mn-diff");
489
+ if (marks.chordTones)
490
+ classes.push(marks.chordTones.has(chroma) ? "mn-tone" : "mn-passing");
448
491
  return classes.length ? ` ${classes.join(" ")}` : "";
449
492
  }
450
493
  function describeMarks(set, marks = {}) {
451
494
  const names = (chromas) => set.members.filter((m) => chromas?.has(m.chroma)).map((m) => m.name);
452
495
  const characteristic = names(marks.characteristic);
453
496
  const different = names(marks.different);
454
- return (characteristic.length ? `, characteristic notes: ${characteristic.join(" ")}` : "") + (different.length ? `, different from the compared scale: ${different.join(" ")}` : "");
497
+ const tones = names(marks.chordTones);
498
+ return (characteristic.length ? `, characteristic notes: ${characteristic.join(" ")}` : "") + (different.length ? `, different from the compared scale: ${different.join(" ")}` : "") + (tones.length ? `, chord tones: ${tones.join(" ")}` : "");
455
499
  }
456
500
  var memberFor = (set, chroma) => set.members.find((m) => m.chroma === chroma);
457
501
  var memberOf = (set, midi) => set.pitches && !set.pitches.includes(midi) ? undefined : memberFor(set, (midi % 12 + 12) % 12);
@@ -1072,5 +1116,5 @@ export {
1072
1116
  voicingCount
1073
1117
  };
1074
1118
 
1075
- //# debugId=F3659EDE73223BE364756E2164756E21
1119
+ //# debugId=E4AEA9217A9C58C564756E2164756E21
1076
1120
  //# sourceMappingURL=index.js.map