@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/README.md
CHANGED
|
@@ -158,7 +158,7 @@ if (!result.ok) console.warn(result.error)
|
|
|
158
158
|
|
|
159
159
|
- `renderBlock(language, source, host, options)` appends the rendering to `host` and never throws. It returns `{ ok, el, error, destroy() }`.
|
|
160
160
|
- `@dsebastien/music-notation/voicings` adds about 1,800 guitar voicings, found by chord symbol (`chord` blocks with only a symbol). It's a separate entry point because the data weighs about 230 KB.
|
|
161
|
-
- **Hear the diagrams**: with the `play` option, a click on a diagram plays it and a click on a dot or a key plays that note; one bar under each block plays the selected diagram or all of them in turn, with loop, speed and the sound (the volume is the app's setting). Guitar chords strum, piano chords strike as a block, scales run from their tonic up and back. While it plays, each note lights up on the drawing when you hear it.
|
|
161
|
+
- **Hear the diagrams**: with the `play` option, a click on a diagram plays it and a click on a dot or a key plays that note; one bar under each block plays the selected diagram or all of them in turn, with loop, speed and the sound (the volume is the app's setting). Guitar chords strum, piano chords strike as a block, scales run from their tonic up and back. Four guitars can play them: a steel-string acoustic (the default), a classical, a clean electric or an overdriven electric guitar (`guitar: nylon` in a block, or the app's choice). While it plays, each note lights up on the drawing when you hear it.
|
|
162
162
|
- **Strumming patterns**: `strum` blocks draw a pattern (`D DU UDU`, `D - D U - U D U`) on a beat grid with counts, accents, muted and ghost strums and chord changes; with playback on, they play over their chords, with loop, tempo and a count-in. `playStrum(pattern, { bpm, chord, tuning })` plays one from code.
|
|
163
163
|
- **Practice in time**: `progression` blocks and ChordPro charts get a bar that plays their chords in time, one chord a bar (or as a chart's bar lines say), with a metronome click, a count-in and a loop. Each chord is strummed on the beats, once a bar, as an arpeggio or to a strumming pattern, and the chord playing lights up. `playProgression(chords, { bpm, strum, pattern, click, countIn, loop })` does it from code, with your own player.
|
|
164
164
|
- **Harmonize a scale**: a `progression` block with `harmonize: triads`, `sevenths`, `sus` or `power` and any 7-note scale as its `key:` (`A harmonic minor`, `D dorian`) draws the chord on each degree with its numeral and a diagram, ready to play in time. `harmonize(scale, { kind })` gives the same chords from code.
|
|
@@ -191,7 +191,7 @@ Add this to your site's `publish.js`. It loads the bundle only on pages that hav
|
|
|
191
191
|
|
|
192
192
|
```js
|
|
193
193
|
;(() => {
|
|
194
|
-
const VERSION = '0.23.
|
|
194
|
+
const VERSION = '0.23.1'
|
|
195
195
|
const CDN = `https://cdn.jsdelivr.net/npm/@dsebastien/music-notation@${VERSION}/dist`
|
|
196
196
|
const selector = (languages) => languages.map((l) => `pre > code.language-${l}`).join(', ')
|
|
197
197
|
const BLOCKS = selector([
|
|
@@ -224,6 +224,8 @@ Add this to your site's `publish.js`. It loads the bundle only on pages that hav
|
|
|
224
224
|
|
|
225
225
|
The bundle renders every block, now and as you navigate, and hides a block's source only once it rendered.
|
|
226
226
|
|
|
227
|
+
The same bundles work on any other website, and the package in an app: see [Websites and apps](https://dsebastien.github.io/music-notation/websites-and-apps.html).
|
|
228
|
+
|
|
227
229
|
## Credits and licenses
|
|
228
230
|
|
|
229
231
|
MIT. Built on [tonal](https://github.com/tonaljs/tonal) (MIT) for music theory and [chords-db](https://github.com/tombatossals/chords-db) (MIT) for guitar voicings. The `check` command bundles [linkedom](https://github.com/WebReflection/linkedom) (ISC) for the DOM in Node. Tabs and scores use [alphaTab](https://alphatab.net) (MPL-2.0), which the app passes in. The tab bundle loads it from jsDelivr.
|
package/dist/i18n/en/index.d.ts
CHANGED
|
@@ -39,6 +39,7 @@ export declare const en: {
|
|
|
39
39
|
readonly 'playback.redraw.guitar': "{name}, drawn for guitar";
|
|
40
40
|
readonly 'playback.redraw.piano': "{name}, drawn for piano";
|
|
41
41
|
readonly 'playback.engine.invalid': "engine: use generaluser, sonivox or light, got \"{value}\"";
|
|
42
|
+
readonly 'playback.guitar.invalid': "guitar: use steel, nylon, clean or overdrive, got \"{value}\"";
|
|
42
43
|
readonly 'tab.source.staves': "staves: use tab, score or both, got \"{value}\"";
|
|
43
44
|
readonly 'tab.source.layout': "layout: use page or line, got \"{value}\"";
|
|
44
45
|
readonly 'tab.source.names': "names: use on or off, got \"{value}\"";
|
package/dist/i18n/en/play.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare const enPlay: {
|
|
|
40
40
|
readonly 'playback.redraw.guitar': "{name}, drawn for guitar";
|
|
41
41
|
readonly 'playback.redraw.piano': "{name}, drawn for piano";
|
|
42
42
|
readonly 'playback.engine.invalid': "engine: use generaluser, sonivox or light, got \"{value}\"";
|
|
43
|
+
readonly 'playback.guitar.invalid': "guitar: use steel, nylon, clean or overdrive, got \"{value}\"";
|
|
43
44
|
readonly 'tab.source.staves': "staves: use tab, score or both, got \"{value}\"";
|
|
44
45
|
readonly 'tab.source.layout': "layout: use page or line, got \"{value}\"";
|
|
45
46
|
readonly 'tab.source.names': "names: use on or off, got \"{value}\"";
|
package/dist/i18n/fr/play.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ export declare const frPlay: {
|
|
|
40
40
|
readonly 'playback.redraw.guitar': "{name}, dessiné pour la guitare";
|
|
41
41
|
readonly 'playback.redraw.piano': "{name}, dessiné pour le piano";
|
|
42
42
|
readonly 'playback.engine.invalid': "engine: utilisez generaluser, sonivox ou light, reçu « {value} »";
|
|
43
|
+
readonly 'playback.guitar.invalid': "guitar: utilisez steel, nylon, clean ou overdrive, reçu « {value} »";
|
|
43
44
|
readonly 'tab.source.staves': "staves: utilisez tab, score ou both, reçu « {value} »";
|
|
44
45
|
readonly 'tab.source.layout': "layout: utilisez page ou line, reçu « {value} »";
|
|
45
46
|
readonly 'tab.source.names': "names: utilisez on ou off, reçu « {value} »";
|
package/dist/i18n/language.d.ts
CHANGED
|
@@ -41,6 +41,7 @@ export declare const TABLES: {
|
|
|
41
41
|
readonly 'playback.redraw.guitar': "{name}, drawn for guitar";
|
|
42
42
|
readonly 'playback.redraw.piano': "{name}, drawn for piano";
|
|
43
43
|
readonly 'playback.engine.invalid': "engine: use generaluser, sonivox or light, got \"{value}\"";
|
|
44
|
+
readonly 'playback.guitar.invalid': "guitar: use steel, nylon, clean or overdrive, got \"{value}\"";
|
|
44
45
|
readonly 'tab.source.staves': "staves: use tab, score or both, got \"{value}\"";
|
|
45
46
|
readonly 'tab.source.layout': "layout: use page or line, got \"{value}\"";
|
|
46
47
|
readonly 'tab.source.names': "names: use on or off, got \"{value}\"";
|
|
@@ -532,7 +533,7 @@ export declare const TABLES: {
|
|
|
532
533
|
readonly 'theory.marks.different': ", different from the compared scale: {notes}";
|
|
533
534
|
readonly 'theory.marks.chordTones': ", chord tones: {notes}";
|
|
534
535
|
};
|
|
535
|
-
readonly fr: Record<"playback.bar" | "playback.diagram" | "playback.place" | "playback.playItem" | "playback.playAll" | "playback.play" | "playback.stop" | "playback.loop" | "playback.countIn" | "playback.click" | "playback.sound" | "playback.guitar" | "playback.piano" | "playback.tempo" | "playback.unit.bpm" | "playback.unit.ms" | "playback.strum" | "playback.dotted" | "playback.strumPattern.bar" | "playback.picking.bar" | "playback.progression.bar" | "playback.progression.play" | "playback.strumChoice" | "playback.strum.beats" | "playback.strum.bar" | "playback.strum.arpeggio" | "playback.strum.pattern" | "playback.copy.button" | "playback.copy.hint" | "playback.copy.bar" | "playback.copy.copied" | "playback.copy.refused" | "playback.copy.unsupported" | "playback.copy.failed" | "playback.full.enter" | "playback.full.exit" | "playback.redraw.sounds" | "playback.redraw.guitar" | "playback.redraw.piano" | "playback.engine.invalid" | "tab.source.staves" | "tab.source.layout" | "tab.source.names" | "tab.source.tracks" | "tab.source.empty" | "tab.sound.loadFailed" | "tab.error.at" | "tab.error.textTab" | "tab.error.fileRead" | "tab.error.fileMissing" | "tab.error.fileUnknown" | "tab.player.cantPlay" | "tab.player.metronome" | "tab.player.pause" | "tab.names" | "tab.follow" | "tab.followPaused" | "tab.view.group" | "tab.view.tab" | "tab.view.score" | "tab.view.both" | "tab.view.whatTab" | "tab.view.whatScore" | "tab.view.whatBoth" | "tab.view.drawAs" | "tab.view.drawAsWritten" | "tab.view.drawAsDefault" | "tab.view.keep" | "tab.view.keepTitle" | "tab.tempo.group" | "tab.tempo.slower" | "tab.tempo.faster" | "tab.tempo.toPercent" | "tab.tempo.toBpm" | "tab.tempo.reset" | "tab.tempo.inBpm" | "tab.tempo.inPercent" | "tab.tempo.title" | "tab.tempo.speedTitle" | "strum.time.invalid" | "strum.swing.invalid" | "strum.subdivision.invalid" | "strum.triplets.quarterBeat68" | "strum.triplets.quarterBeat" | "strum.subdivision.tooLong" | "strum.chord.notRecognizedTry" | "strum.chord.empty" | "strum.chord.notRecognized" | "strum.line.bracketMissing" | "strum.line.barInGhost" | "strum.line.accentAndGhost" | "strum.line.ghostNested" | "strum.line.parenUnopened" | "strum.help" | "strum.line.notUnderstood" | "strum.line.accentNeedsStrum" | "strum.line.ghostNoRests" | "strum.line.parenUnclosed" | "strum.line.chordEndsPattern" | "strum.pattern.chordLineAlone" | "strum.pattern.missing" | "strum.key.unknown" | "strum.swing.withTriplets" | "strum.swing.compound" | "strum.swing.oneSlot" | "strum.tempo.invalid" | "strum.bars.tooMany" | "strum.chord.pastEnd" | "strum.count.bar.one" | "strum.count.bar.other" | "strum.count.slot.one" | "strum.count.slot.other" | "strum.count.barsAndSlots" | "strum.count.spill" | "strum.count.spillOrTime" | "strum.count.mismatch" | "strum.count.alternative.first" | "strum.count.alternative.next" | "strum.count.alternative.last" | "strum.note.one" | "strum.note.other" | "strum.feel.swing" | "strum.feel.swingPercent" | "strum.feel.swing16" | "strum.feel.swing16Percent" | "strum.name" | "strum.name.titled" | "strum.name.feel" | "strum.tuning.unknown" | "strum.tuning.tooManyStrings" | "strum.tuning.unknownGiven" | "picking.help" | "picking.token.notUnderstood" | "picking.string.missing" | "picking.bar.slots" | "picking.bar.betweenBarLines" | "picking.key.unknown" | "picking.swing.pairs" | "picking.tempo.invalid" | "picking.pattern.twice" | "picking.pattern.missing" | "picking.chords.tooMany" | "picking.tuning.unknown" | "picking.name" | "picking.name.titled" | "picking.name.over" | "picking.voicing.none" | "export.image.title" | "render.layout.orientation" | "render.layout.hand" | "render.rootMark.invalid" | "render.rootListsOnly" | "render.unknownChord" | "render.tuning" | "render.yesNo" | "render.hand.left" | "render.hand.right" | "render.positions.exerciseOne" | "render.positions.needsSet" | "render.positions.arpeggioCaged" | "render.positions.range" | "render.positions.fromMinor" | "render.positions.arpeggioTitle" | "render.positions.shapeTitle" | "render.positions.npsTitle" | "render.positions.boxTitle" | "render.fingering.handTitle" | "render.voicings.notBoth" | "render.voicings.fretted" | "render.voicings.noFrets" | "render.voicings.needsChord" | "render.voicings.instrument" | "render.voicings.maxStrings" | "render.voicings.count" | "render.voicings.area" | "render.voicings.rootString" | "render.voicings.inversion" | "render.voicings.manyStringsAny" | "render.voicings.wideArea" | "render.voicings.oneWidening" | "render.noVoicing.gaps" | "render.noVoicing.rootString" | "render.noVoicing.inversion" | "render.noVoicing.bass" | "render.noVoicing.none" | "render.triads.noFrets" | "render.triads.fretted" | "render.triads.strings" | "render.triads.inversion" | "render.triads.keyInversion" | "render.triads.key" | "render.triads.needsChord" | "render.triads.notTriad" | "render.triads.none" | "render.transitions.needsFrom" | "render.transitions.fretted" | "render.transitions.notBoth" | "render.transitions.refused" | "render.transitions.maxStrings" | "render.transitions.twoChords" | "render.transitions.maxChords" | "render.transitions.noVoicings" | "render.transitions.needsTo" | "render.transitions.noHeld" | "render.transitions.stringCount" | "render.transitions.count" | "render.transitions.noTarget" | "render.modes.none" | "render.modes.refused" | "render.row.notShared" | "render.row.columns" | "render.row.needsDiagram" | "render.row.max" | "render.row.columnsShared" | "render.row.ownRow" | "render.row.exercise" | "render.row.diagram" | "render.row.sharedHint" | "fretboard.capo" | "fretboard.title" | "fretboard.note.open" | "fretboard.note.fret" | "fretboard.note.root" | "fretboard.string" | "fretboard.pick.open" | "fretboard.pick.fret" | "fretboard.exercise.direction" | "fretboard.exercise.rhythm" | "fretboard.exercise.scale" | "fretboard.exercise.chord" | "fretboard.exercise.needsSet" | "fretboard.exercise.arpeggioCaged" | "fretboard.exercise.positions" | "fretboard.exercise.tuning" | "fretboard.exercise.capo" | "fretboard.positions.numbering" | "fretboard.positions.numberingPentatonic" | "fretboard.positions.numberingCaged" | "fretboard.positions.position" | "fretboard.positions.shape" | "keyboard.fingering.finger" | "keyboard.fingering.autoNeedsScale" | "keyboard.fingering.autoUnknown" | "keyboard.piano.shell" | "keyboard.piano.rootless" | "keyboard.piano.octave" | "keyboard.piano.inversion" | "keyboard.piano.slashInversion" | "keyboard.piano.inversionStyle" | "keyboard.piano.inversionMax" | "keyboard.piano.open" | "keyboard.piano.offKeys" | "keyboard.piano.inversionWord" | "keyboard.piano.octaveMiddle" | "keyboard.piano.voicing" | "keyboard.piano.key" | "keyboard.piano.resolvesTo" | "keyboard.piano.hands" | "keyboard.title" | "keyboard.hand" | "keyboard.handMark.left" | "keyboard.handMark.right" | "keyboard.whiteKey" | "keyboard.blackKey" | "keyboard.lit.root" | "keyboard.lit.finger" | "keyboard.lit.keys" | "circle.label" | "circle.or" | "circle.mode.major" | "circle.mode.minor" | "circle.mode.ionian" | "circle.mode.dorian" | "circle.mode.phrygian" | "circle.mode.lydian" | "circle.mode.mixolydian" | "circle.mode.aeolian" | "circle.mode.locrian" | "circle.key" | "circle.mode" | "circle.modeTwice" | "circle.chords" | "circle.dominant" | "keyboard.piano.unknownChord" | "blocks.source.expected" | "blocks.source.strings" | "blocks.caption.fingeringChordOnly" | "blocks.caption.useAll" | "blocks.caption.useFormula" | "blocks.noteSet.chordOrArpeggio" | "blocks.noteSet.invalidRoot" | "blocks.noteSet.notAList" | "blocks.noteSet.addNotesForRoot" | "blocks.noteSet.addRoot" | "blocks.noteSet.addSource" | "blocks.noteSet.rootListsOnlyScale" | "blocks.noteSet.rootListsOnlyChord" | "blocks.noteSet.unknownLabelsFingers" | "blocks.noteSet.unknownLabels" | "blocks.noteSet.invalidNotes" | "blocks.noteSet.unknownScale" | "blocks.noteSet.unknownChord" | "blocks.noteSet.notAScaleChordOrList" | "blocks.noteSet.highlightNeedsIntervals" | "blocks.noteSet.notInSet" | "theory.key.needsSharps" | "theory.key.needsFlats" | "theory.key.noSignature" | "theory.harmonize.unknownScale" | "theory.harmonize.sevenNotes" | "theory.harmonize.noNamedChord" | "theory.harmonize.noFifth" | "theory.harmonize.noFourthOrSecond" | "blocks.progression.yesNo" | "blocks.progression.majorMinorKeys" | "blocks.progression.unknownKey" | "blocks.progression.unread" | "blocks.progression.harmonizeKind" | "blocks.progression.harmonizeNothing" | "blocks.progression.harmonizeNoChords" | "blocks.progression.addScale" | "blocks.progression.transposeWhole" | "blocks.progression.addChords" | "blocks.progression.addKey" | "blocks.progression.unknownTuning" | "blocks.progression.tempo" | "blocks.progression.strum" | "blocks.progression.key" | "blocks.progression.blues" | "blocks.progression.orKeys" | "blocks.progression.leftOut" | "blocks.progression.leftOutDegree" | "blocks.progression.unknownInstrument" | "blocks.progression.numerals" | "blocks.progression.voiceLeadingPiano" | "blocks.progression.pianoOnly" | "blocks.progression.voiceLeadingHands" | "blocks.progression.voiceLeadingOrKey" | "blocks.progression.addChordsAfterShared" | "blocks.progression.maxChords" | "theory.chord.suggest" | "blocks.render.maxStrings" | "blocks.render.invalidRange" | "blocks.render.maxKeys" | "blocks.render.wholeFrom1" | "blocks.render.unrecognized" | "blocks.render.rootForListsOnly" | "blocks.chord.capoNotPiano" | "blocks.chord.pitchesGivenKeys" | "blocks.chord.autoNeedsSymbol" | "blocks.chord.invalidPitches" | "blocks.chord.autoCovers" | "blocks.chord.addSymbolOrPitches" | "blocks.chord.unknownInstrument" | "blocks.chord.invalidFrets" | "blocks.chord.nutAtCapo" | "blocks.chord.capoMaxFret" | "blocks.chord.fingersCount" | "blocks.chord.noVoicing" | "blocks.chord.addFretsFor" | "blocks.chord.addSymbolAndFrets" | "blocks.chord.positionAboveLowest" | "blocks.chord.tuningStrings" | "blocks.chord.soundsTitle" | "blocks.chord.captionFormulaChord" | "blocks.chord.captionFormulaSet" | "blocks.chord.soundsTitleNeedsChord" | "blocks.chord.soundsNeedsCapo" | "blocks.chord.soundsYesNeedsChord" | "blocks.chord.soundsMismatch" | "blocks.chord.unknownLabels" | "blocks.chord.labelsNeedChord" | "blocks.keyboard.autoBothAlone" | "blocks.keyboard.fingersCount" | "blocks.keyboard.fingersForNotes" | "blocks.keyboard.keyTwice" | "blocks.keyboard.pastRange" | "blocks.keyboard.handTitleLeft" | "blocks.keyboard.handTitleRight" | "blocks.fretboard.invalidFrets" | "blocks.fretboard.maxFret" | "blocks.fretboard.nutStartsAtCapo" | "blocks.fretboard.numberingNeedsPosition" | "blocks.fretboard.positionsNeedSet" | "blocks.fretboard.arpeggioCaged" | "blocks.fretboard.positionCount" | "blocks.fretboard.positionNotFit" | "blocks.fretboard.rhythmNeedsExercise" | "blocks.fretboard.exerciseNeedsPosition" | "blocks.fretboard.invalidTempo" | "blocks.fretboard.arpeggioTitle" | "blocks.fretboard.fromMinor" | "blocks.fretboard.shapeTitle" | "blocks.fretboard.threeNpsTitle" | "blocks.fretboard.boxTitle" | "blocks.scalesFor.both" | "blocks.scalesFor.findsItself" | "blocks.scalesFor.addChords" | "blocks.scalesFor.addNotes" | "blocks.scalesFor.unreadChords" | "blocks.scalesFor.unreadNotes" | "blocks.scalesFor.outside" | "blocks.scalesFor.bluesTitle" | "blocks.scalesFor.title" | "chord.capo.fret" | "chord.capo.fretsFrom" | "theory.naming.write" | "theory.naming.writeDirective" | "chord.words.ordinalFirst" | "chord.words.ordinalSt" | "chord.words.ordinalNd" | "chord.words.ordinalRd" | "chord.words.ordinalTh" | "chord.words.listAnd" | "chord.words.guitarIndex" | "chord.words.guitarMiddle" | "chord.words.guitarRing" | "chord.words.guitarPinky" | "chord.words.guitarThumb" | "chord.words.guitarFinger" | "chord.words.pianoThumb" | "chord.words.pianoIndex" | "chord.words.pianoMiddle" | "chord.words.pianoRing" | "chord.words.pianoLittle" | "chord.words.pianoFinger" | "chord.words.lowName" | "chord.words.highName" | "chord.words.stringNamed" | "chord.words.stringsNamed" | "chord.words.stringNumberedNote" | "chord.words.stringNumbered" | "chord.words.capoFrom" | "chord.words.capoNut" | "chord.words.allMuted" | "chord.words.strumSix" | "chord.words.strumAll" | "chord.words.strumFrom" | "chord.words.strumFromTo" | "chord.words.press" | "chord.words.fingerOn" | "chord.words.fingerBars" | "chord.words.fingerAlsoOn" | "chord.words.muteOne" | "chord.words.mutePlural" | "chord.words.groupRingOpenOne" | "chord.words.groupRingOpenPlural" | "chord.words.groupRingCapoOne" | "chord.words.groupRingCapoPlural" | "chord.words.ringOpenOne" | "chord.words.ringOpenPlural" | "chord.words.ringCapoOne" | "chord.words.ringCapoPlural" | "chord.words.pianoFingerOn" | "chord.words.pianoAlsoPlay" | "chord.words.sentence" | "chord.words.play" | "chord.words.leftHand" | "chord.words.rightHand" | "chord.transition.fingerIndex" | "chord.transition.fingerMiddle" | "chord.transition.fingerRing" | "chord.transition.fingerPinky" | "chord.transition.fingerThumb" | "chord.transition.fingerOther" | "chord.transition.keep" | "chord.transition.slide" | "chord.transition.moveUp" | "chord.transition.moveDown" | "chord.transition.lift" | "chord.guitar.capoCaption" | "chord.guitar.capoCaptionSounds" | "chord.guitar.diagram" | "chord.guitar.diagramTitled" | "chord.guitar.rootOnString" | "chord.guitar.rootOnStrings" | "chord.triads.rootPosition" | "chord.triads.firstInversion" | "chord.triads.secondInversion" | "theory.formula.chord" | "theory.formula.inTheBass" | "theory.formula.formula" | "theory.formula.alsoWritten" | "theory.formula.scale" | "theory.formula.steps" | "chords.chart.chorus" | "chords.chart.bridge" | "chords.chart.tab" | "chords.chart.grid" | "chords.chart.key" | "chords.chart.capo" | "chords.chart.tempo" | "chords.chart.transposed" | "chords.chart.sounds" | "chords.chart.moreNotDrawn" | "chords.chart.missing" | "chords.chart.howPiano" | "chords.chart.howGuitar" | "chords.define.needsName" | "chords.define.baseFret" | "chords.define.frets" | "chords.define.keys" | "chords.define.copy" | "chords.define.unknown" | "chords.define.fingersCount" | "chords.define.reaches" | "chords.directive.diagrams" | "chord.shape.open" | "chord.shape.caged" | "chord.shape.cagedStrings" | "chord.shape.power" | "chord.shape.triad" | "chord.shape.shell" | "chord.shape.drop" | "chord.shape.hendrix" | "chord.shape.openBass" | "chord.shape.openStrings" | "chord.shape.strings" | "blocks.function.tonic" | "blocks.function.subdominant" | "blocks.function.dominant" | "blocks.function.secondaryDominant" | "blocks.function.neapolitan" | "blocks.function.borrowed" | "blocks.function.chromatic" | "blocks.function.tonicization" | "blocks.function.passing" | "theory.marks.characteristic" | "theory.marks.different" | "theory.marks.chordTones", string>;
|
|
536
|
+
readonly fr: Record<"playback.bar" | "playback.diagram" | "playback.place" | "playback.playItem" | "playback.playAll" | "playback.play" | "playback.stop" | "playback.loop" | "playback.countIn" | "playback.click" | "playback.sound" | "playback.guitar" | "playback.piano" | "playback.tempo" | "playback.unit.bpm" | "playback.unit.ms" | "playback.strum" | "playback.dotted" | "playback.strumPattern.bar" | "playback.picking.bar" | "playback.progression.bar" | "playback.progression.play" | "playback.strumChoice" | "playback.strum.beats" | "playback.strum.bar" | "playback.strum.arpeggio" | "playback.strum.pattern" | "playback.copy.button" | "playback.copy.hint" | "playback.copy.bar" | "playback.copy.copied" | "playback.copy.refused" | "playback.copy.unsupported" | "playback.copy.failed" | "playback.full.enter" | "playback.full.exit" | "playback.redraw.sounds" | "playback.redraw.guitar" | "playback.redraw.piano" | "playback.engine.invalid" | "playback.guitar.invalid" | "tab.source.staves" | "tab.source.layout" | "tab.source.names" | "tab.source.tracks" | "tab.source.empty" | "tab.sound.loadFailed" | "tab.error.at" | "tab.error.textTab" | "tab.error.fileRead" | "tab.error.fileMissing" | "tab.error.fileUnknown" | "tab.player.cantPlay" | "tab.player.metronome" | "tab.player.pause" | "tab.names" | "tab.follow" | "tab.followPaused" | "tab.view.group" | "tab.view.tab" | "tab.view.score" | "tab.view.both" | "tab.view.whatTab" | "tab.view.whatScore" | "tab.view.whatBoth" | "tab.view.drawAs" | "tab.view.drawAsWritten" | "tab.view.drawAsDefault" | "tab.view.keep" | "tab.view.keepTitle" | "tab.tempo.group" | "tab.tempo.slower" | "tab.tempo.faster" | "tab.tempo.toPercent" | "tab.tempo.toBpm" | "tab.tempo.reset" | "tab.tempo.inBpm" | "tab.tempo.inPercent" | "tab.tempo.title" | "tab.tempo.speedTitle" | "strum.time.invalid" | "strum.swing.invalid" | "strum.subdivision.invalid" | "strum.triplets.quarterBeat68" | "strum.triplets.quarterBeat" | "strum.subdivision.tooLong" | "strum.chord.notRecognizedTry" | "strum.chord.empty" | "strum.chord.notRecognized" | "strum.line.bracketMissing" | "strum.line.barInGhost" | "strum.line.accentAndGhost" | "strum.line.ghostNested" | "strum.line.parenUnopened" | "strum.help" | "strum.line.notUnderstood" | "strum.line.accentNeedsStrum" | "strum.line.ghostNoRests" | "strum.line.parenUnclosed" | "strum.line.chordEndsPattern" | "strum.pattern.chordLineAlone" | "strum.pattern.missing" | "strum.key.unknown" | "strum.swing.withTriplets" | "strum.swing.compound" | "strum.swing.oneSlot" | "strum.tempo.invalid" | "strum.bars.tooMany" | "strum.chord.pastEnd" | "strum.count.bar.one" | "strum.count.bar.other" | "strum.count.slot.one" | "strum.count.slot.other" | "strum.count.barsAndSlots" | "strum.count.spill" | "strum.count.spillOrTime" | "strum.count.mismatch" | "strum.count.alternative.first" | "strum.count.alternative.next" | "strum.count.alternative.last" | "strum.note.one" | "strum.note.other" | "strum.feel.swing" | "strum.feel.swingPercent" | "strum.feel.swing16" | "strum.feel.swing16Percent" | "strum.name" | "strum.name.titled" | "strum.name.feel" | "strum.tuning.unknown" | "strum.tuning.tooManyStrings" | "strum.tuning.unknownGiven" | "picking.help" | "picking.token.notUnderstood" | "picking.string.missing" | "picking.bar.slots" | "picking.bar.betweenBarLines" | "picking.key.unknown" | "picking.swing.pairs" | "picking.tempo.invalid" | "picking.pattern.twice" | "picking.pattern.missing" | "picking.chords.tooMany" | "picking.tuning.unknown" | "picking.name" | "picking.name.titled" | "picking.name.over" | "picking.voicing.none" | "export.image.title" | "render.layout.orientation" | "render.layout.hand" | "render.rootMark.invalid" | "render.rootListsOnly" | "render.unknownChord" | "render.tuning" | "render.yesNo" | "render.hand.left" | "render.hand.right" | "render.positions.exerciseOne" | "render.positions.needsSet" | "render.positions.arpeggioCaged" | "render.positions.range" | "render.positions.fromMinor" | "render.positions.arpeggioTitle" | "render.positions.shapeTitle" | "render.positions.npsTitle" | "render.positions.boxTitle" | "render.fingering.handTitle" | "render.voicings.notBoth" | "render.voicings.fretted" | "render.voicings.noFrets" | "render.voicings.needsChord" | "render.voicings.instrument" | "render.voicings.maxStrings" | "render.voicings.count" | "render.voicings.area" | "render.voicings.rootString" | "render.voicings.inversion" | "render.voicings.manyStringsAny" | "render.voicings.wideArea" | "render.voicings.oneWidening" | "render.noVoicing.gaps" | "render.noVoicing.rootString" | "render.noVoicing.inversion" | "render.noVoicing.bass" | "render.noVoicing.none" | "render.triads.noFrets" | "render.triads.fretted" | "render.triads.strings" | "render.triads.inversion" | "render.triads.keyInversion" | "render.triads.key" | "render.triads.needsChord" | "render.triads.notTriad" | "render.triads.none" | "render.transitions.needsFrom" | "render.transitions.fretted" | "render.transitions.notBoth" | "render.transitions.refused" | "render.transitions.maxStrings" | "render.transitions.twoChords" | "render.transitions.maxChords" | "render.transitions.noVoicings" | "render.transitions.needsTo" | "render.transitions.noHeld" | "render.transitions.stringCount" | "render.transitions.count" | "render.transitions.noTarget" | "render.modes.none" | "render.modes.refused" | "render.row.notShared" | "render.row.columns" | "render.row.needsDiagram" | "render.row.max" | "render.row.columnsShared" | "render.row.ownRow" | "render.row.exercise" | "render.row.diagram" | "render.row.sharedHint" | "fretboard.capo" | "fretboard.title" | "fretboard.note.open" | "fretboard.note.fret" | "fretboard.note.root" | "fretboard.string" | "fretboard.pick.open" | "fretboard.pick.fret" | "fretboard.exercise.direction" | "fretboard.exercise.rhythm" | "fretboard.exercise.scale" | "fretboard.exercise.chord" | "fretboard.exercise.needsSet" | "fretboard.exercise.arpeggioCaged" | "fretboard.exercise.positions" | "fretboard.exercise.tuning" | "fretboard.exercise.capo" | "fretboard.positions.numbering" | "fretboard.positions.numberingPentatonic" | "fretboard.positions.numberingCaged" | "fretboard.positions.position" | "fretboard.positions.shape" | "keyboard.fingering.finger" | "keyboard.fingering.autoNeedsScale" | "keyboard.fingering.autoUnknown" | "keyboard.piano.shell" | "keyboard.piano.rootless" | "keyboard.piano.octave" | "keyboard.piano.inversion" | "keyboard.piano.slashInversion" | "keyboard.piano.inversionStyle" | "keyboard.piano.inversionMax" | "keyboard.piano.open" | "keyboard.piano.offKeys" | "keyboard.piano.inversionWord" | "keyboard.piano.octaveMiddle" | "keyboard.piano.voicing" | "keyboard.piano.key" | "keyboard.piano.resolvesTo" | "keyboard.piano.hands" | "keyboard.title" | "keyboard.hand" | "keyboard.handMark.left" | "keyboard.handMark.right" | "keyboard.whiteKey" | "keyboard.blackKey" | "keyboard.lit.root" | "keyboard.lit.finger" | "keyboard.lit.keys" | "circle.label" | "circle.or" | "circle.mode.major" | "circle.mode.minor" | "circle.mode.ionian" | "circle.mode.dorian" | "circle.mode.phrygian" | "circle.mode.lydian" | "circle.mode.mixolydian" | "circle.mode.aeolian" | "circle.mode.locrian" | "circle.key" | "circle.mode" | "circle.modeTwice" | "circle.chords" | "circle.dominant" | "keyboard.piano.unknownChord" | "blocks.source.expected" | "blocks.source.strings" | "blocks.caption.fingeringChordOnly" | "blocks.caption.useAll" | "blocks.caption.useFormula" | "blocks.noteSet.chordOrArpeggio" | "blocks.noteSet.invalidRoot" | "blocks.noteSet.notAList" | "blocks.noteSet.addNotesForRoot" | "blocks.noteSet.addRoot" | "blocks.noteSet.addSource" | "blocks.noteSet.rootListsOnlyScale" | "blocks.noteSet.rootListsOnlyChord" | "blocks.noteSet.unknownLabelsFingers" | "blocks.noteSet.unknownLabels" | "blocks.noteSet.invalidNotes" | "blocks.noteSet.unknownScale" | "blocks.noteSet.unknownChord" | "blocks.noteSet.notAScaleChordOrList" | "blocks.noteSet.highlightNeedsIntervals" | "blocks.noteSet.notInSet" | "theory.key.needsSharps" | "theory.key.needsFlats" | "theory.key.noSignature" | "theory.harmonize.unknownScale" | "theory.harmonize.sevenNotes" | "theory.harmonize.noNamedChord" | "theory.harmonize.noFifth" | "theory.harmonize.noFourthOrSecond" | "blocks.progression.yesNo" | "blocks.progression.majorMinorKeys" | "blocks.progression.unknownKey" | "blocks.progression.unread" | "blocks.progression.harmonizeKind" | "blocks.progression.harmonizeNothing" | "blocks.progression.harmonizeNoChords" | "blocks.progression.addScale" | "blocks.progression.transposeWhole" | "blocks.progression.addChords" | "blocks.progression.addKey" | "blocks.progression.unknownTuning" | "blocks.progression.tempo" | "blocks.progression.strum" | "blocks.progression.key" | "blocks.progression.blues" | "blocks.progression.orKeys" | "blocks.progression.leftOut" | "blocks.progression.leftOutDegree" | "blocks.progression.unknownInstrument" | "blocks.progression.numerals" | "blocks.progression.voiceLeadingPiano" | "blocks.progression.pianoOnly" | "blocks.progression.voiceLeadingHands" | "blocks.progression.voiceLeadingOrKey" | "blocks.progression.addChordsAfterShared" | "blocks.progression.maxChords" | "theory.chord.suggest" | "blocks.render.maxStrings" | "blocks.render.invalidRange" | "blocks.render.maxKeys" | "blocks.render.wholeFrom1" | "blocks.render.unrecognized" | "blocks.render.rootForListsOnly" | "blocks.chord.capoNotPiano" | "blocks.chord.pitchesGivenKeys" | "blocks.chord.autoNeedsSymbol" | "blocks.chord.invalidPitches" | "blocks.chord.autoCovers" | "blocks.chord.addSymbolOrPitches" | "blocks.chord.unknownInstrument" | "blocks.chord.invalidFrets" | "blocks.chord.nutAtCapo" | "blocks.chord.capoMaxFret" | "blocks.chord.fingersCount" | "blocks.chord.noVoicing" | "blocks.chord.addFretsFor" | "blocks.chord.addSymbolAndFrets" | "blocks.chord.positionAboveLowest" | "blocks.chord.tuningStrings" | "blocks.chord.soundsTitle" | "blocks.chord.captionFormulaChord" | "blocks.chord.captionFormulaSet" | "blocks.chord.soundsTitleNeedsChord" | "blocks.chord.soundsNeedsCapo" | "blocks.chord.soundsYesNeedsChord" | "blocks.chord.soundsMismatch" | "blocks.chord.unknownLabels" | "blocks.chord.labelsNeedChord" | "blocks.keyboard.autoBothAlone" | "blocks.keyboard.fingersCount" | "blocks.keyboard.fingersForNotes" | "blocks.keyboard.keyTwice" | "blocks.keyboard.pastRange" | "blocks.keyboard.handTitleLeft" | "blocks.keyboard.handTitleRight" | "blocks.fretboard.invalidFrets" | "blocks.fretboard.maxFret" | "blocks.fretboard.nutStartsAtCapo" | "blocks.fretboard.numberingNeedsPosition" | "blocks.fretboard.positionsNeedSet" | "blocks.fretboard.arpeggioCaged" | "blocks.fretboard.positionCount" | "blocks.fretboard.positionNotFit" | "blocks.fretboard.rhythmNeedsExercise" | "blocks.fretboard.exerciseNeedsPosition" | "blocks.fretboard.invalidTempo" | "blocks.fretboard.arpeggioTitle" | "blocks.fretboard.fromMinor" | "blocks.fretboard.shapeTitle" | "blocks.fretboard.threeNpsTitle" | "blocks.fretboard.boxTitle" | "blocks.scalesFor.both" | "blocks.scalesFor.findsItself" | "blocks.scalesFor.addChords" | "blocks.scalesFor.addNotes" | "blocks.scalesFor.unreadChords" | "blocks.scalesFor.unreadNotes" | "blocks.scalesFor.outside" | "blocks.scalesFor.bluesTitle" | "blocks.scalesFor.title" | "chord.capo.fret" | "chord.capo.fretsFrom" | "theory.naming.write" | "theory.naming.writeDirective" | "chord.words.ordinalFirst" | "chord.words.ordinalSt" | "chord.words.ordinalNd" | "chord.words.ordinalRd" | "chord.words.ordinalTh" | "chord.words.listAnd" | "chord.words.guitarIndex" | "chord.words.guitarMiddle" | "chord.words.guitarRing" | "chord.words.guitarPinky" | "chord.words.guitarThumb" | "chord.words.guitarFinger" | "chord.words.pianoThumb" | "chord.words.pianoIndex" | "chord.words.pianoMiddle" | "chord.words.pianoRing" | "chord.words.pianoLittle" | "chord.words.pianoFinger" | "chord.words.lowName" | "chord.words.highName" | "chord.words.stringNamed" | "chord.words.stringsNamed" | "chord.words.stringNumberedNote" | "chord.words.stringNumbered" | "chord.words.capoFrom" | "chord.words.capoNut" | "chord.words.allMuted" | "chord.words.strumSix" | "chord.words.strumAll" | "chord.words.strumFrom" | "chord.words.strumFromTo" | "chord.words.press" | "chord.words.fingerOn" | "chord.words.fingerBars" | "chord.words.fingerAlsoOn" | "chord.words.muteOne" | "chord.words.mutePlural" | "chord.words.groupRingOpenOne" | "chord.words.groupRingOpenPlural" | "chord.words.groupRingCapoOne" | "chord.words.groupRingCapoPlural" | "chord.words.ringOpenOne" | "chord.words.ringOpenPlural" | "chord.words.ringCapoOne" | "chord.words.ringCapoPlural" | "chord.words.pianoFingerOn" | "chord.words.pianoAlsoPlay" | "chord.words.sentence" | "chord.words.play" | "chord.words.leftHand" | "chord.words.rightHand" | "chord.transition.fingerIndex" | "chord.transition.fingerMiddle" | "chord.transition.fingerRing" | "chord.transition.fingerPinky" | "chord.transition.fingerThumb" | "chord.transition.fingerOther" | "chord.transition.keep" | "chord.transition.slide" | "chord.transition.moveUp" | "chord.transition.moveDown" | "chord.transition.lift" | "chord.guitar.capoCaption" | "chord.guitar.capoCaptionSounds" | "chord.guitar.diagram" | "chord.guitar.diagramTitled" | "chord.guitar.rootOnString" | "chord.guitar.rootOnStrings" | "chord.triads.rootPosition" | "chord.triads.firstInversion" | "chord.triads.secondInversion" | "theory.formula.chord" | "theory.formula.inTheBass" | "theory.formula.formula" | "theory.formula.alsoWritten" | "theory.formula.scale" | "theory.formula.steps" | "chords.chart.chorus" | "chords.chart.bridge" | "chords.chart.tab" | "chords.chart.grid" | "chords.chart.key" | "chords.chart.capo" | "chords.chart.tempo" | "chords.chart.transposed" | "chords.chart.sounds" | "chords.chart.moreNotDrawn" | "chords.chart.missing" | "chords.chart.howPiano" | "chords.chart.howGuitar" | "chords.define.needsName" | "chords.define.baseFret" | "chords.define.frets" | "chords.define.keys" | "chords.define.copy" | "chords.define.unknown" | "chords.define.fingersCount" | "chords.define.reaches" | "chords.directive.diagrams" | "chord.shape.open" | "chord.shape.caged" | "chord.shape.cagedStrings" | "chord.shape.power" | "chord.shape.triad" | "chord.shape.shell" | "chord.shape.drop" | "chord.shape.hendrix" | "chord.shape.openBass" | "chord.shape.openStrings" | "chord.shape.strings" | "blocks.function.tonic" | "blocks.function.subdominant" | "blocks.function.dominant" | "blocks.function.secondaryDominant" | "blocks.function.neapolitan" | "blocks.function.borrowed" | "blocks.function.chromatic" | "blocks.function.tonicization" | "blocks.function.passing" | "theory.marks.characteristic" | "theory.marks.different" | "theory.marks.chordTones", string>;
|
|
536
537
|
};
|
|
537
538
|
export type Language = keyof typeof TABLES;
|
|
538
539
|
export declare const LANGUAGES_OF_TEXTS: readonly Language[];
|
package/dist/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export { sampledPlayer, type SampledOptions } from './playback/sampled.js';
|
|
|
10
10
|
export { pageInstruments, type InstrumentSource } from './tab/instruments.js';
|
|
11
11
|
export { attachPlayback, type PlayOptions, type TimedBar } from './playback/controls.js';
|
|
12
12
|
export { ENGINES, chooseEngine, engineOf, engineOrder, pageEngine, type Engine } from './playback/engine.js';
|
|
13
|
+
export { DEFAULT_GUITAR_TONE, GUITAR_PROGRAMS, GUITAR_TONES, guitarToneOf, pageGuitar, type GuitarTone } from './playback/guitar-tone.js';
|
|
13
14
|
export { volumeChanged } from './playback/live-volume.js';
|
|
14
15
|
export { attachCopy } from './playback/copy-image.js';
|
|
15
16
|
export { toSvgString, toPng, type ExportTheme, type SvgExportOptions, type PngExportOptions } from './export/image.js';
|
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}"',
|
|
@@ -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} »",
|
|
@@ -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
|