@dsebastien/music-notation 0.10.1 → 0.11.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 +7 -4
- package/dist/blocks/properties.d.ts +2 -0
- package/dist/blocks/renderers.d.ts +11 -2
- package/dist/chord/generate.d.ts +13 -4
- package/dist/cli.js +3 -3
- package/dist/fretboard/exercise.d.ts +80 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +5741 -4108
- package/dist/index.js.map +28 -20
- package/dist/music-notation.css +88 -0
- package/dist/music-notation.publish.min.js +117 -24
- package/dist/music-notation.tab.min.js +95 -7
- package/dist/picking/pattern.d.ts +59 -0
- package/dist/picking/play.d.ts +87 -0
- package/dist/picking/render.d.ts +17 -0
- package/dist/picking/voicing.d.ts +19 -0
- package/dist/playback/picking-bar.d.ts +10 -0
- package/dist/playback/progression-bar.d.ts +8 -0
- package/dist/playback/progression.d.ts +111 -0
- package/dist/playback/strum-bar.d.ts +26 -1
- package/dist/publish/index.js +5399 -3882
- package/dist/publish/index.js.map +28 -20
- package/dist/strum/play.d.ts +18 -0
- package/dist/tab/index.d.ts +5 -0
- package/dist/tab/index.js +5 -1
- package/dist/tab/index.js.map +3 -3
- package/dist/voicings/index.js +96 -7
- package/dist/voicings/index.js.map +3 -3
- package/package.json +1 -1
package/dist/voicings/index.js
CHANGED
|
@@ -950,8 +950,7 @@ function shapeOf(frets, info, targets, tuning) {
|
|
|
950
950
|
return "Triad";
|
|
951
951
|
const fretted = sounding.map((s) => frets[s]).filter((f) => f > 0);
|
|
952
952
|
const open = sounding.some((s) => frets[s] === 0);
|
|
953
|
-
|
|
954
|
-
if (open && top && sounding.length >= 4 && (!fretted.length || Math.max(...fretted) <= 4)) {
|
|
953
|
+
if (open && sounding.length >= 4 && (!fretted.length || Math.max(...fretted) <= 4)) {
|
|
955
954
|
return "Open";
|
|
956
955
|
}
|
|
957
956
|
if (sameTuning(tuning, STANDARD_TUNING) && !open && fretted.length) {
|
|
@@ -977,9 +976,97 @@ function shapeOf(frets, info, targets, tuning) {
|
|
|
977
976
|
}
|
|
978
977
|
return null;
|
|
979
978
|
}
|
|
979
|
+
var OPEN_CHORD_FRETS = [...OPEN_CHORDS].map((t) => [...t].map((c) => c === "x" ? null : Number(c)));
|
|
980
|
+
function stringsText(sounding, count) {
|
|
981
|
+
const numbers = sounding.map((s) => count - s).sort((a, b) => a - b);
|
|
982
|
+
const runs = [];
|
|
983
|
+
for (let i = 0;i < numbers.length; ) {
|
|
984
|
+
let j = i;
|
|
985
|
+
while (j + 1 < numbers.length && numbers[j + 1] === numbers[j] + 1)
|
|
986
|
+
j++;
|
|
987
|
+
runs.push(i === j ? `${numbers[i]}` : `${numbers[i]}-${numbers[j]}`);
|
|
988
|
+
i = j + 1;
|
|
989
|
+
}
|
|
990
|
+
return runs.join(", ");
|
|
991
|
+
}
|
|
992
|
+
function cagedPartOf(frets, sounding, info) {
|
|
993
|
+
if (info.bass !== null || sounding.length < 3)
|
|
994
|
+
return null;
|
|
995
|
+
if (sounding.some((s) => frets[s] === 0))
|
|
996
|
+
return null;
|
|
997
|
+
for (const letter of ["E", "A", "C", "G", "D"]) {
|
|
998
|
+
const target = chordInfo(letter + info.suffix);
|
|
999
|
+
if (!target)
|
|
1000
|
+
continue;
|
|
1001
|
+
const tones = new Set(target.tones.map((t) => t.chroma));
|
|
1002
|
+
const base = ((info.root - chromaOf(letter)) % 12 + 12) % 12;
|
|
1003
|
+
for (const open of OPEN_CHORD_FRETS) {
|
|
1004
|
+
const strings = open.flatMap((f, s) => f === null ? [] : [s]);
|
|
1005
|
+
if (strings[0] !== CAGED_ROOT_STRING[letter] || strings.length <= sounding.length) {
|
|
1006
|
+
continue;
|
|
1007
|
+
}
|
|
1008
|
+
const chromas = strings.map((s) => (STANDARD_TUNING[s] + open[s]) % 12);
|
|
1009
|
+
if (chromas[0] !== chromaOf(letter))
|
|
1010
|
+
continue;
|
|
1011
|
+
if (!chromas.every((c) => tones.has(c)))
|
|
1012
|
+
continue;
|
|
1013
|
+
if (!target.tones.every((t) => !t.required || chromas.includes(t.chroma)))
|
|
1014
|
+
continue;
|
|
1015
|
+
for (const shift of [base, base + 12]) {
|
|
1016
|
+
if (shift === 0)
|
|
1017
|
+
continue;
|
|
1018
|
+
if (sounding.every((s) => open[s] !== null && frets[s] === open[s] + shift)) {
|
|
1019
|
+
return letter;
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
}
|
|
1023
|
+
}
|
|
1024
|
+
return null;
|
|
1025
|
+
}
|
|
1026
|
+
function dropOf(pitches) {
|
|
1027
|
+
if (pitches.length !== 4 || new Set(pitches.map((p) => p % 12)).size !== 4)
|
|
1028
|
+
return null;
|
|
1029
|
+
const sorted = [...pitches].sort((a, b) => a - b);
|
|
1030
|
+
const raised = sorted[0] + 12;
|
|
1031
|
+
const close = [...sorted.slice(1), raised].sort((a, b) => a - b);
|
|
1032
|
+
if (close[3] - close[0] >= 12)
|
|
1033
|
+
return null;
|
|
1034
|
+
const fromTop = 3 - close.indexOf(raised);
|
|
1035
|
+
return fromTop === 1 ? 2 : fromTop === 2 ? 3 : null;
|
|
1036
|
+
}
|
|
1037
|
+
function isHendrixChord(frets, info, tuning) {
|
|
1038
|
+
if (!sameTuning(tuning, STANDARD_TUNING) || !isJazzGrip(frets) || frets[1] === null)
|
|
1039
|
+
return false;
|
|
1040
|
+
if (frets[0] !== null || (tuning[1] + frets[1]) % 12 !== info.root)
|
|
1041
|
+
return false;
|
|
1042
|
+
const chromas = new Set(info.tones.map((t) => t.chroma));
|
|
1043
|
+
return chromas.has((info.root + 3) % 12) && chromas.has((info.root + 4) % 12);
|
|
1044
|
+
}
|
|
1045
|
+
function otherNameOf(frets, info, tuning) {
|
|
1046
|
+
const sounding = frets.flatMap((f, s) => f === null ? [] : [s]);
|
|
1047
|
+
if (!sounding.length || tuning.length !== frets.length)
|
|
1048
|
+
return null;
|
|
1049
|
+
const strings = stringsText(sounding, frets.length);
|
|
1050
|
+
const standard = sameTuning(tuning, STANDARD_TUNING);
|
|
1051
|
+
const pitches = sounding.map((s) => tuning[s] + frets[s]);
|
|
1052
|
+
const letter = standard ? cagedPartOf(frets, sounding, info) : null;
|
|
1053
|
+
if (letter)
|
|
1054
|
+
return `${letter} shape (strings ${strings})`;
|
|
1055
|
+
const drop = dropOf(pitches);
|
|
1056
|
+
if (drop)
|
|
1057
|
+
return `Drop ${drop} (strings ${strings})`;
|
|
1058
|
+
const open = sounding.filter((s) => frets[s] === 0);
|
|
1059
|
+
if (open.length)
|
|
1060
|
+
return open.length === 1 && open[0] === sounding[0] ? "Open bass" : "Open strings";
|
|
1061
|
+
return `Strings ${strings}`;
|
|
1062
|
+
}
|
|
980
1063
|
function voicingShape(frets, symbol, tuning = STANDARD_TUNING, _fingers) {
|
|
981
1064
|
const info = chordInfo(symbol);
|
|
982
|
-
|
|
1065
|
+
if (!info)
|
|
1066
|
+
return null;
|
|
1067
|
+
if (isHendrixChord(frets, info, tuning))
|
|
1068
|
+
return "Hendrix chord";
|
|
1069
|
+
return shapeOf(frets, info, cagedTargets(info), tuning) ?? otherNameOf(frets, info, tuning);
|
|
983
1070
|
}
|
|
984
1071
|
var KNOWN_SHAPES = new Set([
|
|
985
1072
|
"C shape",
|
|
@@ -995,14 +1082,16 @@ var JAZZ_GRIPS = [
|
|
|
995
1082
|
{ rootString: 0, offsets: [0, null, -1, 0, -1, null] },
|
|
996
1083
|
{ rootString: 0, offsets: [0, null, 0, 1, 2, null] }
|
|
997
1084
|
];
|
|
998
|
-
function distinctShapes(voicings, count = voicings.length) {
|
|
1085
|
+
function distinctShapes(voicings, count = voicings.length, tuning = STANDARD_TUNING) {
|
|
999
1086
|
const sounding = (v) => v.frets.flatMap((f, s) => f === null ? [] : [s]);
|
|
1000
1087
|
const copyOf = (v, w) => {
|
|
1001
1088
|
const mine = sounding(v);
|
|
1002
1089
|
const theirs = sounding(w);
|
|
1003
1090
|
return mine.length < theirs.length && v.frets.length === w.frets.length && mine.every((s, i) => theirs[i] === s && w.frets[s] === v.frets[s]);
|
|
1004
1091
|
};
|
|
1005
|
-
const
|
|
1092
|
+
const standard = sameTuning(tuning, STANDARD_TUNING);
|
|
1093
|
+
const grip = (v) => standard && isJazzGrip(v.frets);
|
|
1094
|
+
const kept = voicings.filter((v) => !voicings.some((w) => w !== v && (copyOf(v, w) && !grip(v) || copyOf(w, v) && grip(w))));
|
|
1006
1095
|
const lowest = (v) => {
|
|
1007
1096
|
const fretted = v.frets.filter((f) => f !== null && f > 0);
|
|
1008
1097
|
return fretted.length ? Math.min(...fretted) : 0;
|
|
@@ -1165,7 +1254,7 @@ function generateVoicings(symbol, options = {}) {
|
|
|
1165
1254
|
baseFret: base,
|
|
1166
1255
|
bassString,
|
|
1167
1256
|
inversion: inBass < 0 ? null : inBass,
|
|
1168
|
-
shape,
|
|
1257
|
+
shape: isHendrixChord(candidate, info, tuning) ? "Hendrix chord" : shape ?? otherNameOf(candidate, info, tuning),
|
|
1169
1258
|
difficulty: Math.max(0, Math.round(difficulty * 10) / 10),
|
|
1170
1259
|
reasons
|
|
1171
1260
|
};
|
|
@@ -1524,5 +1613,5 @@ export {
|
|
|
1524
1613
|
voicingCount
|
|
1525
1614
|
};
|
|
1526
1615
|
|
|
1527
|
-
//# debugId=
|
|
1616
|
+
//# debugId=0FDAEF7C01DCE45464756E2164756E21
|
|
1528
1617
|
//# sourceMappingURL=index.js.map
|