@dsebastien/music-notation 0.23.0 → 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/diagrams.d.ts +2 -2
- package/dist/i18n/fr/parse.d.ts +4 -4
- package/dist/i18n/fr/play.d.ts +1 -0
- package/dist/i18n/fr/timed.d.ts +4 -4
- package/dist/i18n/language.d.ts +2 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +158 -36
- package/dist/index.js.map +15 -14
- 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 +135 -28
- package/dist/publish/index.js.map +14 -13
- package/dist/tab/index.js +87 -27
- package/dist/tab/index.js.map +10 -9
- package/dist/voicings/index.js +13 -11
- package/dist/voicings/index.js.map +7 -7
- package/package.json +2 -2
package/dist/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}"',
|
|
@@ -752,7 +753,7 @@ var frDiagrams = {
|
|
|
752
753
|
"render.voicings.inversion": "inversion : utilisez 0 (fondamentale), 1, 2, 3 ou any, reçu « {inversion} »",
|
|
753
754
|
"render.voicings.manyStringsAny": "Sur {count} cordes, inversion: any demande six cordes ou moins : ajoutez par exemple strings: 1-6",
|
|
754
755
|
"render.voicings.wideArea": "une zone large",
|
|
755
|
-
"render.voicings.oneWidening": "Sur {count} cordes, utilisez
|
|
756
|
+
"render.voicings.oneWidening": "Sur {count} cordes, utilisez une seule option à la fois parmi {list}",
|
|
756
757
|
"render.noVoicing.gaps": "Les cordes {strings} ne sont pas côte à côte : ajoutez gaps: yes",
|
|
757
758
|
"render.noVoicing.rootString": "root-string {string} ne fait pas partie des cordes {strings}",
|
|
758
759
|
"render.noVoicing.inversion": "{symbol} a {notes} notes : inversion va jusqu'à {max}",
|
|
@@ -810,7 +811,7 @@ var frDiagrams = {
|
|
|
810
811
|
"fretboard.exercise.capo": "capo : utilisez une case de 1 à 12 (0 pour aucun), reçu {text}",
|
|
811
812
|
"fretboard.positions.numbering": "numbering : utilisez minor (positions depuis le relatif mineur), reçu « {text} »",
|
|
812
813
|
"fretboard.positions.numberingPentatonic": "numbering: minor sert aux positions de la pentatonique majeure (par exemple A major pentatonic), pas à {title}",
|
|
813
|
-
"fretboard.positions.numberingCaged": "numbering: minor numérote les positions
|
|
814
|
+
"fretboard.positions.numberingCaged": "numbering: minor numérote les positions (« box ») et 3nps, pas les formes CAGED",
|
|
814
815
|
"fretboard.positions.position": "position doit être un nombre entier à partir de 1, reçu « {text} »",
|
|
815
816
|
"fretboard.positions.shape": "Forme inconnue « {text} » : utilisez C, A, G, E, D ou 3nps",
|
|
816
817
|
"keyboard.fingering.finger": "fingering : les doigts vont de 1 (pouce) à 5 (auriculaire), reçu « {text} »",
|
|
@@ -971,7 +972,7 @@ var frParse = {
|
|
|
971
972
|
"blocks.fretboard.fromMinor": " (depuis {minor}m)",
|
|
972
973
|
"blocks.fretboard.shapeTitle": "{name}, forme {shape}",
|
|
973
974
|
"blocks.fretboard.threeNpsTitle": "{name}, 3nps {n}{from}",
|
|
974
|
-
"blocks.fretboard.boxTitle": "{name},
|
|
975
|
+
"blocks.fretboard.boxTitle": "{name}, position {n}{from}",
|
|
975
976
|
"blocks.scalesFor.both": "Utilisez scales-for (accords) ou scales-for-notes, pas les deux",
|
|
976
977
|
"blocks.scalesFor.findsItself": '{key} trouve la gamme seul : retirez "{what}"',
|
|
977
978
|
"blocks.scalesFor.addChords": "Ajoutez les accords : par ex. scales-for: G D Em C",
|
|
@@ -1020,8 +1021,8 @@ var frParse = {
|
|
|
1020
1021
|
"chord.words.fingerOn": "{finger} sur {strings}, {fret} case.",
|
|
1021
1022
|
"chord.words.fingerBars": "{finger} fait le barré à la {fret} case, cordes {from} à {to}.",
|
|
1022
1023
|
"chord.words.fingerAlsoOn": "{finger} aussi sur {string}, {fret} case.",
|
|
1023
|
-
"chord.words.muteOne": "Étouffez {list} :
|
|
1024
|
-
"chord.words.mutePlural": "Étouffez {list} :
|
|
1024
|
+
"chord.words.muteOne": "Étouffez {list} : laissez un doigt de l'accord l'effleurer.",
|
|
1025
|
+
"chord.words.mutePlural": "Étouffez {list} : laissez un doigt de l'accord les effleurer.",
|
|
1025
1026
|
"chord.words.groupRingOpenOne": "La corde {list} sonne à vide.",
|
|
1026
1027
|
"chord.words.groupRingOpenPlural": "Les cordes {list} sonnent à vide.",
|
|
1027
1028
|
"chord.words.groupRingCapoOne": "La corde {list} sonne au capodastre.",
|
|
@@ -1061,7 +1062,7 @@ var frParse = {
|
|
|
1061
1062
|
"theory.formula.formula": "Formule {formula}.",
|
|
1062
1063
|
"theory.formula.alsoWritten": "S'écrit aussi {list}.",
|
|
1063
1064
|
"theory.formula.scale": "{title} : {notes}.",
|
|
1064
|
-
"theory.formula.steps": "
|
|
1065
|
+
"theory.formula.steps": "Intervalles {steps}.",
|
|
1065
1066
|
"chords.chart.chorus": "Refrain",
|
|
1066
1067
|
"chords.chart.bridge": "Pont",
|
|
1067
1068
|
"chords.chart.tab": "Tablature",
|
|
@@ -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} »",
|
|
@@ -1215,7 +1217,7 @@ var frTimed = {
|
|
|
1215
1217
|
"strum.line.parenUnclosed": "« ) » manquant dans « {line} » : écrivez un coup fantôme ainsi : (U)",
|
|
1216
1218
|
"strum.line.chordEndsPattern": "L’accord [{chord}] termine le rythme : placez-le avant un coup ou un -",
|
|
1217
1219
|
"strum.pattern.chordLineAlone": "Une ligne d’accords demande une ligne de rythme dessous, par exemple D - D U - U D U",
|
|
1218
|
-
"strum.pattern.missing": "Écrivez
|
|
1220
|
+
"strum.pattern.missing": "Écrivez une rythmique, par exemple D - D U - U D U (ou D DU UDU)",
|
|
1219
1221
|
"strum.key.unknown": "Clé « {key} » inconnue : utilisez time, subdivision, swing, chord, tempo, tuning, title ou pattern",
|
|
1220
1222
|
"strum.swing.withTriplets": "Les triolets et le swing sont deux façons d’écrire un shuffle : gardez subdivision: triplets (D - U sur chaque temps), ou écrivez 8ths avec swing: yes",
|
|
1221
1223
|
"strum.swing.compound": "{time} a déjà trois {unit} par temps : retirez swing: (il swingue les 8ths ou les 16ths en 4/4, 3/4, 2/4…)",
|
|
@@ -1240,8 +1242,8 @@ var frTimed = {
|
|
|
1240
1242
|
"strum.feel.swingPercent": "Swing {percent} %",
|
|
1241
1243
|
"strum.feel.swing16": "Swing en doubles croches",
|
|
1242
1244
|
"strum.feel.swing16Percent": "Swing en doubles croches {percent} %",
|
|
1243
|
-
"strum.name": "
|
|
1244
|
-
"strum.name.titled": "{title} :
|
|
1245
|
+
"strum.name": "Rythmique {written}, {time}, {subdivision}{feel}",
|
|
1246
|
+
"strum.name.titled": "{title} : rythmique {written}, {time}, {subdivision}{feel}",
|
|
1245
1247
|
"strum.name.feel": ", {feel}",
|
|
1246
1248
|
"strum.tuning.unknown": "Accordage « {tuning} » inconnu : utilisez par exemple tuning: standard, drop d, ukulele ou E2 A2 D3 G3 B3 E4",
|
|
1247
1249
|
"strum.tuning.tooManyStrings": "12 cordes au plus",
|
|
@@ -1261,7 +1263,7 @@ var frTimed = {
|
|
|
1261
1263
|
"picking.name": "Motif de picking {written}, {time}, {subdivision}{over}",
|
|
1262
1264
|
"picking.name.titled": "{title} : motif de picking {written}, {time}, {subdivision}{over}",
|
|
1263
1265
|
"picking.name.over": ", sur {chords}",
|
|
1264
|
-
"picking.voicing.none": "
|
|
1266
|
+
"picking.voicing.none": "Aucune position jouable de {chord} pour cet accordage",
|
|
1265
1267
|
"export.image.title": "Notation musicale"
|
|
1266
1268
|
};
|
|
1267
1269
|
|
|
@@ -5481,6 +5483,55 @@ function strumVoicing(chord, tuning = STANDARD_TUNING, voicings) {
|
|
|
5481
5483
|
return [...pitches];
|
|
5482
5484
|
}
|
|
5483
5485
|
|
|
5486
|
+
// src/playback/guitar-tone.ts
|
|
5487
|
+
var GUITAR_TONES = ["steel", "nylon", "clean", "overdrive"];
|
|
5488
|
+
var DEFAULT_GUITAR_TONE = "steel";
|
|
5489
|
+
var GUITAR_PROGRAMS = {
|
|
5490
|
+
steel: 25,
|
|
5491
|
+
nylon: 24,
|
|
5492
|
+
clean: 27,
|
|
5493
|
+
overdrive: 29
|
|
5494
|
+
};
|
|
5495
|
+
var ALIASES3 = {
|
|
5496
|
+
acoustic: "steel",
|
|
5497
|
+
"steel-string": "steel",
|
|
5498
|
+
classical: "nylon",
|
|
5499
|
+
"nylon-string": "nylon",
|
|
5500
|
+
electric: "clean",
|
|
5501
|
+
overdriven: "overdrive"
|
|
5502
|
+
};
|
|
5503
|
+
function guitarToneOf(value) {
|
|
5504
|
+
if (typeof value !== "string")
|
|
5505
|
+
return null;
|
|
5506
|
+
const name = value.trim().toLowerCase().replace(/\s+/g, "-");
|
|
5507
|
+
return GUITAR_TONES.find((tone) => tone === name) ?? ALIASES3[name] ?? null;
|
|
5508
|
+
}
|
|
5509
|
+
var LINE = /^[ \t]*guitar[ \t]*:[ \t]*(.*?)[ \t]*(?:\r?\n|$)/gim;
|
|
5510
|
+
var DIRECTIVE = /^[ \t]*\{[ \t]*guitar[ \t]*:[ \t]*(.*?)[ \t]*\}[ \t]*(?:\r?\n|$)/gim;
|
|
5511
|
+
function blockGuitar(source, chart = false) {
|
|
5512
|
+
let guitar = null;
|
|
5513
|
+
const rest = source.replace(chart ? DIRECTIVE : LINE, (_line, value) => {
|
|
5514
|
+
const read = guitarToneOf(value);
|
|
5515
|
+
if (!read) {
|
|
5516
|
+
throw new Error(t("playback.guitar.invalid", { value }));
|
|
5517
|
+
}
|
|
5518
|
+
guitar = read;
|
|
5519
|
+
return "";
|
|
5520
|
+
});
|
|
5521
|
+
return { guitar, source: rest };
|
|
5522
|
+
}
|
|
5523
|
+
function guitarWish(el) {
|
|
5524
|
+
return guitarToneOf(el?.closest("[data-mn-guitar]")?.getAttribute("data-mn-guitar"));
|
|
5525
|
+
}
|
|
5526
|
+
function pageGuitar(options) {
|
|
5527
|
+
if (!options || typeof options !== "object" || !("play" in options))
|
|
5528
|
+
return;
|
|
5529
|
+
const play = options.play;
|
|
5530
|
+
if (!play || typeof play !== "object" || !("guitar" in play))
|
|
5531
|
+
return;
|
|
5532
|
+
return guitarToneOf(play.guitar) ?? undefined;
|
|
5533
|
+
}
|
|
5534
|
+
|
|
5484
5535
|
// src/playback/player.ts
|
|
5485
5536
|
var DEFAULT_SEQUENCE = { bpm: 90, strum: 12 };
|
|
5486
5537
|
var DEFAULT_STRUM = { guitar: 12, piano: 0 };
|
|
@@ -5574,8 +5625,21 @@ function pluckedString(midi, sampleRate, seconds, random = Math.random, options
|
|
|
5574
5625
|
out[i] = value * 0.5;
|
|
5575
5626
|
at = next;
|
|
5576
5627
|
}
|
|
5628
|
+
const drive = options.drive !== undefined && Number.isFinite(options.drive) ? Math.max(0, options.drive) : 0;
|
|
5629
|
+
if (drive > 0) {
|
|
5630
|
+
const push = 1 + drive;
|
|
5631
|
+
for (let i = 0;i < out.length; i++)
|
|
5632
|
+
out[i] = Math.tanh(out[i] * 2 * push) * OVERDRIVE_LEVEL;
|
|
5633
|
+
}
|
|
5577
5634
|
return out;
|
|
5578
5635
|
}
|
|
5636
|
+
var OVERDRIVE_LEVEL = 0.18;
|
|
5637
|
+
var TONE_PLUCKS = {
|
|
5638
|
+
steel: { brightness: [0.55, 0.95], pick: [0.08, 0.2], damping: [0.85, 1.15], drive: 0 },
|
|
5639
|
+
nylon: { brightness: [0.05, 0.25], pick: [0.2, 0.34], damping: [2.2, 2.8], drive: 0 },
|
|
5640
|
+
clean: { brightness: [0.7, 1], pick: [0.1, 0.18], damping: [0.55, 0.75], drive: 0 },
|
|
5641
|
+
overdrive: { brightness: [0.7, 1], pick: [0.1, 0.18], damping: [0.45, 0.6], drive: 5 }
|
|
5642
|
+
};
|
|
5579
5643
|
function pianoTone(midi, sampleRate, seconds) {
|
|
5580
5644
|
const out = new Float32Array(Math.round(sampleRate * seconds));
|
|
5581
5645
|
const f = frequency(midi);
|
|
@@ -5661,14 +5725,16 @@ function lightPlayer(win, random = Math.random) {
|
|
|
5661
5725
|
const strings = new Map;
|
|
5662
5726
|
const waves = new WeakMap;
|
|
5663
5727
|
const between = (lo, hi) => lo + (hi - lo) * random();
|
|
5664
|
-
const stringBuffer = (ctx, midi, pluck) => {
|
|
5665
|
-
const key = midi * PLUCKS + pluck
|
|
5728
|
+
const stringBuffer = (ctx, midi, pluck, tone) => {
|
|
5729
|
+
const key = `${tone}:${midi * PLUCKS + pluck}`;
|
|
5666
5730
|
let buffer = strings.get(key);
|
|
5667
5731
|
if (!buffer) {
|
|
5732
|
+
const ranges = TONE_PLUCKS[tone];
|
|
5668
5733
|
const data = pluckedString(midi, ctx.sampleRate, STRING_SECONDS, random, {
|
|
5669
|
-
brightness: between(0
|
|
5670
|
-
pick: between(0
|
|
5671
|
-
damping: between(0
|
|
5734
|
+
brightness: between(ranges.brightness[0], ranges.brightness[1]),
|
|
5735
|
+
pick: between(ranges.pick[0], ranges.pick[1]),
|
|
5736
|
+
damping: between(ranges.damping[0], ranges.damping[1]),
|
|
5737
|
+
...ranges.drive ? { drive: ranges.drive } : {}
|
|
5672
5738
|
});
|
|
5673
5739
|
buffer = ctx.createBuffer(1, data.length, ctx.sampleRate);
|
|
5674
5740
|
buffer.getChannelData(0).set(data);
|
|
@@ -5687,10 +5753,11 @@ function lightPlayer(win, random = Math.random) {
|
|
|
5687
5753
|
};
|
|
5688
5754
|
return {
|
|
5689
5755
|
reportsStart: true,
|
|
5690
|
-
play(events, { sound, volume, onEnd, onStart }) {
|
|
5756
|
+
play(events, { sound, volume, onEnd, onStart, guitar }) {
|
|
5691
5757
|
const ctx = contextFor(win);
|
|
5692
5758
|
if (!ctx || !events.length)
|
|
5693
5759
|
return { stop() {} };
|
|
5760
|
+
const tone = guitar ?? DEFAULT_GUITAR_TONE;
|
|
5694
5761
|
const resumed = ctx.resume();
|
|
5695
5762
|
const touches = events.map(() => ({
|
|
5696
5763
|
pluck: Math.min(PLUCKS - 1, Math.floor(random() * PLUCKS)),
|
|
@@ -5701,9 +5768,9 @@ function lightPlayer(win, random = Math.random) {
|
|
|
5701
5768
|
if (sound === "guitar")
|
|
5702
5769
|
events.forEach((e, i) => {
|
|
5703
5770
|
if (e.kind === "muted")
|
|
5704
|
-
stringBuffer(ctx, e.midi, 0);
|
|
5771
|
+
stringBuffer(ctx, e.midi, 0, tone);
|
|
5705
5772
|
else if (!e.kind)
|
|
5706
|
-
stringBuffer(ctx, e.midi, touches[i].pluck);
|
|
5773
|
+
stringBuffer(ctx, e.midi, touches[i].pluck, tone);
|
|
5707
5774
|
});
|
|
5708
5775
|
const gain = ctx.createGain();
|
|
5709
5776
|
gain.gain.value = Number.isFinite(volume) ? Math.min(1, Math.max(0, volume)) : 0.8;
|
|
@@ -5711,7 +5778,7 @@ function lightPlayer(win, random = Math.random) {
|
|
|
5711
5778
|
const start = ctx.currentTime + 0.05;
|
|
5712
5779
|
const sources = events.map((e, i) => {
|
|
5713
5780
|
if (e.kind)
|
|
5714
|
-
return percussive(ctx, gain, e, start, sound, (c, m) => stringBuffer(c, m, 0));
|
|
5781
|
+
return percussive(ctx, gain, e, start, sound, (c, m) => stringBuffer(c, m, 0, tone));
|
|
5715
5782
|
const touch = touches[i];
|
|
5716
5783
|
const at = start + e.time;
|
|
5717
5784
|
const end = at + e.duration;
|
|
@@ -5722,7 +5789,7 @@ function lightPlayer(win, random = Math.random) {
|
|
|
5722
5789
|
let source;
|
|
5723
5790
|
if (sound === "guitar") {
|
|
5724
5791
|
const buffer = ctx.createBufferSource();
|
|
5725
|
-
buffer.buffer = stringBuffer(ctx, e.midi, touch.pluck);
|
|
5792
|
+
buffer.buffer = stringBuffer(ctx, e.midi, touch.pluck, tone);
|
|
5726
5793
|
buffer.playbackRate.value = Math.pow(2, touch.cents / 1200);
|
|
5727
5794
|
source = buffer;
|
|
5728
5795
|
env.gain.setValueAtTime(level, at);
|
|
@@ -6730,11 +6797,11 @@ function chooseEngine(wish, has) {
|
|
|
6730
6797
|
}
|
|
6731
6798
|
return null;
|
|
6732
6799
|
}
|
|
6733
|
-
var
|
|
6734
|
-
var
|
|
6800
|
+
var LINE2 = /^[ \t]*engine[ \t]*:[ \t]*(.*?)[ \t]*(?:\r?\n|$)/gim;
|
|
6801
|
+
var DIRECTIVE2 = /^[ \t]*\{[ \t]*engine[ \t]*:[ \t]*(.*?)[ \t]*\}[ \t]*(?:\r?\n|$)/gim;
|
|
6735
6802
|
function blockEngine(source, chart = false) {
|
|
6736
6803
|
let engine = null;
|
|
6737
|
-
const rest = source.replace(chart ?
|
|
6804
|
+
const rest = source.replace(chart ? DIRECTIVE2 : LINE2, (_line, value) => {
|
|
6738
6805
|
const read = engineOf(value);
|
|
6739
6806
|
if (!read) {
|
|
6740
6807
|
throw new Error(t("playback.engine.invalid", { value }));
|
|
@@ -7882,7 +7949,7 @@ function barPlayer(wrap, win, options) {
|
|
|
7882
7949
|
try {
|
|
7883
7950
|
return chosen.play(events, given);
|
|
7884
7951
|
} catch {
|
|
7885
|
-
return lightFor(here).play(events, opts);
|
|
7952
|
+
return toned(lightFor(here), options, wrap).play(events, opts);
|
|
7886
7953
|
}
|
|
7887
7954
|
}
|
|
7888
7955
|
};
|
|
@@ -8162,7 +8229,7 @@ var PICKING_PATTERNS = {
|
|
|
8162
8229
|
"alternate bass": { name: "Alternate bass", slots: "p i m i p' i m i" },
|
|
8163
8230
|
"1-2-3-4": { name: "1-2-3-4", slots: "p i m a p i m a" }
|
|
8164
8231
|
};
|
|
8165
|
-
var
|
|
8232
|
+
var ALIASES4 = {
|
|
8166
8233
|
"travis picking": "travis",
|
|
8167
8234
|
"alternating bass": "alternate bass",
|
|
8168
8235
|
"alternate-bass": "alternate bass",
|
|
@@ -8172,7 +8239,7 @@ var ALIASES3 = {
|
|
|
8172
8239
|
};
|
|
8173
8240
|
function namedPicking(text) {
|
|
8174
8241
|
const t = text.trim().toLowerCase().replace(/\s+/g, " ");
|
|
8175
|
-
const key =
|
|
8242
|
+
const key = ALIASES4[t] ?? t;
|
|
8176
8243
|
return PICKING_PATTERNS[key] ? key : null;
|
|
8177
8244
|
}
|
|
8178
8245
|
var KEYS2 = [
|
|
@@ -8817,7 +8884,7 @@ function diagramGroup(doc, win, diagrams, options, how) {
|
|
|
8817
8884
|
try {
|
|
8818
8885
|
return run(playerFor(here, options, item.wrap));
|
|
8819
8886
|
} catch {
|
|
8820
|
-
return run(lightFor(here));
|
|
8887
|
+
return run(toned(lightFor(here), options, item.wrap));
|
|
8821
8888
|
}
|
|
8822
8889
|
};
|
|
8823
8890
|
const select = (item) => {
|
|
@@ -9097,6 +9164,42 @@ function lightFor(win) {
|
|
|
9097
9164
|
return player;
|
|
9098
9165
|
}
|
|
9099
9166
|
function playerFor(win, options, el) {
|
|
9167
|
+
return toned(enginePlayerFor(win, options, el), options, el);
|
|
9168
|
+
}
|
|
9169
|
+
function toned(player, options, el) {
|
|
9170
|
+
const tone = guitarFor(options, el);
|
|
9171
|
+
return tone ? withGuitar(player, tone) : player;
|
|
9172
|
+
}
|
|
9173
|
+
function guitarFor(options, el) {
|
|
9174
|
+
const wish = guitarWish(el);
|
|
9175
|
+
if (wish)
|
|
9176
|
+
return wish;
|
|
9177
|
+
try {
|
|
9178
|
+
return guitarToneOf(typeof options.guitar === "function" ? options.guitar() : options.guitar);
|
|
9179
|
+
} catch {
|
|
9180
|
+
return null;
|
|
9181
|
+
}
|
|
9182
|
+
}
|
|
9183
|
+
var guitarPlayers = new WeakMap;
|
|
9184
|
+
function withGuitar(player, guitar) {
|
|
9185
|
+
let twins = guitarPlayers.get(player);
|
|
9186
|
+
if (!twins) {
|
|
9187
|
+
twins = new Map;
|
|
9188
|
+
guitarPlayers.set(player, twins);
|
|
9189
|
+
}
|
|
9190
|
+
let twin = twins.get(guitar);
|
|
9191
|
+
if (!twin) {
|
|
9192
|
+
twin = {
|
|
9193
|
+
get reportsStart() {
|
|
9194
|
+
return player.reportsStart;
|
|
9195
|
+
},
|
|
9196
|
+
play: (events, options) => player.play(events, options.guitar ? options : { ...options, guitar })
|
|
9197
|
+
};
|
|
9198
|
+
twins.set(guitar, twin);
|
|
9199
|
+
}
|
|
9200
|
+
return twin;
|
|
9201
|
+
}
|
|
9202
|
+
function enginePlayerFor(win, options, el) {
|
|
9100
9203
|
const engines = options.engines;
|
|
9101
9204
|
if (engines) {
|
|
9102
9205
|
const chosen = chooseEngine(engineWish(el) ?? engineOf(options.engine), (engine) => {
|
|
@@ -14198,6 +14301,10 @@ function drawBlock(language, source, host, given) {
|
|
|
14198
14301
|
text = wish.source;
|
|
14199
14302
|
if (wish.engine)
|
|
14200
14303
|
el.setAttribute("data-mn-engine", wish.engine);
|
|
14304
|
+
const tone = blockGuitar(text, language === "chords");
|
|
14305
|
+
text = tone.source;
|
|
14306
|
+
if (tone.guitar)
|
|
14307
|
+
el.setAttribute("data-mn-guitar", tone.guitar);
|
|
14201
14308
|
} catch (e) {
|
|
14202
14309
|
return failed(el, host, language, messageOf(e));
|
|
14203
14310
|
}
|
|
@@ -16738,9 +16845,10 @@ function regionsFor(preset, key, velocity) {
|
|
|
16738
16845
|
}
|
|
16739
16846
|
|
|
16740
16847
|
// src/playback/sampled.ts
|
|
16741
|
-
var
|
|
16848
|
+
var PIANO = 0;
|
|
16742
16849
|
var MUTED = 28;
|
|
16743
16850
|
var CLICK_KEY = 33;
|
|
16851
|
+
var programOf = (kind) => kind === "muted" ? MUTED : kind === "piano" ? PIANO : GUITAR_PROGRAMS[kind];
|
|
16744
16852
|
var LONGEST_RELEASE = 2.5;
|
|
16745
16853
|
var SILENCE = 0.00001;
|
|
16746
16854
|
function loopWithin(loop, duration) {
|
|
@@ -16758,7 +16866,7 @@ function sampledPlayer(win, source, fallback, options = {}) {
|
|
|
16758
16866
|
const contextOf = () => options.context?.() ?? contextFor(win);
|
|
16759
16867
|
const load = async (kind, ctx) => {
|
|
16760
16868
|
const sounds = kind === "click" ? { programs: [], drums: false } : {
|
|
16761
|
-
programs: [kind
|
|
16869
|
+
programs: [programOf(kind)],
|
|
16762
16870
|
drums: false,
|
|
16763
16871
|
click: false
|
|
16764
16872
|
};
|
|
@@ -16809,7 +16917,7 @@ function sampledPlayer(win, source, fallback, options = {}) {
|
|
|
16809
16917
|
}
|
|
16810
16918
|
return voice;
|
|
16811
16919
|
};
|
|
16812
|
-
const kindOf = (e, sound) => e.kind === "click" ? "click" :
|
|
16920
|
+
const kindOf = (e, sound, guitar) => e.kind === "click" ? "click" : sound === "piano" ? "piano" : e.kind === "muted" ? "muted" : guitar;
|
|
16813
16921
|
const sound = (ctx, out, voice, region, key, level, at, end) => {
|
|
16814
16922
|
const buffer = voice.buffers.get(region.sample);
|
|
16815
16923
|
if (!buffer)
|
|
@@ -16872,15 +16980,23 @@ function sampledPlayer(win, source, fallback, options = {}) {
|
|
|
16872
16980
|
};
|
|
16873
16981
|
return {
|
|
16874
16982
|
reportsStart: true,
|
|
16875
|
-
play(events, { sound: instrument, volume, onEnd, onStart }) {
|
|
16983
|
+
play(events, { sound: instrument, volume, onEnd, onStart, guitar }) {
|
|
16876
16984
|
const ctx = contextOf();
|
|
16985
|
+
const tone = guitar ?? DEFAULT_GUITAR_TONE;
|
|
16986
|
+
const same = guitar ? { guitar } : {};
|
|
16877
16987
|
if (!ctx)
|
|
16878
|
-
return fallback.play(events, {
|
|
16988
|
+
return fallback.play(events, {
|
|
16989
|
+
sound: instrument,
|
|
16990
|
+
volume,
|
|
16991
|
+
...onEnd ? { onEnd } : {},
|
|
16992
|
+
...onStart ? { onStart } : {},
|
|
16993
|
+
...same
|
|
16994
|
+
});
|
|
16879
16995
|
let stopped = false;
|
|
16880
16996
|
let handle = null;
|
|
16881
16997
|
let level = Number.isFinite(volume) ? Math.min(1, Math.max(0, volume)) : 0.8;
|
|
16882
16998
|
const resumed = "resume" in ctx ? ctx.resume() : Promise.resolve();
|
|
16883
|
-
const kinds = [...new Set(events.map((e) => kindOf(e, instrument)))];
|
|
16999
|
+
const kinds = [...new Set(events.map((e) => kindOf(e, instrument, tone)))];
|
|
16884
17000
|
Promise.all(kinds.map((kind) => voiceOf(kind, ctx))).then((loaded) => {
|
|
16885
17001
|
if (stopped)
|
|
16886
17002
|
return;
|
|
@@ -16889,7 +17005,8 @@ function sampledPlayer(win, source, fallback, options = {}) {
|
|
|
16889
17005
|
sound: instrument,
|
|
16890
17006
|
volume: level,
|
|
16891
17007
|
...onEnd ? { onEnd } : {},
|
|
16892
|
-
...onStart ? { onStart } : {}
|
|
17008
|
+
...onStart ? { onStart } : {},
|
|
17009
|
+
...same
|
|
16893
17010
|
});
|
|
16894
17011
|
if (!fallback.reportsStart)
|
|
16895
17012
|
onStart?.();
|
|
@@ -16903,7 +17020,7 @@ function sampledPlayer(win, source, fallback, options = {}) {
|
|
|
16903
17020
|
const sources = [];
|
|
16904
17021
|
let tail = 0;
|
|
16905
17022
|
for (const e of events) {
|
|
16906
|
-
const kind = kindOf(e, instrument);
|
|
17023
|
+
const kind = kindOf(e, instrument, tone);
|
|
16907
17024
|
const voice = byKind.get(kind);
|
|
16908
17025
|
const velocity = e.velocity === undefined || !Number.isFinite(e.velocity) ? 100 : Math.round(Math.min(127, Math.max(1, e.velocity)));
|
|
16909
17026
|
const key = kind === "click" ? CLICK_KEY : e.midi;
|
|
@@ -17856,12 +17973,15 @@ export {
|
|
|
17856
17973
|
BLUES_SCALES,
|
|
17857
17974
|
CAGED_SHAPES,
|
|
17858
17975
|
DEFAULT_EXERCISE_TEMPO,
|
|
17976
|
+
DEFAULT_GUITAR_TONE,
|
|
17859
17977
|
DEFAULT_PROPERTY_NAMES,
|
|
17860
17978
|
DEFAULT_SEQUENCE,
|
|
17861
17979
|
DEFAULT_STRUM,
|
|
17862
17980
|
DEFAULT_STRUM_CHORD,
|
|
17863
17981
|
ENGINES,
|
|
17864
17982
|
FLAT_NAMES,
|
|
17983
|
+
GUITAR_PROGRAMS,
|
|
17984
|
+
GUITAR_TONES,
|
|
17865
17985
|
HARMONIZE_KINDS,
|
|
17866
17986
|
LANGUAGES,
|
|
17867
17987
|
LANGUAGES_OF_TEXTS,
|
|
@@ -17929,6 +18049,7 @@ export {
|
|
|
17929
18049
|
formatStrum,
|
|
17930
18050
|
fretsFromCapo,
|
|
17931
18051
|
generateVoicings,
|
|
18052
|
+
guitarToneOf,
|
|
17932
18053
|
harmonicFunction,
|
|
17933
18054
|
harmonize,
|
|
17934
18055
|
inKey,
|
|
@@ -17970,6 +18091,7 @@ export {
|
|
|
17970
18091
|
noteTargets,
|
|
17971
18092
|
numeralOf,
|
|
17972
18093
|
pageEngine,
|
|
18094
|
+
pageGuitar,
|
|
17973
18095
|
pageInstruments,
|
|
17974
18096
|
parentMajor,
|
|
17975
18097
|
parseCapo,
|
|
@@ -18072,5 +18194,5 @@ export {
|
|
|
18072
18194
|
withTonicizations
|
|
18073
18195
|
};
|
|
18074
18196
|
|
|
18075
|
-
//# debugId=
|
|
18197
|
+
//# debugId=3A1E1BEF24D884B064756E2164756E21
|
|
18076
18198
|
//# sourceMappingURL=index.js.map
|