@dsebastien/music-notation 0.23.1 → 0.24.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 +4 -2
- package/dist/i18n/en/index.d.ts +1 -0
- package/dist/i18n/en/play.d.ts +1 -0
- package/dist/i18n/fr/play.d.ts +1 -0
- package/dist/i18n/language.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +148 -26
- package/dist/index.js.map +12 -11
- package/dist/music-notation.publish.min.js +32 -32
- package/dist/music-notation.tab.min.js +7 -7
- package/dist/playback/controls.d.ts +14 -0
- package/dist/playback/guitar-tone.d.ts +27 -0
- package/dist/playback/player.d.ts +12 -0
- package/dist/publish/index.js +125 -18
- package/dist/publish/index.js.map +11 -10
- package/dist/tab/index.js +77 -17
- package/dist/tab/index.js.map +7 -6
- package/dist/voicings/index.js +3 -1
- package/dist/voicings/index.js.map +4 -4
- package/package.json +2 -2
package/dist/tab/index.js
CHANGED
|
@@ -597,6 +597,7 @@ var enPlay = {
|
|
|
597
597
|
"playback.redraw.guitar": "{name}, drawn for guitar",
|
|
598
598
|
"playback.redraw.piano": "{name}, drawn for piano",
|
|
599
599
|
"playback.engine.invalid": 'engine: use generaluser, sonivox or light, got "{value}"',
|
|
600
|
+
"playback.guitar.invalid": 'guitar: use steel, nylon, clean or overdrive, got "{value}"',
|
|
600
601
|
"tab.source.staves": 'staves: use tab, score or both, got "{value}"',
|
|
601
602
|
"tab.source.layout": 'layout: use page or line, got "{value}"',
|
|
602
603
|
"tab.source.names": 'names: use on or off, got "{value}"',
|
|
@@ -1151,6 +1152,7 @@ var frPlay = {
|
|
|
1151
1152
|
"playback.redraw.guitar": "{name}, dessiné pour la guitare",
|
|
1152
1153
|
"playback.redraw.piano": "{name}, dessiné pour le piano",
|
|
1153
1154
|
"playback.engine.invalid": "engine: utilisez generaluser, sonivox ou light, reçu « {value} »",
|
|
1155
|
+
"playback.guitar.invalid": "guitar: utilisez steel, nylon, clean ou overdrive, reçu « {value} »",
|
|
1154
1156
|
"tab.source.staves": "staves: utilisez tab, score ou both, reçu « {value} »",
|
|
1155
1157
|
"tab.source.layout": "layout: utilisez page ou line, reçu « {value} »",
|
|
1156
1158
|
"tab.source.names": "names: utilisez on ou off, reçu « {value} »",
|
|
@@ -2982,6 +2984,55 @@ function pageEngine(options) {
|
|
|
2982
2984
|
return engineOf(play.engine) ?? undefined;
|
|
2983
2985
|
}
|
|
2984
2986
|
|
|
2987
|
+
// src/playback/guitar-tone.ts
|
|
2988
|
+
var GUITAR_TONES = ["steel", "nylon", "clean", "overdrive"];
|
|
2989
|
+
var DEFAULT_GUITAR_TONE = "steel";
|
|
2990
|
+
var GUITAR_PROGRAMS = {
|
|
2991
|
+
steel: 25,
|
|
2992
|
+
nylon: 24,
|
|
2993
|
+
clean: 27,
|
|
2994
|
+
overdrive: 29
|
|
2995
|
+
};
|
|
2996
|
+
var ALIASES2 = {
|
|
2997
|
+
acoustic: "steel",
|
|
2998
|
+
"steel-string": "steel",
|
|
2999
|
+
classical: "nylon",
|
|
3000
|
+
"nylon-string": "nylon",
|
|
3001
|
+
electric: "clean",
|
|
3002
|
+
overdriven: "overdrive"
|
|
3003
|
+
};
|
|
3004
|
+
function guitarToneOf(value) {
|
|
3005
|
+
if (typeof value !== "string")
|
|
3006
|
+
return null;
|
|
3007
|
+
const name = value.trim().toLowerCase().replace(/\s+/g, "-");
|
|
3008
|
+
return GUITAR_TONES.find((tone) => tone === name) ?? ALIASES2[name] ?? null;
|
|
3009
|
+
}
|
|
3010
|
+
var LINE2 = /^[ \t]*guitar[ \t]*:[ \t]*(.*?)[ \t]*(?:\r?\n|$)/gim;
|
|
3011
|
+
var DIRECTIVE2 = /^[ \t]*\{[ \t]*guitar[ \t]*:[ \t]*(.*?)[ \t]*\}[ \t]*(?:\r?\n|$)/gim;
|
|
3012
|
+
function blockGuitar(source, chart = false) {
|
|
3013
|
+
let guitar = null;
|
|
3014
|
+
const rest = source.replace(chart ? DIRECTIVE2 : LINE2, (_line, value) => {
|
|
3015
|
+
const read = guitarToneOf(value);
|
|
3016
|
+
if (!read) {
|
|
3017
|
+
throw new Error(t("playback.guitar.invalid", { value }));
|
|
3018
|
+
}
|
|
3019
|
+
guitar = read;
|
|
3020
|
+
return "";
|
|
3021
|
+
});
|
|
3022
|
+
return { guitar, source: rest };
|
|
3023
|
+
}
|
|
3024
|
+
function guitarWish(el) {
|
|
3025
|
+
return guitarToneOf(el?.closest("[data-mn-guitar]")?.getAttribute("data-mn-guitar"));
|
|
3026
|
+
}
|
|
3027
|
+
function pageGuitar(options) {
|
|
3028
|
+
if (!options || typeof options !== "object" || !("play" in options))
|
|
3029
|
+
return;
|
|
3030
|
+
const play = options.play;
|
|
3031
|
+
if (!play || typeof play !== "object" || !("guitar" in play))
|
|
3032
|
+
return;
|
|
3033
|
+
return guitarToneOf(play.guitar) ?? undefined;
|
|
3034
|
+
}
|
|
3035
|
+
|
|
2985
3036
|
// src/playback/bar-parts.ts
|
|
2986
3037
|
var ICONS = {
|
|
2987
3038
|
play: "M4 2.5v11l9-5.5z",
|
|
@@ -4584,14 +4635,15 @@ function renderTab(language, source, host, options) {
|
|
|
4584
4635
|
}
|
|
4585
4636
|
};
|
|
4586
4637
|
}
|
|
4587
|
-
var
|
|
4638
|
+
var PIANO_PROGRAM = 0;
|
|
4639
|
+
var programOf = (sound, guitar) => sound === "piano" ? PIANO_PROGRAM : GUITAR_PROGRAMS[guitar ?? DEFAULT_GUITAR_TONE];
|
|
4588
4640
|
var MUTED = { channel: 1, program: 28 };
|
|
4589
4641
|
var CLICK = { channel: 9, key: 33 };
|
|
4590
4642
|
var SOUNDFONT_TAIL = 0.5;
|
|
4591
4643
|
function soundfontPlayer(alphaTab, api) {
|
|
4592
4644
|
return {
|
|
4593
4645
|
reportsStart: true,
|
|
4594
|
-
play(events, { sound, volume, onEnd, onStart }) {
|
|
4646
|
+
play(events, { sound, volume, onEnd, onStart, guitar }) {
|
|
4595
4647
|
const current = api();
|
|
4596
4648
|
const player = current?.player;
|
|
4597
4649
|
if (!current || !player)
|
|
@@ -4600,7 +4652,7 @@ function soundfontPlayer(alphaTab, api) {
|
|
|
4600
4652
|
const handler = new alphaTab.midi.AlphaSynthMidiFileHandler(midi, true);
|
|
4601
4653
|
const ticks = (seconds) => Math.round(seconds * midi.division);
|
|
4602
4654
|
handler.addTempo(0, 60);
|
|
4603
|
-
handler.addProgramChange(0, 0, 0,
|
|
4655
|
+
handler.addProgramChange(0, 0, 0, programOf(sound, guitar));
|
|
4604
4656
|
if (sound === "guitar" && events.some((e) => e.kind === "muted"))
|
|
4605
4657
|
handler.addProgramChange(0, 0, MUTED.channel, MUTED.program);
|
|
4606
4658
|
if (events.some((e) => e.kind === "click"))
|
|
@@ -4644,8 +4696,8 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
|
|
|
4644
4696
|
const have = new Set;
|
|
4645
4697
|
const reading = new Map;
|
|
4646
4698
|
let whole = !assets.instruments;
|
|
4647
|
-
const programsOf = (sound) => sound === "guitar" ? [
|
|
4648
|
-
const start = (first = "guitar") => {
|
|
4699
|
+
const programsOf = (sound, guitar) => sound === "guitar" ? [programOf(sound, guitar), MUTED.program] : [programOf(sound)];
|
|
4700
|
+
const start = (first = "guitar", guitar) => {
|
|
4649
4701
|
if (ready)
|
|
4650
4702
|
return ready;
|
|
4651
4703
|
host = html(doc, "div", "mn-tab-hidden");
|
|
@@ -4688,13 +4740,14 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
|
|
|
4688
4740
|
current.error.on(() => resolve(false));
|
|
4689
4741
|
if (assets.instruments)
|
|
4690
4742
|
loadSounds(current, doc, assets, {
|
|
4691
|
-
programs: programsOf(first),
|
|
4743
|
+
programs: programsOf(first, guitar),
|
|
4692
4744
|
drums: false
|
|
4693
4745
|
}).then((kind) => {
|
|
4694
4746
|
if (kind === "whole")
|
|
4695
4747
|
whole = true;
|
|
4696
4748
|
else
|
|
4697
|
-
|
|
4749
|
+
for (const one of programsOf(first, guitar))
|
|
4750
|
+
have.add(one);
|
|
4698
4751
|
loaded();
|
|
4699
4752
|
}, () => resolve(false));
|
|
4700
4753
|
else
|
|
@@ -4702,25 +4755,32 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
|
|
|
4702
4755
|
});
|
|
4703
4756
|
if (assets.soundFont instanceof Uint8Array && !assets.instruments)
|
|
4704
4757
|
current.loadSoundFont(made.bytes(assets.soundFont), false);
|
|
4705
|
-
current.tex(
|
|
4758
|
+
current.tex([
|
|
4759
|
+
...GUITAR_TONES.map((tone) => `\\track "Guitar ${tone}" \\instrument ${GUITAR_PROGRAMS[tone]} r`),
|
|
4760
|
+
`\\track "Piano" \\instrument ${PIANO_PROGRAM} r`,
|
|
4761
|
+
`\\track "Muted" \\instrument ${MUTED.program} r`
|
|
4762
|
+
].join(" "));
|
|
4706
4763
|
return ready;
|
|
4707
4764
|
};
|
|
4708
|
-
const sounding = async (sound) => {
|
|
4709
|
-
if (!await start(sound))
|
|
4765
|
+
const sounding = async (sound, guitar) => {
|
|
4766
|
+
if (!await start(sound, guitar))
|
|
4710
4767
|
return false;
|
|
4711
|
-
|
|
4768
|
+
const program = programOf(sound, guitar);
|
|
4769
|
+
if (whole || have.has(program) || !api)
|
|
4712
4770
|
return true;
|
|
4713
4771
|
const current = api;
|
|
4714
|
-
let more = reading.get(
|
|
4772
|
+
let more = reading.get(program);
|
|
4715
4773
|
if (!more) {
|
|
4716
|
-
|
|
4774
|
+
const programs = programsOf(sound, guitar).filter((one) => one === program || !have.has(MUTED.program));
|
|
4775
|
+
more = loadSounds(current, doc, assets, { programs, drums: false, click: false }, true).then((kind) => {
|
|
4717
4776
|
if (kind === "whole")
|
|
4718
4777
|
whole = true;
|
|
4719
4778
|
else
|
|
4720
|
-
|
|
4779
|
+
for (const one of programs)
|
|
4780
|
+
have.add(one);
|
|
4721
4781
|
return true;
|
|
4722
4782
|
}, () => false);
|
|
4723
|
-
reading.set(
|
|
4783
|
+
reading.set(program, more);
|
|
4724
4784
|
}
|
|
4725
4785
|
return more;
|
|
4726
4786
|
};
|
|
@@ -4731,7 +4791,7 @@ function createSoundfontPlayer(alphaTab, assets, doc, fallback) {
|
|
|
4731
4791
|
let handle = null;
|
|
4732
4792
|
let stopped = false;
|
|
4733
4793
|
let volume = options.volume;
|
|
4734
|
-
sounding(options.sound).then((ok) => {
|
|
4794
|
+
sounding(options.sound, options.guitar).then((ok) => {
|
|
4735
4795
|
if (stopped)
|
|
4736
4796
|
return;
|
|
4737
4797
|
try {
|
|
@@ -4803,5 +4863,5 @@ export {
|
|
|
4803
4863
|
textTabToAlphaTex
|
|
4804
4864
|
};
|
|
4805
4865
|
|
|
4806
|
-
//# debugId=
|
|
4866
|
+
//# debugId=160F358ACD31936664756E2164756E21
|
|
4807
4867
|
//# sourceMappingURL=index.js.map
|