@dsebastien/music-notation 0.8.0 → 0.9.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.
- package/README.md +37 -5
- package/dist/chord/generate.d.ts +34 -9
- package/dist/chord/guitar.d.ts +18 -0
- package/dist/circle/circle.d.ts +8 -2
- package/dist/cli.js +1 -1
- package/dist/convert/text-tab.d.ts +56 -0
- package/dist/index.d.ts +9 -8
- package/dist/index.js +6599 -4673
- package/dist/index.js.map +32 -30
- package/dist/keyboard/keyboard.d.ts +17 -2
- package/dist/keyboard/piano-chord.d.ts +28 -3
- package/dist/keyboard/play-voicing.d.ts +10 -0
- package/dist/keyboard/scale-fingering.d.ts +41 -0
- package/dist/keyboard/voice-leading.d.ts +55 -4
- package/dist/music-notation.css +68 -5
- package/dist/music-notation.publish.min.js +91 -28
- package/dist/music-notation.tab.min.js +72 -9
- package/dist/playback/controls.d.ts +13 -2
- package/dist/playback/player.d.ts +69 -5
- package/dist/publish/index.js +5306 -3909
- package/dist/publish/index.js.map +31 -29
- package/dist/render/dom.d.ts +25 -1
- package/dist/strum/pattern.d.ts +25 -0
- package/dist/strum/play.d.ts +46 -5
- package/dist/strum/render.d.ts +4 -1
- package/dist/tab/index.d.ts +39 -0
- package/dist/tab/index.js +683 -75
- package/dist/tab/index.js.map +6 -6
- package/dist/theory/detect.d.ts +6 -2
- package/dist/theory/find.d.ts +35 -7
- package/dist/theory/keys.d.ts +8 -2
- package/dist/theory/note-set.d.ts +5 -0
- package/dist/theory/numerals.d.ts +34 -7
- package/dist/voicings/check.d.ts +17 -0
- package/dist/voicings/curated.d.ts +10 -0
- package/dist/voicings/index.d.ts +1 -1
- package/dist/voicings/index.js +429 -109
- package/dist/voicings/index.js.map +10 -8
- package/package.json +1 -1
package/dist/voicings/index.js
CHANGED
|
@@ -42,15 +42,55 @@ function html(doc, tag, cls, text) {
|
|
|
42
42
|
el.textContent = text;
|
|
43
43
|
return el;
|
|
44
44
|
}
|
|
45
|
+
var NAME_PREFIX = `mn-name-${Math.random().toString(36).slice(2, 8)}-`;
|
|
46
|
+
var names = 0;
|
|
45
47
|
function svgRoot(doc, width, height, cls, label) {
|
|
48
|
+
const id = `${NAME_PREFIX}${++names}`;
|
|
49
|
+
const title = svg(doc, "title", { class: "mn-name", id });
|
|
50
|
+
title.textContent = label;
|
|
46
51
|
return svg(doc, "svg", {
|
|
47
52
|
xmlns: SVG_NS,
|
|
48
53
|
viewBox: `0 0 ${width} ${height}`,
|
|
49
54
|
width,
|
|
50
55
|
class: `mn-svg ${cls}`,
|
|
51
56
|
role: "img",
|
|
52
|
-
"aria-
|
|
57
|
+
"aria-labelledby": id
|
|
58
|
+
}, [svg(doc, "defs", {}, [title])]);
|
|
59
|
+
}
|
|
60
|
+
var nameElement = (el) => {
|
|
61
|
+
const id = el.getAttribute("aria-labelledby");
|
|
62
|
+
if (!id)
|
|
63
|
+
return null;
|
|
64
|
+
for (const candidate of el.querySelectorAll("[id]")) {
|
|
65
|
+
if (candidate.getAttribute("id") === id)
|
|
66
|
+
return candidate;
|
|
67
|
+
}
|
|
68
|
+
return el.ownerDocument.getElementById(id);
|
|
69
|
+
};
|
|
70
|
+
function accessibleName(el) {
|
|
71
|
+
const named = nameElement(el);
|
|
72
|
+
if (named)
|
|
73
|
+
return named.textContent;
|
|
74
|
+
return el.getAttribute("aria-label");
|
|
75
|
+
}
|
|
76
|
+
function setAccessibleName(el, name) {
|
|
77
|
+
const named = nameElement(el);
|
|
78
|
+
if (named)
|
|
79
|
+
named.textContent = name;
|
|
80
|
+
else
|
|
81
|
+
el.setAttribute("aria-label", name);
|
|
82
|
+
}
|
|
83
|
+
function playableMark(doc, area, ...children) {
|
|
84
|
+
const hit = svg(doc, "rect", {
|
|
85
|
+
class: "mn-hit",
|
|
86
|
+
x: area.x,
|
|
87
|
+
y: area.y,
|
|
88
|
+
width: area.width,
|
|
89
|
+
height: area.height,
|
|
90
|
+
fill: "transparent",
|
|
91
|
+
"pointer-events": "all"
|
|
53
92
|
});
|
|
93
|
+
return svg(doc, "g", { class: "mn-mark" }, [hit, ...children]);
|
|
54
94
|
}
|
|
55
95
|
|
|
56
96
|
// src/render/layout.ts
|
|
@@ -122,8 +162,60 @@ function neckFrame(n) {
|
|
|
122
162
|
return { width: content + 2 * shift, height, at, box };
|
|
123
163
|
}
|
|
124
164
|
|
|
165
|
+
// src/theory/pitch.ts
|
|
166
|
+
var SHARP_NAMES = [
|
|
167
|
+
"C",
|
|
168
|
+
"C#",
|
|
169
|
+
"D",
|
|
170
|
+
"D#",
|
|
171
|
+
"E",
|
|
172
|
+
"F",
|
|
173
|
+
"F#",
|
|
174
|
+
"G",
|
|
175
|
+
"G#",
|
|
176
|
+
"A",
|
|
177
|
+
"A#",
|
|
178
|
+
"B"
|
|
179
|
+
];
|
|
180
|
+
var FLAT_NAMES = ["C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"];
|
|
181
|
+
var LETTER_CHROMA = { C: 0, D: 2, E: 4, F: 5, G: 7, A: 9, B: 11 };
|
|
182
|
+
function chromaOf(name) {
|
|
183
|
+
const m = /^([A-Ga-g])([#♯b♭]*)$/.exec(name.trim());
|
|
184
|
+
if (!m)
|
|
185
|
+
return null;
|
|
186
|
+
let chroma = LETTER_CHROMA[m[1].toUpperCase()];
|
|
187
|
+
for (const accidental of m[2])
|
|
188
|
+
chroma += accidental === "#" || accidental === "♯" ? 1 : -1;
|
|
189
|
+
return (chroma % 12 + 12) % 12;
|
|
190
|
+
}
|
|
191
|
+
function midiOf(note) {
|
|
192
|
+
const m = /^([A-Ga-g][#♯b♭]*)(-?\d)$/.exec(note.trim());
|
|
193
|
+
if (!m)
|
|
194
|
+
return null;
|
|
195
|
+
const chroma = chromaOf(m[1]);
|
|
196
|
+
if (chroma === null)
|
|
197
|
+
return null;
|
|
198
|
+
const letter = LETTER_CHROMA[m[1][0].toUpperCase()];
|
|
199
|
+
const shift = Math.round((chroma - letter) / 12);
|
|
200
|
+
return (Number(m[2]) + 1) * 12 + chroma - shift * 12;
|
|
201
|
+
}
|
|
202
|
+
var nameOf = (chroma, preferFlats = false) => (preferFlats ? FLAT_NAMES : SHARP_NAMES)[((Math.round(chroma) || 0) % 12 + 12) % 12];
|
|
203
|
+
var doubleSharp = (name) => name.replace(/x$/, "##");
|
|
204
|
+
function splitChordSymbol(symbol) {
|
|
205
|
+
const normalized = symbol.trim().replace(/♯/g, "#").replace(/♭/g, "b").replace(/𝄪/g, "x").replace(/𝄫/g, "bb");
|
|
206
|
+
const m = /^([A-G](?:##|x(?!\d)|bb|#|b)?)(.*?)(?:\/([A-G](?:##|x|bb|#|b)?))?$/.exec(normalized);
|
|
207
|
+
return m ? { root: doubleSharp(m[1]), suffix: m[2], bass: m[3] ? doubleSharp(m[3]) : null } : null;
|
|
208
|
+
}
|
|
209
|
+
var noteOf = (midi, preferFlats = false) => `${nameOf(midi, preferFlats)}${Math.floor(midi / 12) - 1}`;
|
|
210
|
+
var isFlat = (name) => /^[A-Ga-g][b♭]/.test(name.trim());
|
|
211
|
+
|
|
125
212
|
// src/chord/guitar.ts
|
|
126
213
|
var STANDARD_TUNING = [40, 45, 50, 55, 59, 64];
|
|
214
|
+
function chartNoteName(name) {
|
|
215
|
+
if (!/^[A-G](##|bb)$/.test(name))
|
|
216
|
+
return name;
|
|
217
|
+
return nameOf(chromaOf(name), name.endsWith("b"));
|
|
218
|
+
}
|
|
127
219
|
function parseFrets(text) {
|
|
128
220
|
const trimmed = text.trim();
|
|
129
221
|
const tokens = /[\s,-]/.test(trimmed) ? trimmed.split(/[\s,-]+/) : [...trimmed];
|
|
@@ -154,19 +246,31 @@ function barresOf(voicing, capoFret) {
|
|
|
154
246
|
for (const [key, strings] of byKey) {
|
|
155
247
|
if (strings.length < 2)
|
|
156
248
|
continue;
|
|
157
|
-
const [finger,
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
249
|
+
const [finger, fretText] = key.split("@");
|
|
250
|
+
const fret = Number(fretText);
|
|
251
|
+
const from = Math.min(...strings);
|
|
252
|
+
const to = Math.max(...strings);
|
|
253
|
+
let under = false;
|
|
254
|
+
for (let s = from + 1;s < to; s++) {
|
|
255
|
+
const f = voicing.frets[s];
|
|
256
|
+
if (!strings.includes(s) && f !== null && f !== undefined && f > fret)
|
|
257
|
+
under = true;
|
|
258
|
+
}
|
|
259
|
+
barres.push({ fret, from, to, finger, strings, full: under || strings.length > 3 });
|
|
164
260
|
}
|
|
165
261
|
return barres;
|
|
166
262
|
}
|
|
263
|
+
function barreKind(voicing) {
|
|
264
|
+
const barres = barresOf(voicing, null);
|
|
265
|
+
if (!barres.length)
|
|
266
|
+
return null;
|
|
267
|
+
return barres.some((b) => b.full) ? "full" : "partial";
|
|
268
|
+
}
|
|
269
|
+
var isBarreVoicing = (voicing) => barreKind(voicing) !== null;
|
|
167
270
|
var SPACING = 18;
|
|
168
271
|
var ROW = 20;
|
|
169
272
|
var MARKERS = 16;
|
|
273
|
+
var HIT_ALONG = 44;
|
|
170
274
|
var BASE = 30;
|
|
171
275
|
var TITLE = 22;
|
|
172
276
|
var CAPTION = 18;
|
|
@@ -239,22 +343,41 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
|
|
|
239
343
|
const label = `${base}fr`;
|
|
240
344
|
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"));
|
|
241
345
|
}
|
|
346
|
+
const textOf = (s) => (options.labels ? options.labels[s] : voicing.fingers[s]) ?? null;
|
|
347
|
+
const quiet = new Set;
|
|
242
348
|
for (const barre of barresOf(voicing, capoFret)) {
|
|
349
|
+
const texts = new Set(barre.strings.map(textOf));
|
|
350
|
+
if (texts.size === 1) {
|
|
351
|
+
for (const s of barre.strings)
|
|
352
|
+
if (s !== barre.from)
|
|
353
|
+
quiet.add(s);
|
|
354
|
+
} else if (!barre.full) {
|
|
355
|
+
continue;
|
|
356
|
+
}
|
|
243
357
|
const middle = along(barre.fret - base + 0.5);
|
|
244
358
|
root.appendChild(svg(doc, "rect", {
|
|
245
359
|
class: "mn-barre",
|
|
246
360
|
...frame.box(across(barre.from) - 7, middle - 7, across(barre.to) + 7, middle + 7),
|
|
247
|
-
rx: 7
|
|
361
|
+
rx: 7,
|
|
362
|
+
"data-mn-fret": barre.fret,
|
|
363
|
+
"data-mn-finger": barre.finger,
|
|
364
|
+
"data-mn-from": strings - barre.from,
|
|
365
|
+
"data-mn-to": strings - barre.to
|
|
248
366
|
}));
|
|
249
367
|
}
|
|
250
368
|
const tuning = options.tuning ?? (strings === 6 ? STANDARD_TUNING : undefined);
|
|
251
369
|
voicing.frets.forEach((fret, s) => {
|
|
252
|
-
const
|
|
370
|
+
const markAlong = -8;
|
|
371
|
+
const mark = frame.at(across(s), markAlong);
|
|
253
372
|
const string = strings - s;
|
|
254
373
|
if (fret === null) {
|
|
255
|
-
const
|
|
256
|
-
|
|
257
|
-
root.appendChild(
|
|
374
|
+
const [x, y] = mark;
|
|
375
|
+
const d = 3.5;
|
|
376
|
+
root.appendChild(svg(doc, "path", {
|
|
377
|
+
class: "mn-muted",
|
|
378
|
+
d: `M${x - d} ${y - d}L${x + d} ${y + d}M${x + d} ${y - d}L${x - d} ${y + d}`,
|
|
379
|
+
"data-mn-string": string
|
|
380
|
+
}));
|
|
258
381
|
return;
|
|
259
382
|
}
|
|
260
383
|
const openString = tuning?.[s];
|
|
@@ -265,9 +388,18 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
|
|
|
265
388
|
"data-mn-fret": fret,
|
|
266
389
|
...open !== undefined ? { "data-midi": open + fret } : {}
|
|
267
390
|
};
|
|
391
|
+
const place = (markAt, ...els) => {
|
|
392
|
+
if (open === undefined) {
|
|
393
|
+
for (const el of els)
|
|
394
|
+
root.appendChild(el);
|
|
395
|
+
return;
|
|
396
|
+
}
|
|
397
|
+
const area = frame.box(across(s) - SPACING / 2, markAt - HIT_ALONG / 2, across(s) + SPACING / 2, markAt + HIT_ALONG / 2);
|
|
398
|
+
root.appendChild(playableMark(doc, area, ...els));
|
|
399
|
+
};
|
|
268
400
|
if (fret === 0) {
|
|
269
401
|
const [cx, cy] = mark;
|
|
270
|
-
|
|
402
|
+
place(markAlong, svg(doc, "circle", {
|
|
271
403
|
class: `mn-open${isRoot ? " mn-root" : ""}`,
|
|
272
404
|
cx,
|
|
273
405
|
cy,
|
|
@@ -276,9 +408,11 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
|
|
|
276
408
|
}));
|
|
277
409
|
return;
|
|
278
410
|
}
|
|
411
|
+
const row = along(fret - base + 0.5);
|
|
412
|
+
const center = at(s, fret - base + 0.5);
|
|
413
|
+
const [cx, cy] = center;
|
|
279
414
|
if (fret === capoFret) {
|
|
280
|
-
|
|
281
|
-
root.appendChild(svg(doc, "circle", {
|
|
415
|
+
place(row, svg(doc, "circle", {
|
|
282
416
|
class: `mn-capo-open${isRoot ? " mn-root" : ""}`,
|
|
283
417
|
cx,
|
|
284
418
|
cy,
|
|
@@ -287,18 +421,14 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
|
|
|
287
421
|
}));
|
|
288
422
|
return;
|
|
289
423
|
}
|
|
290
|
-
const
|
|
291
|
-
|
|
292
|
-
root.appendChild(svg(doc, "circle", {
|
|
424
|
+
const text = quiet.has(s) ? null : textOf(s);
|
|
425
|
+
place(row, svg(doc, "circle", {
|
|
293
426
|
class: `mn-dot${isRoot ? " mn-root" : ""}${options.marks?.[s] ? ` mn-${options.marks[s]}` : ""}`,
|
|
294
427
|
cx,
|
|
295
428
|
cy,
|
|
296
429
|
r: 7,
|
|
297
430
|
...midi
|
|
298
|
-
}));
|
|
299
|
-
const text = options.labels ? options.labels[s] : voicing.fingers[s];
|
|
300
|
-
if (text)
|
|
301
|
-
root.appendChild(svgLabel(doc, text, center, "mn-dot-text"));
|
|
431
|
+
}), ...text ? [svgLabel(doc, text, center, "mn-dot-text")] : []);
|
|
302
432
|
});
|
|
303
433
|
if (tuning) {
|
|
304
434
|
const shift = fromNut ? 0 : capo;
|
|
@@ -313,53 +443,6 @@ function renderGuitarDiagram(doc, voicing, options = {}) {
|
|
|
313
443
|
// src/theory/note-set.ts
|
|
314
444
|
import { Chord, Interval, Scale as Scale2 } from "tonal";
|
|
315
445
|
|
|
316
|
-
// src/theory/pitch.ts
|
|
317
|
-
var SHARP_NAMES = [
|
|
318
|
-
"C",
|
|
319
|
-
"C#",
|
|
320
|
-
"D",
|
|
321
|
-
"D#",
|
|
322
|
-
"E",
|
|
323
|
-
"F",
|
|
324
|
-
"F#",
|
|
325
|
-
"G",
|
|
326
|
-
"G#",
|
|
327
|
-
"A",
|
|
328
|
-
"A#",
|
|
329
|
-
"B"
|
|
330
|
-
];
|
|
331
|
-
var FLAT_NAMES = ["C", "Db", "D", "Eb", "E", "F", "Gb", "G", "Ab", "A", "Bb", "B"];
|
|
332
|
-
var LETTER_CHROMA = { C: 0, D: 2, E: 4, F: 5, G: 7, A: 9, B: 11 };
|
|
333
|
-
function chromaOf(name) {
|
|
334
|
-
const m = /^([A-Ga-g])([#♯b♭]*)$/.exec(name.trim());
|
|
335
|
-
if (!m)
|
|
336
|
-
return null;
|
|
337
|
-
let chroma = LETTER_CHROMA[m[1].toUpperCase()];
|
|
338
|
-
for (const accidental of m[2])
|
|
339
|
-
chroma += accidental === "#" || accidental === "♯" ? 1 : -1;
|
|
340
|
-
return (chroma % 12 + 12) % 12;
|
|
341
|
-
}
|
|
342
|
-
function midiOf(note) {
|
|
343
|
-
const m = /^([A-Ga-g][#♯b♭]*)(-?\d)$/.exec(note.trim());
|
|
344
|
-
if (!m)
|
|
345
|
-
return null;
|
|
346
|
-
const chroma = chromaOf(m[1]);
|
|
347
|
-
if (chroma === null)
|
|
348
|
-
return null;
|
|
349
|
-
const letter = LETTER_CHROMA[m[1][0].toUpperCase()];
|
|
350
|
-
const shift = Math.round((chroma - letter) / 12);
|
|
351
|
-
return (Number(m[2]) + 1) * 12 + chroma - shift * 12;
|
|
352
|
-
}
|
|
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$/, "##");
|
|
355
|
-
function splitChordSymbol(symbol) {
|
|
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;
|
|
359
|
-
}
|
|
360
|
-
var noteOf = (midi, preferFlats = false) => `${nameOf(midi, preferFlats)}${Math.floor(midi / 12) - 1}`;
|
|
361
|
-
var isFlat = (name) => /^[A-Ga-g][b♭]/.test(name.trim());
|
|
362
|
-
|
|
363
446
|
// src/theory/suffix.ts
|
|
364
447
|
var CANONICAL = new Map([
|
|
365
448
|
["M", ""],
|
|
@@ -567,6 +650,14 @@ function chordNoteSet(symbol) {
|
|
|
567
650
|
}
|
|
568
651
|
return set;
|
|
569
652
|
}
|
|
653
|
+
function respell(set, chord) {
|
|
654
|
+
set.root = chord.root;
|
|
655
|
+
for (const member of set.members) {
|
|
656
|
+
const own = memberFor(chord, member.chroma);
|
|
657
|
+
if (own)
|
|
658
|
+
member.name = own.name;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
570
661
|
function scaleNoteSet(name) {
|
|
571
662
|
const scale = Scale2.get(scaleName(name));
|
|
572
663
|
if (scale.empty || !scale.tonic)
|
|
@@ -624,6 +715,7 @@ function listNoteSet(text, root) {
|
|
|
624
715
|
}
|
|
625
716
|
|
|
626
717
|
// src/chord/generate.ts
|
|
718
|
+
var isBarreShape = (shape) => shape === "E shape" || shape === "A shape";
|
|
627
719
|
var MAX_GENERATED_STRINGS = 8;
|
|
628
720
|
var MAX_SPAN = 6;
|
|
629
721
|
function chordInfo(symbol) {
|
|
@@ -703,7 +795,7 @@ function fingerChoices(count) {
|
|
|
703
795
|
walk(1, []);
|
|
704
796
|
return out;
|
|
705
797
|
}
|
|
706
|
-
function bestFingering(frets) {
|
|
798
|
+
function bestFingering(frets, pinkyBarre = false) {
|
|
707
799
|
const empty = frets.map(() => null);
|
|
708
800
|
const byFret = new Map;
|
|
709
801
|
frets.forEach((fret, s) => {
|
|
@@ -727,6 +819,10 @@ function bestFingering(frets) {
|
|
|
727
819
|
const g = sorted[i];
|
|
728
820
|
if (g.under && (choice[i] !== 1 || g.fret !== lowest))
|
|
729
821
|
ok = false;
|
|
822
|
+
const topTwo = g.from === frets.length - 2 && g.to === frets.length - 1;
|
|
823
|
+
const pinky = pinkyBarre && choice[i] === 4 && topTwo;
|
|
824
|
+
if (g.strings.length > 1 && choice[i] !== 1 && choice[i] !== 3 && !pinky)
|
|
825
|
+
ok = false;
|
|
730
826
|
for (let j = i + 1;j < sorted.length && ok; j++) {
|
|
731
827
|
if (sorted[j].fret - g.fret > choice[j] - choice[i] + 1)
|
|
732
828
|
ok = false;
|
|
@@ -739,12 +835,17 @@ function bestFingering(frets) {
|
|
|
739
835
|
sorted.forEach((g, i) => {
|
|
740
836
|
const finger = choice[i];
|
|
741
837
|
if (g.strings.length > 1) {
|
|
742
|
-
cost += 2.5;
|
|
838
|
+
cost += finger === 4 ? 3.5 : 2.5;
|
|
743
839
|
if (finger === 1 && g.fret === lowest && g.to === top && !g.under)
|
|
744
840
|
cost -= 2;
|
|
745
841
|
}
|
|
746
842
|
cost += 0.1 * Math.abs(g.fret - lowest - (finger - 1));
|
|
747
843
|
});
|
|
844
|
+
const index = choice.indexOf(1);
|
|
845
|
+
const middle = choice.indexOf(2);
|
|
846
|
+
if (index >= 0 && middle >= 0) {
|
|
847
|
+
cost += 0.2 * Math.max(0, sorted[middle].fret - sorted[index].fret - 1);
|
|
848
|
+
}
|
|
748
849
|
for (const a of sorted)
|
|
749
850
|
for (const b of sorted)
|
|
750
851
|
if (a !== b && a.fret === b.fret && b.from - a.to >= 3) {
|
|
@@ -778,7 +879,7 @@ function bestFingering(frets) {
|
|
|
778
879
|
return best;
|
|
779
880
|
}
|
|
780
881
|
function fingerVoicing(frets) {
|
|
781
|
-
return bestFingering(frets)?.fingers ?? null;
|
|
882
|
+
return bestFingering(frets, true)?.fingers ?? null;
|
|
782
883
|
}
|
|
783
884
|
var CAGED_ROOT_STRING = {
|
|
784
885
|
C: 1,
|
|
@@ -818,7 +919,7 @@ function cagedTargets(info) {
|
|
|
818
919
|
}
|
|
819
920
|
return targets;
|
|
820
921
|
}
|
|
821
|
-
function shapeOf(frets, info, targets, tuning
|
|
922
|
+
function shapeOf(frets, info, targets, tuning) {
|
|
822
923
|
const sounding = frets.flatMap((f, s) => f === null ? [] : [s]);
|
|
823
924
|
if (!sounding.length || tuning.length !== frets.length)
|
|
824
925
|
return null;
|
|
@@ -838,7 +939,6 @@ function shapeOf(frets, info, targets, tuning, fingers) {
|
|
|
838
939
|
if (open && top && sounding.length >= 4 && (!fretted.length || Math.max(...fretted) <= 4)) {
|
|
839
940
|
return "Open";
|
|
840
941
|
}
|
|
841
|
-
const barre = fingers ? hasBarre(frets, fingers) : false;
|
|
842
942
|
if (sameTuning(tuning, STANDARD_TUNING) && !open && fretted.length) {
|
|
843
943
|
const lowest = Math.min(...fretted);
|
|
844
944
|
for (const letter of ["E", "A", "C", "G", "D"]) {
|
|
@@ -856,24 +956,22 @@ function shapeOf(frets, info, targets, tuning, fingers) {
|
|
|
856
956
|
continue;
|
|
857
957
|
if (!sounding.every((s) => target.has((tuning[s] + moved[s]) % 12)))
|
|
858
958
|
continue;
|
|
859
|
-
|
|
860
|
-
return barre ? `${letter}-shape barre` : `CAGED ${letter}`;
|
|
861
|
-
return `CAGED ${letter}`;
|
|
959
|
+
return `${letter} shape`;
|
|
862
960
|
}
|
|
863
961
|
}
|
|
864
962
|
}
|
|
865
|
-
return
|
|
963
|
+
return null;
|
|
866
964
|
}
|
|
867
|
-
function voicingShape(frets, symbol, tuning = STANDARD_TUNING,
|
|
965
|
+
function voicingShape(frets, symbol, tuning = STANDARD_TUNING, _fingers) {
|
|
868
966
|
const info = chordInfo(symbol);
|
|
869
|
-
return info ? shapeOf(frets, info, cagedTargets(info), tuning
|
|
967
|
+
return info ? shapeOf(frets, info, cagedTargets(info), tuning) : null;
|
|
870
968
|
}
|
|
871
969
|
var KNOWN_SHAPES = new Set([
|
|
872
|
-
"
|
|
873
|
-
"
|
|
874
|
-
"
|
|
875
|
-
"
|
|
876
|
-
"
|
|
970
|
+
"C shape",
|
|
971
|
+
"A shape",
|
|
972
|
+
"G shape",
|
|
973
|
+
"E shape",
|
|
974
|
+
"D shape",
|
|
877
975
|
"Power chord"
|
|
878
976
|
]);
|
|
879
977
|
var indexOf = (number, count) => count - number;
|
|
@@ -927,6 +1025,8 @@ function generateVoicings(symbol, options = {}) {
|
|
|
927
1025
|
const last = sounding[sounding.length - 1];
|
|
928
1026
|
const inner = last - first + 1 - sounding.length;
|
|
929
1027
|
const pitches = sounding.map((s) => tuning[s] + candidate[s]);
|
|
1028
|
+
if (ascending && new Set(pitches).size < pitches.length)
|
|
1029
|
+
return null;
|
|
930
1030
|
const chromas = new Set(pitches.map((p) => p % 12));
|
|
931
1031
|
if (sounding.length <= 3 && chromas.size < Math.min(sounding.length, tones.length)) {
|
|
932
1032
|
return null;
|
|
@@ -942,7 +1042,7 @@ function generateVoicings(symbol, options = {}) {
|
|
|
942
1042
|
if (!fingering)
|
|
943
1043
|
return null;
|
|
944
1044
|
const { fingers } = fingering;
|
|
945
|
-
const shape = shapeOf(candidate, info, targets, tuning
|
|
1045
|
+
const shape = shapeOf(candidate, info, targets, tuning);
|
|
946
1046
|
const fretted = sounding.map((s) => candidate[s]).filter((f) => f > 0);
|
|
947
1047
|
const span = fretted.length ? Math.max(...fretted) - Math.min(...fretted) + 1 : 0;
|
|
948
1048
|
const used = new Set(fingers.filter(Boolean)).size;
|
|
@@ -950,9 +1050,9 @@ function generateVoicings(symbol, options = {}) {
|
|
|
950
1050
|
const base = baseFretOf(candidate);
|
|
951
1051
|
const reasons = [];
|
|
952
1052
|
const usual = standard && OPEN_CHORDS.has(compact(candidate));
|
|
953
|
-
let difficulty = used + Math.max(0, span - 1) + base * 0.
|
|
1053
|
+
let difficulty = used + Math.max(0, span - 1) + base * 0.3;
|
|
954
1054
|
if (barre) {
|
|
955
|
-
difficulty += shape
|
|
1055
|
+
difficulty += isBarreShape(shape) || !fingering.fullBarre ? 1 : 3;
|
|
956
1056
|
reasons.push("barre");
|
|
957
1057
|
}
|
|
958
1058
|
const notes = sounding.filter((s) => candidate[s] > 0);
|
|
@@ -973,10 +1073,12 @@ function generateVoicings(symbol, options = {}) {
|
|
|
973
1073
|
difficulty += 2 * inner;
|
|
974
1074
|
reasons.push("muted inner string");
|
|
975
1075
|
}
|
|
1076
|
+
const strings = [...allowed];
|
|
976
1077
|
if (!power) {
|
|
977
|
-
const strings = [...allowed];
|
|
978
1078
|
difficulty += strings.filter((s) => s < first).length;
|
|
979
1079
|
difficulty += 1.5 * strings.filter((s) => s > last).length;
|
|
1080
|
+
} else if (ascending) {
|
|
1081
|
+
difficulty += 1.5 * strings.filter((s) => s < first).length;
|
|
980
1082
|
}
|
|
981
1083
|
if (sounding.length < 4 && !power)
|
|
982
1084
|
reasons.push("thin");
|
|
@@ -999,7 +1101,7 @@ function generateVoicings(symbol, options = {}) {
|
|
|
999
1101
|
}
|
|
1000
1102
|
if (usual)
|
|
1001
1103
|
difficulty -= 3;
|
|
1002
|
-
else if (shape
|
|
1104
|
+
else if (isBarreShape(shape) && barre)
|
|
1003
1105
|
difficulty -= 2;
|
|
1004
1106
|
else if (shape && KNOWN_SHAPES.has(shape))
|
|
1005
1107
|
difficulty -= 1.5;
|
|
@@ -1053,9 +1155,160 @@ function generateVoicings(symbol, options = {}) {
|
|
|
1053
1155
|
return [...results.values()].sort((a, b) => a.difficulty - b.difficulty || sounding(b) - sounding(a) || a.baseFret - b.baseFret || a.frets.join(",").localeCompare(b.frets.join(",")));
|
|
1054
1156
|
}
|
|
1055
1157
|
|
|
1158
|
+
// src/voicings/check.ts
|
|
1159
|
+
var chromaAt = (frets, s) => (STANDARD_TUNING[s] + frets[s]) % 12;
|
|
1160
|
+
var ALT_CORE = [4, 10];
|
|
1161
|
+
var ALT_TENSIONS = [6, 8, 1, 3];
|
|
1162
|
+
function voicingProblem(symbol, frets) {
|
|
1163
|
+
const info = chordInfo(symbol);
|
|
1164
|
+
if (!info)
|
|
1165
|
+
return `${symbol} is not a chord the library reads`;
|
|
1166
|
+
if (frets.length !== STANDARD_TUNING.length)
|
|
1167
|
+
return "not six strings";
|
|
1168
|
+
const sounding = frets.flatMap((f, s) => f === null ? [] : [s]);
|
|
1169
|
+
if (sounding.length < 2)
|
|
1170
|
+
return "fewer than two strings sound";
|
|
1171
|
+
const chromas = new Set(sounding.map((s) => chromaAt(frets, s)));
|
|
1172
|
+
const { root } = info;
|
|
1173
|
+
let allowed;
|
|
1174
|
+
let required;
|
|
1175
|
+
if (info.suffix === "7alt") {
|
|
1176
|
+
required = [root, ...ALT_CORE.map((i) => (root + i) % 12)];
|
|
1177
|
+
const tensions = ALT_TENSIONS.map((i) => (root + i) % 12);
|
|
1178
|
+
allowed = [...required, ...tensions];
|
|
1179
|
+
if (!tensions.some((c) => chromas.has(c)))
|
|
1180
|
+
return "no altered fifth or ninth";
|
|
1181
|
+
} else {
|
|
1182
|
+
allowed = info.tones.map((t) => t.chroma);
|
|
1183
|
+
required = info.tones.filter((t) => t.required).map((t) => t.chroma);
|
|
1184
|
+
}
|
|
1185
|
+
const extra = [...chromas].filter((c) => !allowed.includes(c));
|
|
1186
|
+
if (extra.length)
|
|
1187
|
+
return `plays ${extra.map((c) => nameOf(c)).join(", ")}, not in the chord`;
|
|
1188
|
+
const missing = required.filter((c) => !chromas.has(c));
|
|
1189
|
+
if (missing.length)
|
|
1190
|
+
return `misses ${missing.map((c) => nameOf(c)).join(", ")}`;
|
|
1191
|
+
const pitches = sounding.map((s) => STANDARD_TUNING[s] + frets[s]);
|
|
1192
|
+
const bass = Math.min(...pitches) % 12;
|
|
1193
|
+
const wanted = info.bass ?? root;
|
|
1194
|
+
const anyBass = info.suffix === "dim7" && info.bass === null;
|
|
1195
|
+
if (bass !== wanted && !anyBass)
|
|
1196
|
+
return `has ${nameOf(bass)} in the bass, not ${nameOf(wanted)}`;
|
|
1197
|
+
if (new Set(pitches).size < pitches.length)
|
|
1198
|
+
return "plays one pitch on two strings";
|
|
1199
|
+
if (!fingerVoicing(frets))
|
|
1200
|
+
return "no hand can play it";
|
|
1201
|
+
return null;
|
|
1202
|
+
}
|
|
1203
|
+
function fingeringProblem(frets, fingers) {
|
|
1204
|
+
const strings = new Map;
|
|
1205
|
+
for (let s = 0;s < frets.length; s++) {
|
|
1206
|
+
const fret = frets[s];
|
|
1207
|
+
const finger = fingers[s] ?? null;
|
|
1208
|
+
if (!fret) {
|
|
1209
|
+
if (finger !== null)
|
|
1210
|
+
return `a finger on an open or muted string`;
|
|
1211
|
+
continue;
|
|
1212
|
+
}
|
|
1213
|
+
const n = Number(finger);
|
|
1214
|
+
if (!(n >= 1 && n <= 4))
|
|
1215
|
+
return `no finger on a fretted string`;
|
|
1216
|
+
strings.set(n, [...strings.get(n) ?? [], s]);
|
|
1217
|
+
}
|
|
1218
|
+
const fretOf = new Map;
|
|
1219
|
+
for (const [finger, list] of strings) {
|
|
1220
|
+
const fret = frets[list[0]];
|
|
1221
|
+
if (list.some((s) => frets[s] !== fret))
|
|
1222
|
+
return `finger ${finger} on two frets`;
|
|
1223
|
+
if (list.length > 1) {
|
|
1224
|
+
const topTwo = list.length === 2 && list[0] === frets.length - 2 && list[1] === frets.length - 1;
|
|
1225
|
+
if (finger !== 1 && finger !== 3 && !(finger === 4 && topTwo))
|
|
1226
|
+
return `a barre with finger ${finger}`;
|
|
1227
|
+
for (let s = list[0];s <= list[list.length - 1]; s++) {
|
|
1228
|
+
const f = frets[s];
|
|
1229
|
+
if (f === null || f === undefined || f < fret || f > fret && finger !== 1)
|
|
1230
|
+
return `finger ${finger} barres over a string it can't`;
|
|
1231
|
+
}
|
|
1232
|
+
}
|
|
1233
|
+
fretOf.set(finger, fret);
|
|
1234
|
+
}
|
|
1235
|
+
const used = [...fretOf].sort((a, b) => a[0] - b[0]);
|
|
1236
|
+
for (let i = 1;i < used.length; i++) {
|
|
1237
|
+
if (used[i][1] < used[i - 1][1])
|
|
1238
|
+
return `finger ${used[i][0]} below finger ${used[i - 1][0]}`;
|
|
1239
|
+
}
|
|
1240
|
+
return null;
|
|
1241
|
+
}
|
|
1242
|
+
|
|
1243
|
+
// src/voicings/curated.ts
|
|
1244
|
+
var HENDRIX = {
|
|
1245
|
+
C: ["x3234x"],
|
|
1246
|
+
"C#": ["x4345x"],
|
|
1247
|
+
D: ["x5456x"],
|
|
1248
|
+
Eb: ["x6567x"],
|
|
1249
|
+
E: ["x7678x", "076780"],
|
|
1250
|
+
F: ["x8789x"],
|
|
1251
|
+
"F#": ["x-9-8-9-10-x"],
|
|
1252
|
+
G: ["x-10-9-10-11-x"],
|
|
1253
|
+
Ab: ["x-11-10-11-12-x"],
|
|
1254
|
+
A: ["x-12-11-12-13-x"],
|
|
1255
|
+
Bb: ["x1012x"],
|
|
1256
|
+
B: ["x2123x"]
|
|
1257
|
+
};
|
|
1258
|
+
var POWER = {
|
|
1259
|
+
C: "x355xx -134--",
|
|
1260
|
+
"C#": "x466xx -134--",
|
|
1261
|
+
D: "xx023x ---13-",
|
|
1262
|
+
Eb: "x688xx -134--",
|
|
1263
|
+
E: "022xxx -12---",
|
|
1264
|
+
F: "133xxx 134---",
|
|
1265
|
+
"F#": "244xxx 134---",
|
|
1266
|
+
G: "355xxx 134---",
|
|
1267
|
+
Ab: "466xxx 134---",
|
|
1268
|
+
A: "x022xx --12--",
|
|
1269
|
+
Bb: "x133xx -134--",
|
|
1270
|
+
B: "x244xx -134--"
|
|
1271
|
+
};
|
|
1272
|
+
var CURATED = {
|
|
1273
|
+
"C#": ["x46664"],
|
|
1274
|
+
Eb: ["x68886", "xx1343"],
|
|
1275
|
+
Ab: ["466544"],
|
|
1276
|
+
Cm: ["x35543"],
|
|
1277
|
+
"C#m": ["x46654"],
|
|
1278
|
+
Ebm: ["x68876"],
|
|
1279
|
+
Gm: ["355333"],
|
|
1280
|
+
"C#7": ["x46464"],
|
|
1281
|
+
Eb7: ["x68686"],
|
|
1282
|
+
Cm7: ["x35343"],
|
|
1283
|
+
Ebm7: ["x68676"],
|
|
1284
|
+
"C#maj7": ["x46564"],
|
|
1285
|
+
"C#sus4": ["x46674"],
|
|
1286
|
+
B6: ["x24444"],
|
|
1287
|
+
Eb9: ["x65666"],
|
|
1288
|
+
G9: ["353435"],
|
|
1289
|
+
Cmaj7: ["x32000 -32---"],
|
|
1290
|
+
Dm7: ["xx0211 ---211"],
|
|
1291
|
+
A9: ["x02423", "575657"],
|
|
1292
|
+
Fsus2: ["xx3011"],
|
|
1293
|
+
"F#sus2": ["xx4674"],
|
|
1294
|
+
Absus2: ["xx6896"],
|
|
1295
|
+
Ddim: ["xx0131"],
|
|
1296
|
+
Ebdim: ["xx1242"],
|
|
1297
|
+
Edim: ["xx2353"],
|
|
1298
|
+
Fdim: ["xx3464"],
|
|
1299
|
+
Gm7b5: ["3x332x"],
|
|
1300
|
+
"C#aug": ["x4322x"],
|
|
1301
|
+
"Am/G": ["3x2210", "302210"],
|
|
1302
|
+
"E/G#": ["422100"],
|
|
1303
|
+
...Object.fromEntries(Object.entries(HENDRIX).map(([root, list]) => [`${root}7#9`, list])),
|
|
1304
|
+
...Object.fromEntries(Object.entries(HENDRIX).map(([root, list]) => [`${root}7alt`, list])),
|
|
1305
|
+
...Object.fromEntries(Object.entries(POWER).map(([root, shape]) => [`${root}5`, [shape]]))
|
|
1306
|
+
};
|
|
1307
|
+
|
|
1056
1308
|
// src/voicings/index.ts
|
|
1057
1309
|
var DB_KEYS = ["C", "Csharp", "D", "Eb", "E", "F", "Fsharp", "G", "Ab", "A", "Bb", "B"];
|
|
1058
1310
|
var DB_BASSES = ["C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "Bb", "B"];
|
|
1311
|
+
var NAMES = ["C", "C#", "D", "Eb", "E", "F", "F#", "G", "Ab", "A", "Bb", "B"];
|
|
1059
1312
|
var DB_SUFFIXES = {
|
|
1060
1313
|
"": "major",
|
|
1061
1314
|
m: "minor",
|
|
@@ -1063,8 +1316,11 @@ var DB_SUFFIXES = {
|
|
|
1063
1316
|
mMaj9: "mmaj9",
|
|
1064
1317
|
M7b5: "maj7b5",
|
|
1065
1318
|
"7alt": "alt",
|
|
1066
|
-
"6/9": "69"
|
|
1319
|
+
"6/9": "69",
|
|
1320
|
+
"7#5": "aug7",
|
|
1321
|
+
"9#5": "aug9"
|
|
1067
1322
|
};
|
|
1323
|
+
var GENERATED_PER_CHORD = 4;
|
|
1068
1324
|
var lookupGuitarVoicing = (symbol, index) => {
|
|
1069
1325
|
const parts = splitChordSymbol(symbol);
|
|
1070
1326
|
if (!parts)
|
|
@@ -1077,29 +1333,93 @@ var lookupGuitarVoicing = (symbol, index) => {
|
|
|
1077
1333
|
const bassChroma = parts.bass ? chromaOf(parts.bass) : null;
|
|
1078
1334
|
const bass = bassChroma === null ? null : DB_BASSES[bassChroma];
|
|
1079
1335
|
const wanted = bass ? `${suffix === "major" ? "" : suffix === "minor" ? "m" : suffix}/${bass}` : suffix;
|
|
1080
|
-
const
|
|
1081
|
-
const chord = chords.find((c) => c.suffix === wanted);
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1336
|
+
const key = `${NAMES[chroma]}${canonical}${bass ? `/${bass}` : ""}`;
|
|
1337
|
+
const chord = (guitar_default.chords[DB_KEYS[chroma]] ?? []).find((c) => c.suffix === wanted);
|
|
1338
|
+
const list = chord || CURATED[key] ? checked(key, chord) : generated(symbol).slice(0, GENERATED_PER_CHORD);
|
|
1339
|
+
const found = list[index];
|
|
1340
|
+
return found ? { ...found, frets: [...found.frets], fingers: [...found.fingers] } : null;
|
|
1341
|
+
};
|
|
1342
|
+
var compact2 = (frets) => frets.map((f) => f === null ? "x" : f).join(",");
|
|
1343
|
+
function parseFrets2(text) {
|
|
1344
|
+
return (text.includes("-") ? text.split("-") : [...text]).map((t) => t === "x" ? null : Number(t));
|
|
1345
|
+
}
|
|
1346
|
+
function voicing(frets, fingers) {
|
|
1347
|
+
const kept = fingers && !fingeringProblem(frets, fingers) ? fingers : fingerVoicing(frets);
|
|
1348
|
+
return kept ? { frets, fingers: kept, baseFret: baseFretOf(frets) } : null;
|
|
1349
|
+
}
|
|
1350
|
+
function repaired(symbol, frets) {
|
|
1351
|
+
if (!voicingProblem(symbol, frets))
|
|
1352
|
+
return frets;
|
|
1353
|
+
const fewest = /^[A-G][#b]?5$/.test(symbol) ? 2 : 4;
|
|
1354
|
+
const next = [...frets];
|
|
1355
|
+
for (;; ) {
|
|
1356
|
+
const lowest = next.findIndex((f) => f !== null);
|
|
1357
|
+
next[lowest] = null;
|
|
1358
|
+
if (next.filter((f) => f !== null).length < fewest)
|
|
1359
|
+
return null;
|
|
1360
|
+
const problem = voicingProblem(symbol, next);
|
|
1361
|
+
if (!problem)
|
|
1362
|
+
return next;
|
|
1363
|
+
if (problem.startsWith("misses") || problem.startsWith("no altered"))
|
|
1364
|
+
return null;
|
|
1085
1365
|
}
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
const
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1366
|
+
}
|
|
1367
|
+
var checkedCache = new Map;
|
|
1368
|
+
function checked(key, chord) {
|
|
1369
|
+
const hit = checkedCache.get(key);
|
|
1370
|
+
if (hit)
|
|
1371
|
+
return hit;
|
|
1372
|
+
if (!chordInfo(key)) {
|
|
1373
|
+
const raw = (chord?.positions ?? []).map((position) => ({
|
|
1374
|
+
frets: position.frets.map((f) => f < 0 ? null : f === 0 ? 0 : f + position.baseFret - 1),
|
|
1375
|
+
fingers: position.fingers.map((f) => f > 0 ? String(f) : null),
|
|
1376
|
+
baseFret: position.baseFret
|
|
1377
|
+
}));
|
|
1378
|
+
checkedCache.set(key, raw);
|
|
1379
|
+
return raw;
|
|
1380
|
+
}
|
|
1381
|
+
const list = [];
|
|
1382
|
+
const seen = new Set;
|
|
1383
|
+
const add = (v) => {
|
|
1384
|
+
if (!v || seen.has(compact2(v.frets)) || voicingProblem(key, v.frets))
|
|
1385
|
+
return;
|
|
1386
|
+
seen.add(compact2(v.frets));
|
|
1387
|
+
list.push(v);
|
|
1094
1388
|
};
|
|
1095
|
-
|
|
1096
|
-
|
|
1389
|
+
for (const entry of CURATED[key] ?? []) {
|
|
1390
|
+
const [frets, fingers] = entry.split(" ");
|
|
1391
|
+
add(voicing(parseFrets2(frets), fingers ? [...fingers].map((f) => f === "-" ? null : f) : null));
|
|
1392
|
+
}
|
|
1393
|
+
for (const position of chord?.positions ?? []) {
|
|
1394
|
+
const absolute = position.frets.map((f) => f < 0 ? null : f === 0 ? 0 : f + position.baseFret - 1);
|
|
1395
|
+
const frets = repaired(key, absolute);
|
|
1396
|
+
if (!frets)
|
|
1397
|
+
continue;
|
|
1398
|
+
const fingers = position.fingers.map((f, s) => f > 0 && frets[s] ? String(f) : null);
|
|
1399
|
+
const same = frets.every((f, s) => f === absolute[s]);
|
|
1400
|
+
const v = voicing(frets, fingers);
|
|
1401
|
+
add(v && same ? { ...v, baseFret: position.baseFret } : v);
|
|
1402
|
+
}
|
|
1403
|
+
const count = Math.max(chord?.positions.length ?? 0, GENERATED_PER_CHORD);
|
|
1404
|
+
if (list.length < count) {
|
|
1405
|
+
for (const v of generated(key)) {
|
|
1406
|
+
if (list.length >= count)
|
|
1407
|
+
break;
|
|
1408
|
+
const lower = v.frets.map((f) => f === null ? null : f - 12);
|
|
1409
|
+
if (lower.every((f) => f === null || f > 0) && seen.has(compact2(lower)))
|
|
1410
|
+
continue;
|
|
1411
|
+
add({ frets: v.frets, fingers: v.fingers, baseFret: v.baseFret });
|
|
1412
|
+
}
|
|
1413
|
+
}
|
|
1414
|
+
checkedCache.set(key, list);
|
|
1415
|
+
return list;
|
|
1416
|
+
}
|
|
1097
1417
|
var generatedCache = new Map;
|
|
1098
1418
|
function generated(symbol) {
|
|
1099
1419
|
const hit = generatedCache.get(symbol);
|
|
1100
1420
|
if (hit)
|
|
1101
1421
|
return hit;
|
|
1102
|
-
const list = generateVoicings(symbol).slice(0,
|
|
1422
|
+
const list = generateVoicings(symbol).slice(0, 12).map(({ frets, fingers, baseFret }) => ({ frets, fingers, baseFret }));
|
|
1103
1423
|
generatedCache.set(symbol, list);
|
|
1104
1424
|
if (generatedCache.size > 64)
|
|
1105
1425
|
generatedCache.delete(generatedCache.keys().next().value);
|
|
@@ -1116,5 +1436,5 @@ export {
|
|
|
1116
1436
|
voicingCount
|
|
1117
1437
|
};
|
|
1118
1438
|
|
|
1119
|
-
//# debugId=
|
|
1439
|
+
//# debugId=CB5AD4C94F1007E464756E2164756E21
|
|
1120
1440
|
//# sourceMappingURL=index.js.map
|