@dsebastien/music-notation 0.23.1 → 0.25.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 +5 -2
- package/dist/chord/simplify.d.ts +56 -0
- package/dist/chords/chart.d.ts +55 -3
- package/dist/chords/chordpro.d.ts +4 -0
- package/dist/chords/easier.d.ts +39 -0
- package/dist/i18n/en/index.d.ts +11 -0
- package/dist/i18n/en/parse.d.ts +2 -0
- package/dist/i18n/en/play.d.ts +9 -0
- package/dist/i18n/fr/parse.d.ts +2 -0
- package/dist/i18n/fr/play.d.ts +9 -0
- package/dist/i18n/language.d.ts +12 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +532 -44
- package/dist/index.js.map +20 -16
- package/dist/music-notation.publish.min.js +37 -37
- package/dist/music-notation.tab.min.js +7 -7
- package/dist/playback/controls.d.ts +17 -0
- package/dist/playback/guitar-tone.d.ts +35 -0
- package/dist/playback/player.d.ts +12 -0
- package/dist/playback/progression-bar.d.ts +6 -1
- package/dist/playback/sound-menu.d.ts +21 -0
- package/dist/publish/index.js +504 -36
- package/dist/publish/index.js.map +19 -15
- package/dist/tab/index.js +104 -17
- package/dist/tab/index.js.map +9 -8
- package/dist/voicings/index.js +23 -1
- package/dist/voicings/index.js.map +6 -6
- package/package.json +2 -2
package/dist/tab/index.js
CHANGED
|
@@ -516,6 +516,7 @@ var enParse = {
|
|
|
516
516
|
"chords.chart.capo": "Capo {capo}",
|
|
517
517
|
"chords.chart.tempo": "{bpm} BPM",
|
|
518
518
|
"chords.chart.transposed": "Transposed {amount}",
|
|
519
|
+
"chords.chart.simplified": "Easier chords",
|
|
519
520
|
"chords.chart.sounds": "{title} (sounds {sounding})",
|
|
520
521
|
"chords.chart.moreNotDrawn": "{count} more chords not drawn (at most {max})",
|
|
521
522
|
"chords.chart.missing": "No diagram for {names}: give the shape with {how}",
|
|
@@ -530,6 +531,7 @@ var enParse = {
|
|
|
530
531
|
"chords.define.fingersCount": "{at}: fingers has {fingers} values for {strings} strings: give one per string (0 for none)",
|
|
531
532
|
"chords.define.reaches": "{at}: the shape reaches fret {top}: frets go up to {max}",
|
|
532
533
|
"chords.directive.diagrams": "{at}: use on, off, top or bottom",
|
|
534
|
+
"chords.directive.simplify": "{at}: use yes or no",
|
|
533
535
|
"chord.shape.open": "Open",
|
|
534
536
|
"chord.shape.caged": "{letter} shape",
|
|
535
537
|
"chord.shape.cagedStrings": "{letter} shape (strings {strings})",
|
|
@@ -569,7 +571,15 @@ var enPlay = {
|
|
|
569
571
|
"playback.click": "Click",
|
|
570
572
|
"playback.sound": "Sound",
|
|
571
573
|
"playback.guitar": "Guitar",
|
|
574
|
+
"playback.guitar.steel": "Guitar (steel)",
|
|
575
|
+
"playback.guitar.nylon": "Guitar (nylon)",
|
|
576
|
+
"playback.guitar.clean": "Guitar (clean)",
|
|
577
|
+
"playback.guitar.overdrive": "Guitar (overdrive)",
|
|
572
578
|
"playback.piano": "Piano",
|
|
579
|
+
"playback.simplify": "Simplify",
|
|
580
|
+
"playback.simplified": "Simplified",
|
|
581
|
+
"playback.simplify.hint": "Show easier chords",
|
|
582
|
+
"playback.simplified.hint": "Show the chords as written",
|
|
573
583
|
"playback.tempo": "Tempo (BPM)",
|
|
574
584
|
"playback.unit.bpm": "BPM",
|
|
575
585
|
"playback.unit.ms": "ms",
|
|
@@ -597,6 +607,7 @@ var enPlay = {
|
|
|
597
607
|
"playback.redraw.guitar": "{name}, drawn for guitar",
|
|
598
608
|
"playback.redraw.piano": "{name}, drawn for piano",
|
|
599
609
|
"playback.engine.invalid": 'engine: use generaluser, sonivox or light, got "{value}"',
|
|
610
|
+
"playback.guitar.invalid": 'guitar: use steel, nylon, clean or overdrive, got "{value}"',
|
|
600
611
|
"tab.source.staves": 'staves: use tab, score or both, got "{value}"',
|
|
601
612
|
"tab.source.layout": 'layout: use page or line, got "{value}"',
|
|
602
613
|
"tab.source.names": 'names: use on or off, got "{value}"',
|
|
@@ -1070,6 +1081,7 @@ var frParse = {
|
|
|
1070
1081
|
"chords.chart.capo": "Capodastre {capo}",
|
|
1071
1082
|
"chords.chart.tempo": "{bpm} BPM",
|
|
1072
1083
|
"chords.chart.transposed": "Transposé de {amount}",
|
|
1084
|
+
"chords.chart.simplified": "Accords simplifiés",
|
|
1073
1085
|
"chords.chart.sounds": "{title} (sonne {sounding})",
|
|
1074
1086
|
"chords.chart.moreNotDrawn": "{count} accords de plus non dessinés (au plus {max})",
|
|
1075
1087
|
"chords.chart.missing": "Pas de diagramme pour {names} : donnez la forme avec {how}",
|
|
@@ -1084,6 +1096,7 @@ var frParse = {
|
|
|
1084
1096
|
"chords.define.fingersCount": "{at} : fingers a {fingers} valeurs pour {strings} cordes : donnez-en une par corde (0 pour aucune)",
|
|
1085
1097
|
"chords.define.reaches": "{at} : la forme atteint la case {top} : les cases vont jusqu'à {max}",
|
|
1086
1098
|
"chords.directive.diagrams": "{at} : utilisez on, off, top ou bottom",
|
|
1099
|
+
"chords.directive.simplify": "{at} : utilisez yes ou no",
|
|
1087
1100
|
"chord.shape.open": "Accord ouvert",
|
|
1088
1101
|
"chord.shape.caged": "forme {letter}",
|
|
1089
1102
|
"chord.shape.cagedStrings": "forme {letter} (cordes {strings})",
|
|
@@ -1123,7 +1136,15 @@ var frPlay = {
|
|
|
1123
1136
|
"playback.click": "Clic",
|
|
1124
1137
|
"playback.sound": "Son",
|
|
1125
1138
|
"playback.guitar": "Guitare",
|
|
1139
|
+
"playback.guitar.steel": "Guitare (folk)",
|
|
1140
|
+
"playback.guitar.nylon": "Guitare (classique)",
|
|
1141
|
+
"playback.guitar.clean": "Guitare (son clair)",
|
|
1142
|
+
"playback.guitar.overdrive": "Guitare (son saturé)",
|
|
1126
1143
|
"playback.piano": "Piano",
|
|
1144
|
+
"playback.simplify": "Simplifier",
|
|
1145
|
+
"playback.simplified": "Simplifié",
|
|
1146
|
+
"playback.simplify.hint": "Afficher des accords plus faciles",
|
|
1147
|
+
"playback.simplified.hint": "Afficher les accords écrits",
|
|
1127
1148
|
"playback.tempo": "Tempo (BPM)",
|
|
1128
1149
|
"playback.unit.bpm": "BPM",
|
|
1129
1150
|
"playback.unit.ms": "ms",
|
|
@@ -1151,6 +1172,7 @@ var frPlay = {
|
|
|
1151
1172
|
"playback.redraw.guitar": "{name}, dessiné pour la guitare",
|
|
1152
1173
|
"playback.redraw.piano": "{name}, dessiné pour le piano",
|
|
1153
1174
|
"playback.engine.invalid": "engine: utilisez generaluser, sonivox ou light, reçu « {value} »",
|
|
1175
|
+
"playback.guitar.invalid": "guitar: utilisez steel, nylon, clean ou overdrive, reçu « {value} »",
|
|
1154
1176
|
"tab.source.staves": "staves: utilisez tab, score ou both, reçu « {value} »",
|
|
1155
1177
|
"tab.source.layout": "layout: utilisez page ou line, reçu « {value} »",
|
|
1156
1178
|
"tab.source.names": "names: utilisez on ou off, reçu « {value} »",
|
|
@@ -2982,6 +3004,62 @@ function pageEngine(options) {
|
|
|
2982
3004
|
return engineOf(play.engine) ?? undefined;
|
|
2983
3005
|
}
|
|
2984
3006
|
|
|
3007
|
+
// src/playback/guitar-tone.ts
|
|
3008
|
+
var GUITAR_TONES = ["steel", "nylon", "clean", "overdrive"];
|
|
3009
|
+
var DEFAULT_GUITAR_TONE = "steel";
|
|
3010
|
+
var GUITAR_PROGRAMS = {
|
|
3011
|
+
steel: 25,
|
|
3012
|
+
nylon: 24,
|
|
3013
|
+
clean: 27,
|
|
3014
|
+
overdrive: 29
|
|
3015
|
+
};
|
|
3016
|
+
var ALIASES2 = {
|
|
3017
|
+
acoustic: "steel",
|
|
3018
|
+
"steel-string": "steel",
|
|
3019
|
+
classical: "nylon",
|
|
3020
|
+
"nylon-string": "nylon",
|
|
3021
|
+
electric: "clean",
|
|
3022
|
+
overdriven: "overdrive"
|
|
3023
|
+
};
|
|
3024
|
+
function guitarToneOf(value) {
|
|
3025
|
+
if (typeof value !== "string")
|
|
3026
|
+
return null;
|
|
3027
|
+
const name = value.trim().toLowerCase().replace(/\s+/g, "-");
|
|
3028
|
+
return GUITAR_TONES.find((tone) => tone === name) ?? ALIASES2[name] ?? null;
|
|
3029
|
+
}
|
|
3030
|
+
var LINE2 = /^[ \t]*guitar[ \t]*:[ \t]*(.*?)[ \t]*(?:\r?\n|$)/gim;
|
|
3031
|
+
var DIRECTIVE2 = /^[ \t]*\{[ \t]*guitar[ \t]*:[ \t]*(.*?)[ \t]*\}[ \t]*(?:\r?\n|$)/gim;
|
|
3032
|
+
function blockGuitar(source, chart = false) {
|
|
3033
|
+
let guitar = null;
|
|
3034
|
+
const rest = source.replace(chart ? DIRECTIVE2 : LINE2, (_line, value) => {
|
|
3035
|
+
const read = guitarToneOf(value);
|
|
3036
|
+
if (!read) {
|
|
3037
|
+
throw new Error(t("playback.guitar.invalid", { value }));
|
|
3038
|
+
}
|
|
3039
|
+
guitar = read;
|
|
3040
|
+
return "";
|
|
3041
|
+
});
|
|
3042
|
+
return { guitar, source: rest };
|
|
3043
|
+
}
|
|
3044
|
+
function guitarWish(el) {
|
|
3045
|
+
return guitarToneOf(el?.closest("[data-mn-guitar]")?.getAttribute("data-mn-guitar"));
|
|
3046
|
+
}
|
|
3047
|
+
var CHOICE = "data-mn-guitar-choice";
|
|
3048
|
+
function guitarChoice(el) {
|
|
3049
|
+
return guitarToneOf(el?.closest(`[${CHOICE}]`)?.getAttribute(CHOICE));
|
|
3050
|
+
}
|
|
3051
|
+
function chooseGuitar(el, guitar) {
|
|
3052
|
+
(el.closest(".mn-block") ?? el).setAttribute(CHOICE, guitar);
|
|
3053
|
+
}
|
|
3054
|
+
function pageGuitar(options) {
|
|
3055
|
+
if (!options || typeof options !== "object" || !("play" in options))
|
|
3056
|
+
return;
|
|
3057
|
+
const play = options.play;
|
|
3058
|
+
if (!play || typeof play !== "object" || !("guitar" in play))
|
|
3059
|
+
return;
|
|
3060
|
+
return guitarToneOf(play.guitar) ?? undefined;
|
|
3061
|
+
}
|
|
3062
|
+
|
|
2985
3063
|
// src/playback/bar-parts.ts
|
|
2986
3064
|
var ICONS = {
|
|
2987
3065
|
play: "M4 2.5v11l9-5.5z",
|
|
@@ -4584,14 +4662,15 @@ function renderTab(language, source, host, options) {
|
|
|
4584
4662
|
}
|
|
4585
4663
|
};
|
|
4586
4664
|
}
|
|
4587
|
-
var
|
|
4665
|
+
var PIANO_PROGRAM = 0;
|
|
4666
|
+
var programOf = (sound, guitar) => sound === "piano" ? PIANO_PROGRAM : GUITAR_PROGRAMS[guitar ?? DEFAULT_GUITAR_TONE];
|
|
4588
4667
|
var MUTED = { channel: 1, program: 28 };
|
|
4589
4668
|
var CLICK = { channel: 9, key: 33 };
|
|
4590
4669
|
var SOUNDFONT_TAIL = 0.5;
|
|
4591
4670
|
function soundfontPlayer(alphaTab, api) {
|
|
4592
4671
|
return {
|
|
4593
4672
|
reportsStart: true,
|
|
4594
|
-
play(events, { sound, volume, onEnd, onStart }) {
|
|
4673
|
+
play(events, { sound, volume, onEnd, onStart, guitar }) {
|
|
4595
4674
|
const current = api();
|
|
4596
4675
|
const player = current?.player;
|
|
4597
4676
|
if (!current || !player)
|
|
@@ -4600,7 +4679,7 @@ function soundfontPlayer(alphaTab, api) {
|
|
|
4600
4679
|
const handler = new alphaTab.midi.AlphaSynthMidiFileHandler(midi, true);
|
|
4601
4680
|
const ticks = (seconds) => Math.round(seconds * midi.division);
|
|
4602
4681
|
handler.addTempo(0, 60);
|
|
4603
|
-
handler.addProgramChange(0, 0, 0,
|
|
4682
|
+
handler.addProgramChange(0, 0, 0, programOf(sound, guitar));
|
|
4604
4683
|
if (sound === "guitar" && events.some((e) => e.kind === "muted"))
|
|
4605
4684
|
handler.addProgramChange(0, 0, MUTED.channel, MUTED.program);
|
|
4606
4685
|
if (events.some((e) => e.kind === "click"))
|
|
@@ -4644,8 +4723,8 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
|
|
|
4644
4723
|
const have = new Set;
|
|
4645
4724
|
const reading = new Map;
|
|
4646
4725
|
let whole = !assets.instruments;
|
|
4647
|
-
const programsOf = (sound) => sound === "guitar" ? [
|
|
4648
|
-
const start = (first = "guitar") => {
|
|
4726
|
+
const programsOf = (sound, guitar) => sound === "guitar" ? [programOf(sound, guitar), MUTED.program] : [programOf(sound)];
|
|
4727
|
+
const start = (first = "guitar", guitar) => {
|
|
4649
4728
|
if (ready)
|
|
4650
4729
|
return ready;
|
|
4651
4730
|
host = html(doc, "div", "mn-tab-hidden");
|
|
@@ -4688,13 +4767,14 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
|
|
|
4688
4767
|
current.error.on(() => resolve(false));
|
|
4689
4768
|
if (assets.instruments)
|
|
4690
4769
|
loadSounds(current, doc, assets, {
|
|
4691
|
-
programs: programsOf(first),
|
|
4770
|
+
programs: programsOf(first, guitar),
|
|
4692
4771
|
drums: false
|
|
4693
4772
|
}).then((kind) => {
|
|
4694
4773
|
if (kind === "whole")
|
|
4695
4774
|
whole = true;
|
|
4696
4775
|
else
|
|
4697
|
-
|
|
4776
|
+
for (const one of programsOf(first, guitar))
|
|
4777
|
+
have.add(one);
|
|
4698
4778
|
loaded();
|
|
4699
4779
|
}, () => resolve(false));
|
|
4700
4780
|
else
|
|
@@ -4702,25 +4782,32 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
|
|
|
4702
4782
|
});
|
|
4703
4783
|
if (assets.soundFont instanceof Uint8Array && !assets.instruments)
|
|
4704
4784
|
current.loadSoundFont(made.bytes(assets.soundFont), false);
|
|
4705
|
-
current.tex(
|
|
4785
|
+
current.tex([
|
|
4786
|
+
...GUITAR_TONES.map((tone) => `\\track "Guitar ${tone}" \\instrument ${GUITAR_PROGRAMS[tone]} r`),
|
|
4787
|
+
`\\track "Piano" \\instrument ${PIANO_PROGRAM} r`,
|
|
4788
|
+
`\\track "Muted" \\instrument ${MUTED.program} r`
|
|
4789
|
+
].join(" "));
|
|
4706
4790
|
return ready;
|
|
4707
4791
|
};
|
|
4708
|
-
const sounding = async (sound) => {
|
|
4709
|
-
if (!await start(sound))
|
|
4792
|
+
const sounding = async (sound, guitar) => {
|
|
4793
|
+
if (!await start(sound, guitar))
|
|
4710
4794
|
return false;
|
|
4711
|
-
|
|
4795
|
+
const program = programOf(sound, guitar);
|
|
4796
|
+
if (whole || have.has(program) || !api)
|
|
4712
4797
|
return true;
|
|
4713
4798
|
const current = api;
|
|
4714
|
-
let more = reading.get(
|
|
4799
|
+
let more = reading.get(program);
|
|
4715
4800
|
if (!more) {
|
|
4716
|
-
|
|
4801
|
+
const programs = programsOf(sound, guitar).filter((one) => one === program || !have.has(MUTED.program));
|
|
4802
|
+
more = loadSounds(current, doc, assets, { programs, drums: false, click: false }, true).then((kind) => {
|
|
4717
4803
|
if (kind === "whole")
|
|
4718
4804
|
whole = true;
|
|
4719
4805
|
else
|
|
4720
|
-
|
|
4806
|
+
for (const one of programs)
|
|
4807
|
+
have.add(one);
|
|
4721
4808
|
return true;
|
|
4722
4809
|
}, () => false);
|
|
4723
|
-
reading.set(
|
|
4810
|
+
reading.set(program, more);
|
|
4724
4811
|
}
|
|
4725
4812
|
return more;
|
|
4726
4813
|
};
|
|
@@ -4731,7 +4818,7 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
|
|
|
4731
4818
|
let handle = null;
|
|
4732
4819
|
let stopped = false;
|
|
4733
4820
|
let volume = options.volume;
|
|
4734
|
-
sounding(options.sound).then((ok) => {
|
|
4821
|
+
sounding(options.sound, options.guitar).then((ok) => {
|
|
4735
4822
|
if (stopped)
|
|
4736
4823
|
return;
|
|
4737
4824
|
try {
|
|
@@ -4803,5 +4890,5 @@ export {
|
|
|
4803
4890
|
textTabToAlphaTex
|
|
4804
4891
|
};
|
|
4805
4892
|
|
|
4806
|
-
//# debugId=
|
|
4893
|
+
//# debugId=21F24532A6AFD41364756E2164756E21
|
|
4807
4894
|
//# sourceMappingURL=index.js.map
|