@dsebastien/music-notation 0.17.0 → 0.18.1
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 +1 -1
- package/dist/chord/fingering-words.d.ts +7 -0
- package/dist/chord/transitions.d.ts +5 -0
- package/dist/index.js +37 -40
- package/dist/index.js.map +9 -9
- package/dist/music-notation.css +3 -15
- package/dist/music-notation.publish.min.js +31 -43
- package/dist/music-notation.tab.min.js +10 -22
- package/dist/playback/bar-parts.d.ts +1 -0
- package/dist/publish/index.js +34 -25
- package/dist/publish/index.js.map +9 -9
- package/dist/tab/auto.d.ts +1 -0
- package/dist/tab/index.d.ts +5 -0
- package/dist/tab/index.js +167 -83
- package/dist/tab/index.js.map +6 -4
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -186,7 +186,7 @@ Add this to your site's `publish.js`. It loads the bundle only on pages that hav
|
|
|
186
186
|
|
|
187
187
|
```js
|
|
188
188
|
;(() => {
|
|
189
|
-
const VERSION = '0.
|
|
189
|
+
const VERSION = '0.18.1'
|
|
190
190
|
const CDN = `https://cdn.jsdelivr.net/npm/@dsebastien/music-notation@${VERSION}/dist`
|
|
191
191
|
const selector = (languages) => languages.map((l) => `pre > code.language-${l}`).join(', ')
|
|
192
192
|
const BLOCKS = selector([
|
|
@@ -22,6 +22,13 @@ export interface PianoFingering {
|
|
|
22
22
|
/** Spelling per pitch class (C# or Db), as the chord spells its notes; sharps when absent. */
|
|
23
23
|
names?: ReadonlyMap<number, string>;
|
|
24
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* What players call each string. When every name is different, or only the two outer strings share
|
|
27
|
+
* one (low E and high E), by name: "the A string", "the low E string". Otherwise (drop D, DADGAD,
|
|
28
|
+
* open tunings) two strings could read alike, so every string is named by its number and note:
|
|
29
|
+
* "the 4th string (D)". Without a tuning, numbers only.
|
|
30
|
+
*/
|
|
31
|
+
export declare function stringNames(tuning: readonly number[] | null, count: number, spelled?: readonly string[]): string[];
|
|
25
32
|
/**
|
|
26
33
|
* The fingering of a chord in plain sentences, in the order a player sets the hand: for a fretted
|
|
27
34
|
* chord the capo, the strings to strum, barres and fingers (low string first), muted strings
|
|
@@ -25,6 +25,9 @@ export interface TransitionOptions {
|
|
|
25
25
|
fromFingers?: (string | null)[];
|
|
26
26
|
/** How many of the next chord's easiest voicings to consider (30 by default). */
|
|
27
27
|
candidates?: number;
|
|
28
|
+
/** The open strings' names as the tuning is written (Eb Ab Db…, see `tuningNames`): tips
|
|
29
|
+
* spell them so; else from the pitches, with sharps. */
|
|
30
|
+
tuningNames?: readonly string[];
|
|
28
31
|
}
|
|
29
32
|
/**
|
|
30
33
|
* The next chord's voicings, ranked by how easily the hand gets there from the one it holds:
|
|
@@ -41,6 +44,8 @@ export interface ProgressionOptions {
|
|
|
41
44
|
tuning?: number[];
|
|
42
45
|
/** How many of each chord's easiest voicings to weigh (12 by default). */
|
|
43
46
|
candidates?: number;
|
|
47
|
+
/** The open strings' names as the tuning is written (see `TransitionOptions`). */
|
|
48
|
+
tuningNames?: readonly string[];
|
|
44
49
|
/** The voicing database (see `/voicings`): its voicings of each chord are weighed too, and
|
|
45
50
|
* preferred. Only used in standard tuning. */
|
|
46
51
|
voicings?: VoicingLookup;
|
package/dist/index.js
CHANGED
|
@@ -1820,10 +1820,10 @@ var STACKED = {
|
|
|
1820
1820
|
"3M 5P 7M": "maj7",
|
|
1821
1821
|
"3M 5P 7m": "7",
|
|
1822
1822
|
"3m 5P 7m": "m7",
|
|
1823
|
-
"3m 5P 7M": "
|
|
1823
|
+
"3m 5P 7M": "m(maj7)",
|
|
1824
1824
|
"3m 5d 7m": "m7b5",
|
|
1825
1825
|
"3m 5d 7d": "dim7",
|
|
1826
|
-
"3M 5A 7M": "maj7
|
|
1826
|
+
"3M 5A 7M": "+maj7",
|
|
1827
1827
|
"3M 5A 7m": "7#5",
|
|
1828
1828
|
"3M 5d 7m": "7b5"
|
|
1829
1829
|
};
|
|
@@ -1852,14 +1852,18 @@ function numeralQuality(suffix) {
|
|
|
1852
1852
|
case "aug":
|
|
1853
1853
|
return { lower: false, mark: "+" };
|
|
1854
1854
|
case "mMaj7":
|
|
1855
|
-
|
|
1855
|
+
case "m(maj7)":
|
|
1856
|
+
return { lower: true, mark: "(maj7)" };
|
|
1857
|
+
case "maj7#5":
|
|
1858
|
+
case "+maj7":
|
|
1859
|
+
return { lower: false, mark: "+maj7" };
|
|
1856
1860
|
}
|
|
1857
1861
|
if (/^m(?!aj)/.test(suffix))
|
|
1858
1862
|
return { lower: true, mark: suffix.slice(1) };
|
|
1859
1863
|
return { lower: false, mark: suffix };
|
|
1860
1864
|
}
|
|
1861
1865
|
function nashvilleQuality(suffix) {
|
|
1862
|
-
return { dim: "°", dim7: "°7", m7b5: "ø7", aug: "+" }[suffix] ?? (suffix === "mMaj7" ? "
|
|
1866
|
+
return { dim: "°", dim7: "°7", m7b5: "ø7", aug: "+" }[suffix] ?? (suffix === "mMaj7" ? "m(maj7)" : suffix === "maj7#5" ? "+maj7" : suffix);
|
|
1863
1867
|
}
|
|
1864
1868
|
function degreeOf(tonic, note, minorKey = false) {
|
|
1865
1869
|
if (chromaOf(note) === null || chromaOf(tonic) === null)
|
|
@@ -4374,7 +4378,9 @@ function followNotes(win, drawing, targets, events, wait = START_WAIT) {
|
|
|
4374
4378
|
}
|
|
4375
4379
|
|
|
4376
4380
|
// src/playback/live-volume.ts
|
|
4377
|
-
var
|
|
4381
|
+
var REGISTRY = Symbol.for("@dsebastien/music-notation/volume");
|
|
4382
|
+
var shared = globalThis;
|
|
4383
|
+
var listeners = shared[REGISTRY] ??= new Set;
|
|
4378
4384
|
var level = (value) => typeof value === "number" && Number.isFinite(value) ? Math.min(1, Math.max(0, value)) : null;
|
|
4379
4385
|
function volumeChanged() {
|
|
4380
4386
|
for (const listener of [...listeners]) {
|
|
@@ -5141,6 +5147,7 @@ function renderFretboard(doc, set, options = {}) {
|
|
|
5141
5147
|
// src/playback/bar-parts.ts
|
|
5142
5148
|
var ICONS = {
|
|
5143
5149
|
play: "M4 2.5v11l9-5.5z",
|
|
5150
|
+
pause: "M4 3h3v10H4zM9 3h3v10H9z",
|
|
5144
5151
|
stop: "M4 4h8v8H4z",
|
|
5145
5152
|
all: "M1.5 2.5v11l6.5-5.5zM8 2.5v11l6.5-5.5z",
|
|
5146
5153
|
loop: "M3 8a5 5 0 0 1 8.5-3.5L13 6V2.5M13 8a5 5 0 0 1-8.5 3.5L3 10v3.5",
|
|
@@ -8660,21 +8667,12 @@ var FINGER_NAMES = {
|
|
|
8660
8667
|
};
|
|
8661
8668
|
var ordinal2 = (n) => `${n}${n % 100 >= 11 && n % 100 <= 13 ? "th" : ["th", "st", "nd", "rd"][n % 10] ?? "th"}`;
|
|
8662
8669
|
var MAX_SLIDE = 3;
|
|
8663
|
-
|
|
8664
|
-
const name = noteOf(tuning[s]).replace(/-?\d+$/, "");
|
|
8665
|
-
const same = tuning.filter((p) => noteOf(p).replace(/-?\d+$/, "") === name).length;
|
|
8666
|
-
if (same < 2)
|
|
8667
|
-
return `the ${name} string`;
|
|
8668
|
-
if (same > 2)
|
|
8669
|
-
return `the ${ordinal2(tuning.length - s)} string (${name})`;
|
|
8670
|
-
const lowest = tuning.findIndex((p) => noteOf(p).replace(/-?\d+$/, "") === name);
|
|
8671
|
-
return `the ${s === lowest ? "low" : "high"} ${name} string`;
|
|
8672
|
-
}
|
|
8670
|
+
var namesOf2 = (tuning, spelled) => stringNames(tuning, tuning.length, spelled?.length === tuning.length ? spelled : undefined);
|
|
8673
8671
|
var lowestFret2 = (frets) => {
|
|
8674
8672
|
const fretted = frets.filter((f) => f !== null && f > 0);
|
|
8675
8673
|
return fretted.length ? Math.min(...fretted) : 0;
|
|
8676
8674
|
};
|
|
8677
|
-
function move(from, fromFingers, to,
|
|
8675
|
+
function move(from, fromFingers, to, names) {
|
|
8678
8676
|
const anchors = [];
|
|
8679
8677
|
const guides = [];
|
|
8680
8678
|
let movement = 0;
|
|
@@ -8707,14 +8705,14 @@ function move(from, fromFingers, to, tuning) {
|
|
|
8707
8705
|
if (seen.has(f))
|
|
8708
8706
|
continue;
|
|
8709
8707
|
seen.add(f);
|
|
8710
|
-
tips.push(`Keep your ${fingerName(f)} on ${
|
|
8708
|
+
tips.push(`Keep your ${fingerName(f)} on ${names[s]}'s ${ordinal2(to.frets[s])} fret.`);
|
|
8711
8709
|
}
|
|
8712
8710
|
for (const s of guides) {
|
|
8713
8711
|
const f = to.fingers[s];
|
|
8714
8712
|
if (seen.has(f))
|
|
8715
8713
|
continue;
|
|
8716
8714
|
seen.add(f);
|
|
8717
|
-
tips.push(`Slide your ${fingerName(f)} along ${
|
|
8715
|
+
tips.push(`Slide your ${fingerName(f)} along ${names[s]} from fret ${from[s]} to ${to.frets[s]}.`);
|
|
8718
8716
|
}
|
|
8719
8717
|
if (shift >= 2) {
|
|
8720
8718
|
const up = lowestFret2(to.frets) > lowestFret2(from);
|
|
@@ -8731,8 +8729,9 @@ function transition(from, toChord, options = {}) {
|
|
|
8731
8729
|
if (from.length !== tuning.length)
|
|
8732
8730
|
return [];
|
|
8733
8731
|
const fromFingers = options.fromFingers ?? fingerVoicing(from) ?? from.map(() => null);
|
|
8732
|
+
const names = namesOf2(tuning, options.tuningNames);
|
|
8734
8733
|
const candidates = generateVoicings(toChord, { tuning }).slice(0, options.candidates ?? 30);
|
|
8735
|
-
return candidates.map((voicing) => ({ voicing, ...move(from, fromFingers, voicing,
|
|
8734
|
+
return candidates.map((voicing) => ({ voicing, ...move(from, fromFingers, voicing, names) })).sort((a, b) => score(a, a.voicing) - score(b, b.voicing));
|
|
8736
8735
|
}
|
|
8737
8736
|
var DATABASE_VOICINGS = 6;
|
|
8738
8737
|
var HIGH_POSITION = 5;
|
|
@@ -8784,6 +8783,7 @@ function candidatesOf(symbol, tuning, count, voicings) {
|
|
|
8784
8783
|
var sameTuning4 = (a, b) => a.length === b.length && a.every((p, i) => p === b[i]);
|
|
8785
8784
|
function smoothProgression(chords, options = {}) {
|
|
8786
8785
|
const tuning = options.tuning ?? STANDARD_TUNING;
|
|
8786
|
+
const names = namesOf2(tuning, options.tuningNames);
|
|
8787
8787
|
const count = options.candidates ?? 12;
|
|
8788
8788
|
const cache = new Map;
|
|
8789
8789
|
const lists = chords.map((c) => {
|
|
@@ -8804,7 +8804,7 @@ function smoothProgression(chords, options = {}) {
|
|
|
8804
8804
|
let best = Infinity;
|
|
8805
8805
|
let from = 0;
|
|
8806
8806
|
prev.forEach((p, j) => {
|
|
8807
|
-
const step = move(p.voicing.frets, p.voicing.fingers, voicing,
|
|
8807
|
+
const step = move(p.voicing.frets, p.voicing.fingers, voicing, names);
|
|
8808
8808
|
const total = costs[j] + step.movement + SHAPE_WEIGHT * cost;
|
|
8809
8809
|
if (total < best) {
|
|
8810
8810
|
best = total;
|
|
@@ -8827,7 +8827,7 @@ function smoothProgression(chords, options = {}) {
|
|
|
8827
8827
|
return {
|
|
8828
8828
|
chord: chords[i],
|
|
8829
8829
|
voicing,
|
|
8830
|
-
...move(previous.frets, previous.fingers, voicing,
|
|
8830
|
+
...move(previous.frets, previous.fingers, voicing, names)
|
|
8831
8831
|
};
|
|
8832
8832
|
});
|
|
8833
8833
|
}
|
|
@@ -9061,6 +9061,8 @@ function noteOn(key, degree, accidental, diminished) {
|
|
|
9061
9061
|
function suffixOf(mark, lower) {
|
|
9062
9062
|
let s = mark.replace(/♭/g, "b").replace(/♯/g, "#");
|
|
9063
9063
|
s = s.replace(/^o/, "°").replace(/^Δ7?$/, "maj7").replace(/^M7$/, "maj7");
|
|
9064
|
+
if (lower)
|
|
9065
|
+
s = s.replace(/^\((maj\d*)\)$/, "$1").replace(/^m(?=[Mm]aj)/, "").replace(/^Maj/, "maj");
|
|
9064
9066
|
if (s === "°" || s === "dim")
|
|
9065
9067
|
return "dim";
|
|
9066
9068
|
if (s === "°7" || s === "dim7")
|
|
@@ -9082,8 +9084,10 @@ function suffixOf(mark, lower) {
|
|
|
9082
9084
|
return `m${s}`;
|
|
9083
9085
|
}
|
|
9084
9086
|
var isDiminished = (suffix) => /^(dim|m7b5)/.test(suffix);
|
|
9087
|
+
var USUAL = { mMaj7: "m(maj7)", "maj7#5": "+maj7" };
|
|
9085
9088
|
function chordFrom(root, suffix) {
|
|
9086
|
-
const
|
|
9089
|
+
const canonical = canonicalSuffix(suffix);
|
|
9090
|
+
const symbol = `${root}${USUAL[canonical] ?? canonical}`;
|
|
9087
9091
|
return parseChord(symbol) && chordNoteSet(symbol) ? symbol : null;
|
|
9088
9092
|
}
|
|
9089
9093
|
function bassOf(key, text) {
|
|
@@ -9576,7 +9580,8 @@ var SHARED = [
|
|
|
9576
9580
|
"tempo",
|
|
9577
9581
|
"bpm",
|
|
9578
9582
|
"strum",
|
|
9579
|
-
"harmonize"
|
|
9583
|
+
"harmonize",
|
|
9584
|
+
"caption"
|
|
9580
9585
|
];
|
|
9581
9586
|
var KIND_WORDS = {
|
|
9582
9587
|
triad: "triads",
|
|
@@ -9796,7 +9801,7 @@ function guitarVoicings(symbols, tuningText, voicings) {
|
|
|
9796
9801
|
var fretsText = (list) => list.some((f) => f !== null && f > 9) ? list.map((f) => f === null ? "x" : f).join("-") : list.map((f) => f === null ? "x" : f).join("");
|
|
9797
9802
|
function diagramBlock(block, lines) {
|
|
9798
9803
|
const fields = new Map(lines);
|
|
9799
|
-
for (const key of ["orientation", "hand", "labels", "tuning"]) {
|
|
9804
|
+
for (const key of ["orientation", "hand", "labels", "tuning", "caption"]) {
|
|
9800
9805
|
const value = field(block, key);
|
|
9801
9806
|
if (value !== undefined)
|
|
9802
9807
|
fields.set(key, value);
|
|
@@ -9862,6 +9867,10 @@ function renderSection(doc, section, options, renderChord) {
|
|
|
9862
9867
|
}
|
|
9863
9868
|
const piano = instrument !== "guitar";
|
|
9864
9869
|
const diagrams = yes(field(block, "diagrams"), "diagrams", true);
|
|
9870
|
+
const caption = field(block, "caption")?.trim();
|
|
9871
|
+
if (caption && !["fingering", "none", "no", "off", "false"].includes(caption.toLowerCase())) {
|
|
9872
|
+
throw new Error(`caption: use fingering (the fingering in words) or none, got "${caption}"`);
|
|
9873
|
+
}
|
|
9865
9874
|
const functions = yes(field(block, "functions"), "functions", false);
|
|
9866
9875
|
const leading = field(block, "voice-leading");
|
|
9867
9876
|
const led = yes(leading, "voice-leading", false);
|
|
@@ -12695,26 +12704,14 @@ var styles_default = `/* Music notation. Colors follow Obsidian's theme variable
|
|
|
12695
12704
|
pointer-events: none;
|
|
12696
12705
|
}
|
|
12697
12706
|
|
|
12698
|
-
/* Tabs and scores: the player bar
|
|
12707
|
+
/* Tabs and scores: the player bar is a bar like the others (#82), below the score and always
|
|
12708
|
+
shown; it also stays at the bottom of the screen while a long score scrolls. */
|
|
12699
12709
|
.mn-tab {
|
|
12700
12710
|
position: relative;
|
|
12701
12711
|
}
|
|
12702
12712
|
|
|
12703
|
-
.mn-tab .mn-tab-bar {
|
|
12704
|
-
position: sticky;
|
|
12705
|
-
left: auto;
|
|
12706
|
-
right: auto;
|
|
12713
|
+
.mn-tab .mn-play.mn-play-static.mn-tab-bar {
|
|
12707
12714
|
bottom: 6px;
|
|
12708
|
-
width: fit-content;
|
|
12709
|
-
max-width: 100%;
|
|
12710
|
-
margin: 4px auto 0;
|
|
12711
|
-
}
|
|
12712
|
-
|
|
12713
|
-
.mn-tab:hover .mn-tab-bar,
|
|
12714
|
-
.mn-tab:focus-within .mn-tab-bar,
|
|
12715
|
-
.mn-tab.mn-play-open .mn-tab-bar {
|
|
12716
|
-
opacity: 1;
|
|
12717
|
-
pointer-events: auto;
|
|
12718
12715
|
}
|
|
12719
12716
|
|
|
12720
12717
|
/* alphaTab's cursor (the bar that plays, the beat line) and the notes of the beat that sounds, in
|
|
@@ -14628,5 +14625,5 @@ export {
|
|
|
14628
14625
|
withTonicizations
|
|
14629
14626
|
};
|
|
14630
14627
|
|
|
14631
|
-
//# debugId=
|
|
14628
|
+
//# debugId=5534734ED808B8B764756E2164756E21
|
|
14632
14629
|
//# sourceMappingURL=index.js.map
|