vexflow 4.0.1-beta.1 → 4.0.1
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 +48 -65
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +724 -697
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +550 -610
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow-font-gonville.js +1 -1
- package/build/cjs/vexflow-font-gonville.js.map +1 -1
- package/build/cjs/vexflow-gonville.js +2 -2
- package/build/cjs/vexflow-gonville.js.map +1 -1
- package/build/cjs/vexflow-petaluma.js +2 -2
- package/build/cjs/vexflow-petaluma.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/entry/vexflow-bravura.js +10 -0
- package/build/esm/entry/vexflow-core.js +53 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +11 -0
- package/build/esm/entry/vexflow-debug.js +8 -0
- package/build/esm/entry/vexflow-font-bravura.js +7 -0
- package/build/esm/entry/vexflow-font-custom.js +7 -0
- package/build/esm/entry/vexflow-font-gonville.js +7 -0
- package/build/esm/entry/vexflow-font-petaluma.js +7 -0
- package/build/esm/entry/vexflow-gonville.js +10 -0
- package/build/esm/entry/vexflow-petaluma.js +10 -0
- package/build/esm/entry/vexflow.js +8 -0
- package/build/esm/src/accidental.js +348 -0
- package/build/esm/src/annotation.js +238 -0
- package/build/esm/src/articulation.js +267 -0
- package/build/esm/src/barnote.js +58 -0
- package/build/esm/src/beam.js +644 -0
- package/build/esm/src/bend.js +202 -0
- package/build/esm/src/boundingbox.js +59 -0
- package/build/esm/src/boundingboxcomputation.js +107 -0
- package/build/esm/src/canvascontext.js +202 -0
- package/build/esm/src/chordsymbol.js +578 -0
- package/build/esm/src/clef.js +153 -0
- package/build/esm/src/clefnote.js +65 -0
- package/build/esm/src/crescendo.js +77 -0
- package/build/esm/src/curve.js +118 -0
- package/build/esm/src/dot.js +137 -0
- package/build/esm/src/easyscore.js +374 -0
- package/build/esm/src/element.js +216 -0
- package/build/esm/src/factory.js +445 -0
- package/build/esm/src/flow.js +288 -0
- package/build/esm/src/font.js +262 -0
- package/build/esm/src/fonts/bravura_glyphs.js +3239 -0
- package/build/esm/src/fonts/bravura_metrics.js +507 -0
- package/build/esm/src/fonts/custom_glyphs.js +78 -0
- package/build/esm/src/fonts/custom_metrics.js +5 -0
- package/build/esm/src/fonts/gonville_glyphs.js +828 -0
- package/build/esm/src/fonts/gonville_metrics.js +421 -0
- package/build/esm/src/fonts/load_all.js +10 -0
- package/build/esm/src/fonts/load_bravura.js +6 -0
- package/build/esm/src/fonts/load_custom.js +6 -0
- package/build/esm/src/fonts/load_gonville.js +6 -0
- package/build/esm/src/fonts/load_petaluma.js +6 -0
- package/build/esm/src/fonts/petaluma_glyphs.js +1335 -0
- package/build/esm/src/fonts/petaluma_metrics.js +536 -0
- package/build/esm/src/fonts/petalumascript_glyphs.js +863 -0
- package/build/esm/src/fonts/robotoslab_glyphs.js +863 -0
- package/build/esm/src/fonts/textfonts.js +44 -0
- package/build/esm/src/formatter.js +585 -0
- package/build/esm/src/fraction.js +171 -0
- package/build/esm/src/frethandfinger.js +156 -0
- package/build/esm/src/ghostnote.js +50 -0
- package/build/esm/src/glyph.js +337 -0
- package/build/esm/src/glyphnote.js +55 -0
- package/build/esm/src/gracenote.js +133 -0
- package/build/esm/src/gracenotegroup.js +128 -0
- package/build/esm/src/gracetabnote.js +12 -0
- package/build/esm/src/index.js +89 -0
- package/build/esm/src/keymanager.js +99 -0
- package/build/esm/src/keysignature.js +250 -0
- package/build/esm/src/keysignote.js +28 -0
- package/build/esm/src/modifier.js +128 -0
- package/build/esm/src/modifiercontext.js +110 -0
- package/build/esm/src/multimeasurerest.js +173 -0
- package/build/esm/src/music.js +322 -0
- package/build/esm/src/note.js +371 -0
- package/build/esm/src/notehead.js +169 -0
- package/build/esm/src/notesubgroup.js +59 -0
- package/build/esm/src/ornament.js +206 -0
- package/build/esm/src/parenthesis.js +76 -0
- package/build/esm/src/parser.js +164 -0
- package/build/esm/src/pedalmarking.js +192 -0
- package/build/esm/src/registry.js +81 -0
- package/build/esm/src/rendercontext.js +24 -0
- package/build/esm/src/renderer.js +112 -0
- package/build/esm/src/repeatnote.js +22 -0
- package/build/esm/src/stave.js +547 -0
- package/build/esm/src/stavebarline.js +182 -0
- package/build/esm/src/staveconnector.js +196 -0
- package/build/esm/src/stavehairpin.js +120 -0
- package/build/esm/src/staveline.js +215 -0
- package/build/esm/src/stavemodifier.js +77 -0
- package/build/esm/src/stavenote.js +860 -0
- package/build/esm/src/staverepetition.js +155 -0
- package/build/esm/src/stavesection.js +58 -0
- package/build/esm/src/stavetempo.js +91 -0
- package/build/esm/src/stavetext.js +82 -0
- package/build/esm/src/stavetie.js +141 -0
- package/build/esm/src/stavevolta.js +67 -0
- package/build/esm/src/stem.js +131 -0
- package/build/esm/src/stemmablenote.js +193 -0
- package/build/esm/src/stringnumber.js +231 -0
- package/build/esm/src/strokes.js +200 -0
- package/build/esm/src/svgcontext.js +414 -0
- package/build/esm/src/system.js +109 -0
- package/build/esm/src/tables.js +1102 -0
- package/build/esm/src/tabnote.js +299 -0
- package/build/esm/src/tabslide.js +76 -0
- package/build/esm/src/tabstave.js +17 -0
- package/build/esm/src/tabtie.js +19 -0
- package/build/esm/src/textbracket.js +144 -0
- package/build/esm/src/textdynamics.js +81 -0
- package/build/esm/src/textformatter.js +177 -0
- package/build/esm/src/textnote.js +174 -0
- package/build/esm/src/tickable.js +214 -0
- package/build/esm/src/tickcontext.js +170 -0
- package/build/esm/src/timesigglyph.js +85 -0
- package/build/esm/src/timesignature.js +89 -0
- package/build/esm/src/timesignote.js +32 -0
- package/build/esm/src/tremolo.js +47 -0
- package/build/esm/src/tuning.js +54 -0
- package/build/esm/src/tuplet.js +240 -0
- package/build/esm/src/typeguard.js +30 -0
- package/build/esm/src/util.js +58 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vex.js +51 -0
- package/build/esm/src/vibrato.js +100 -0
- package/build/esm/src/vibratobracket.js +50 -0
- package/build/esm/src/voice.js +187 -0
- package/build/esm/src/web.js +15 -0
- package/build/esm/tests/accidental_tests.js +974 -0
- package/build/esm/tests/annotation_tests.js +390 -0
- package/build/esm/tests/articulation_tests.js +365 -0
- package/build/esm/tests/auto_beam_formatting_tests.js +548 -0
- package/build/esm/tests/bach_tests.js +335 -0
- package/build/esm/tests/barline_tests.js +52 -0
- package/build/esm/tests/beam_tests.js +614 -0
- package/build/esm/tests/bend_tests.js +215 -0
- package/build/esm/tests/boundingbox_tests.js +53 -0
- package/build/esm/tests/boundingboxcomputation_tests.js +183 -0
- package/build/esm/tests/chordsymbol_tests.js +320 -0
- package/build/esm/tests/clef_tests.js +131 -0
- package/build/esm/tests/curve_tests.js +118 -0
- package/build/esm/tests/dot_tests.js +123 -0
- package/build/esm/tests/easyscore_tests.js +462 -0
- package/build/esm/tests/factory_tests.js +44 -0
- package/build/esm/tests/font_tests.js +135 -0
- package/build/esm/tests/formatter/framestack.js +61 -0
- package/build/esm/tests/formatter/tests.js +203 -0
- package/build/esm/tests/formatter_tests.js +670 -0
- package/build/esm/tests/fraction_tests.js +72 -0
- package/build/esm/tests/ghostnote_tests.js +77 -0
- package/build/esm/tests/glyphnote_tests.js +113 -0
- package/build/esm/tests/gracenote_tests.js +413 -0
- package/build/esm/tests/gracetabnote_tests.js +79 -0
- package/build/esm/tests/index.js +68 -0
- package/build/esm/tests/key_clef_tests.js +103 -0
- package/build/esm/tests/keymanager_tests.js +68 -0
- package/build/esm/tests/keysignature_tests.js +308 -0
- package/build/esm/tests/mocks.js +71 -0
- package/build/esm/tests/modifier_tests.js +24 -0
- package/build/esm/tests/multimeasurerest_tests.js +141 -0
- package/build/esm/tests/music_tests.js +161 -0
- package/build/esm/tests/notehead_tests.js +137 -0
- package/build/esm/tests/notesubgroup_tests.js +149 -0
- package/build/esm/tests/offscreencanvas_tests.js +47 -0
- package/build/esm/tests/ornament_tests.js +298 -0
- package/build/esm/tests/parser_tests.js +122 -0
- package/build/esm/tests/pedalmarking_tests.js +64 -0
- package/build/esm/tests/percussion_tests.js +180 -0
- package/build/esm/tests/registry_tests.js +64 -0
- package/build/esm/tests/renderer_tests.js +113 -0
- package/build/esm/tests/rests_tests.js +248 -0
- package/build/esm/tests/rhythm_tests.js +357 -0
- package/build/esm/tests/stave_tests.js +560 -0
- package/build/esm/tests/staveconnector_tests.js +402 -0
- package/build/esm/tests/stavehairpin_tests.js +90 -0
- package/build/esm/tests/staveline_tests.js +122 -0
- package/build/esm/tests/stavemodifier_tests.js +51 -0
- package/build/esm/tests/stavenote_tests.js +867 -0
- package/build/esm/tests/stavetie_tests.js +108 -0
- package/build/esm/tests/stringnumber_tests.js +259 -0
- package/build/esm/tests/strokes_tests.js +275 -0
- package/build/esm/tests/style_tests.js +98 -0
- package/build/esm/tests/support/qunit.js +2765 -0
- package/build/esm/tests/tabnote_tests.js +474 -0
- package/build/esm/tests/tabslide_tests.js +135 -0
- package/build/esm/tests/tabstave_tests.js +23 -0
- package/build/esm/tests/tabtie_tests.js +173 -0
- package/build/esm/tests/textbracket_tests.js +100 -0
- package/build/esm/tests/textformatter_tests.js +24 -0
- package/build/esm/tests/textnote_tests.js +215 -0
- package/build/esm/tests/threevoice_tests.js +132 -0
- package/build/esm/tests/tickcontext_tests.js +36 -0
- package/build/esm/tests/timesignature_tests.js +134 -0
- package/build/esm/tests/tremolo_tests.js +75 -0
- package/build/esm/tests/tuning_tests.js +56 -0
- package/build/esm/tests/tuplet_tests.js +450 -0
- package/build/esm/tests/typeguard_tests.js +82 -0
- package/build/esm/tests/vexflow_test_helpers.js +266 -0
- package/build/esm/tests/vf_prefix_tests.js +115 -0
- package/build/esm/tests/vibrato_tests.js +92 -0
- package/build/esm/tests/vibratobracket_tests.js +45 -0
- package/build/esm/tests/voice_tests.js +69 -0
- package/build/types/entry/vexflow-bravura.d.ts +2 -0
- package/build/types/entry/vexflow-core.d.ts +2 -0
- package/build/types/entry/vexflow-debug.d.ts +2 -0
- package/build/types/entry/vexflow-font-bravura.d.ts +3771 -0
- package/build/types/entry/vexflow-font-custom.d.ts +86 -0
- package/build/types/entry/vexflow-font-gonville.d.ts +1267 -0
- package/build/types/entry/vexflow-font-petaluma.d.ts +1896 -0
- package/build/types/entry/vexflow-gonville.d.ts +2 -0
- package/build/types/entry/vexflow-petaluma.d.ts +2 -0
- package/build/types/entry/vexflow.d.ts +2 -0
- package/build/types/src/accidental.d.ts +66 -0
- package/build/types/src/annotation.d.ts +61 -0
- package/build/types/src/articulation.d.ts +62 -0
- package/build/types/src/barnote.d.ts +29 -0
- package/build/types/src/beam.d.ts +153 -0
- package/build/types/src/bend.d.ts +73 -0
- package/build/types/src/boundingbox.d.ts +42 -0
- package/build/types/src/boundingboxcomputation.d.ts +33 -0
- package/build/types/src/canvascontext.d.ts +89 -0
- package/build/types/src/chordsymbol.d.ts +149 -0
- package/build/types/src/clef.d.ts +48 -0
- package/build/types/src/clefnote.d.ts +25 -0
- package/build/types/src/crescendo.d.ts +27 -0
- package/build/types/src/curve.d.ts +41 -0
- package/build/types/src/dot.d.ts +20 -0
- package/build/types/src/easyscore.d.ts +152 -0
- package/build/types/src/element.d.ts +202 -0
- package/build/types/src/factory.d.ts +274 -0
- package/build/types/src/flow.d.ts +260 -0
- package/build/types/src/font.d.ts +180 -0
- package/build/types/src/fonts/bravura_glyphs.d.ts +3239 -0
- package/build/types/src/fonts/bravura_metrics.d.ts +533 -0
- package/build/types/src/fonts/custom_glyphs.d.ts +78 -0
- package/build/types/src/fonts/custom_metrics.d.ts +5 -0
- package/build/types/src/fonts/gonville_glyphs.d.ts +828 -0
- package/build/types/src/fonts/gonville_metrics.d.ts +440 -0
- package/build/types/src/fonts/load_all.d.ts +1 -0
- package/build/types/src/fonts/load_bravura.d.ts +1 -0
- package/build/types/src/fonts/load_custom.d.ts +1 -0
- package/build/types/src/fonts/load_gonville.d.ts +1 -0
- package/build/types/src/fonts/load_petaluma.d.ts +1 -0
- package/build/types/src/fonts/petaluma_glyphs.d.ts +1335 -0
- package/build/types/src/fonts/petaluma_metrics.d.ts +562 -0
- package/build/types/src/fonts/petalumascript_glyphs.d.ts +863 -0
- package/build/types/src/fonts/robotoslab_glyphs.d.ts +863 -0
- package/build/types/src/fonts/textfonts.d.ts +1 -0
- package/build/types/src/formatter.d.ts +203 -0
- package/build/types/src/fraction.d.ts +62 -0
- package/build/types/src/frethandfinger.d.ts +22 -0
- package/build/types/src/ghostnote.d.ts +16 -0
- package/build/types/src/glyph.d.ts +141 -0
- package/build/types/src/glyphnote.d.ts +17 -0
- package/build/types/src/gracenote.d.ts +19 -0
- package/build/types/src/gracenotegroup.d.ts +33 -0
- package/build/types/src/gracetabnote.d.ts +5 -0
- package/build/types/src/index.d.ts +89 -0
- package/build/types/src/keymanager.d.ts +25 -0
- package/build/types/src/keysignature.d.ts +50 -0
- package/build/types/src/keysignote.d.ts +11 -0
- package/build/types/src/modifier.d.ts +97 -0
- package/build/types/src/modifiercontext.d.ts +45 -0
- package/build/types/src/multimeasurerest.d.ts +61 -0
- package/build/types/src/music.d.ts +91 -0
- package/build/types/src/note.d.ts +232 -0
- package/build/types/src/notehead.d.ts +70 -0
- package/build/types/src/notesubgroup.d.ts +18 -0
- package/build/types/src/ornament.d.ts +76 -0
- package/build/types/src/parenthesis.d.ts +22 -0
- package/build/types/src/parser.d.ts +45 -0
- package/build/types/src/pedalmarking.d.ts +69 -0
- package/build/types/src/registry.d.ts +40 -0
- package/build/types/src/rendercontext.d.ts +64 -0
- package/build/types/src/renderer.d.ts +35 -0
- package/build/types/src/repeatnote.d.ts +6 -0
- package/build/types/src/stave.d.ts +186 -0
- package/build/types/src/stavebarline.d.ts +28 -0
- package/build/types/src/staveconnector.d.ts +67 -0
- package/build/types/src/stavehairpin.d.ts +56 -0
- package/build/types/src/staveline.d.ts +54 -0
- package/build/types/src/stavemodifier.d.ts +44 -0
- package/build/types/src/stavenote.d.ts +154 -0
- package/build/types/src/staverepetition.d.ts +32 -0
- package/build/types/src/stavesection.d.ts +15 -0
- package/build/types/src/stavetempo.d.ts +25 -0
- package/build/types/src/stavetext.d.ts +25 -0
- package/build/types/src/stavetie.d.ts +59 -0
- package/build/types/src/stavevolta.d.ts +21 -0
- package/build/types/src/stem.d.ts +58 -0
- package/build/types/src/stemmablenote.d.ts +39 -0
- package/build/types/src/stringnumber.d.ts +27 -0
- package/build/types/src/strokes.d.ts +33 -0
- package/build/types/src/svgcontext.d.ts +131 -0
- package/build/types/src/system.d.ts +92 -0
- package/build/types/src/tables.d.ts +96 -0
- package/build/types/src/tabnote.d.ts +44 -0
- package/build/types/src/tabslide.d.ts +34 -0
- package/build/types/src/tabstave.d.ts +7 -0
- package/build/types/src/tabtie.d.ts +18 -0
- package/build/types/src/textbracket.d.ts +55 -0
- package/build/types/src/textdynamics.d.ts +39 -0
- package/build/types/src/textformatter.d.ts +109 -0
- package/build/types/src/textnote.d.ts +49 -0
- package/build/types/src/tickable.d.ts +140 -0
- package/build/types/src/tickcontext.d.ts +82 -0
- package/build/types/src/timesigglyph.d.ts +14 -0
- package/build/types/src/timesignature.d.ts +26 -0
- package/build/types/src/timesignote.d.ts +11 -0
- package/build/types/src/tremolo.d.ts +17 -0
- package/build/types/src/tuning.d.ts +23 -0
- package/build/types/src/tuplet.d.ts +105 -0
- package/build/types/src/typeguard.d.ts +99 -0
- package/build/types/src/util.d.ts +27 -0
- package/build/types/src/version.d.ts +3 -0
- package/build/types/src/vex.d.ts +18 -0
- package/build/types/src/vibrato.d.ts +29 -0
- package/build/types/src/vibratobracket.d.ts +33 -0
- package/build/types/src/voice.d.ts +108 -0
- package/build/types/src/web.d.ts +2 -0
- package/entry/vexflow-bravura.ts +3 -3
- package/entry/vexflow-core.ts +3 -3
- package/entry/vexflow-debug-with-tests.ts +16 -2
- package/entry/vexflow-debug.ts +11 -3
- package/entry/vexflow-gonville.ts +3 -3
- package/entry/vexflow-petaluma.ts +3 -3
- package/entry/vexflow.ts +3 -3
- package/package.json +1 -1
- package/src/annotation.ts +38 -6
- package/src/articulation.ts +8 -2
- package/src/beam.ts +53 -6
- package/src/easyscore.ts +11 -1
- package/src/factory.ts +16 -2
- package/src/flow.ts +35 -20
- package/src/font.ts +0 -4
- package/src/fonts/gonville_glyphs.ts +4 -4
- package/src/formatter.ts +24 -8
- package/src/glyph.ts +8 -0
- package/src/index.ts +2 -7
- package/src/note.ts +2 -1
- package/src/staveline.ts +2 -5
- package/src/stavenote.ts +13 -9
- package/src/stavetext.ts +3 -3
- package/src/system.ts +1 -7
- package/src/textnote.ts +9 -11
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Flow } from '../src/flow.js';
|
|
2
|
+
import { loadBravura } from '../src/fonts/load_bravura.js';
|
|
3
|
+
import { loadCustom } from '../src/fonts/load_custom.js';
|
|
4
|
+
import { loadTextFonts } from '../src/fonts/textfonts.js';
|
|
5
|
+
loadBravura();
|
|
6
|
+
loadCustom();
|
|
7
|
+
Flow.setMusicFont('Bravura', 'Custom');
|
|
8
|
+
loadTextFonts();
|
|
9
|
+
export * from '../src/index.js';
|
|
10
|
+
export * as default from '../src/index.js';
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { Flow } from '../src/flow.js';
|
|
11
|
+
import { Font } from '../src/font.js';
|
|
12
|
+
import { loadTextFonts } from '../src/fonts/textfonts.js';
|
|
13
|
+
import { globalObject, RuntimeError } from '../src/util.js';
|
|
14
|
+
const fontModules = {
|
|
15
|
+
Bravura: './vexflow-font-bravura.js',
|
|
16
|
+
Gonville: './vexflow-font-gonville.js',
|
|
17
|
+
Petaluma: './vexflow-font-petaluma.js',
|
|
18
|
+
Custom: './vexflow-font-custom.js',
|
|
19
|
+
};
|
|
20
|
+
Flow.fetchMusicFont = (fontName, fontModuleOrPath) => __awaiter(void 0, void 0, void 0, function* () {
|
|
21
|
+
const font = Font.load(fontName);
|
|
22
|
+
if (font.hasData()) {
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
if (!fontModuleOrPath) {
|
|
26
|
+
if (fontName in fontModules) {
|
|
27
|
+
fontModuleOrPath = fontModules[fontName];
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
throw new RuntimeError('UnknownFont', `Music font ${fontName} does not exist.`);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
let fontModule;
|
|
34
|
+
if (typeof fontModuleOrPath === 'string') {
|
|
35
|
+
const module = yield import(fontModuleOrPath);
|
|
36
|
+
const g = globalObject();
|
|
37
|
+
const VexFlowFont = g['VexFlowFont'];
|
|
38
|
+
if (typeof VexFlowFont !== 'undefined' && typeof VexFlowFont[fontName] !== 'undefined') {
|
|
39
|
+
fontModule = VexFlowFont[fontName];
|
|
40
|
+
}
|
|
41
|
+
else {
|
|
42
|
+
fontModule = module.Font;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
fontModule = fontModuleOrPath;
|
|
47
|
+
}
|
|
48
|
+
font.setData(fontModule.data);
|
|
49
|
+
font.setMetrics(fontModule.metrics);
|
|
50
|
+
});
|
|
51
|
+
loadTextFonts();
|
|
52
|
+
export * from '../src/index.js';
|
|
53
|
+
export * as default from '../src/index.js';
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import * as VexSrc from '../src/index.js';
|
|
2
|
+
import * as VexTests from '../tests/index.js';
|
|
3
|
+
import { Flow } from '../src/flow.js';
|
|
4
|
+
import { loadAllMusicFonts } from '../src/fonts/load_all.js';
|
|
5
|
+
import { loadTextFonts } from '../src/fonts/textfonts.js';
|
|
6
|
+
loadAllMusicFonts();
|
|
7
|
+
Flow.setMusicFont('Bravura', 'Gonville', 'Custom');
|
|
8
|
+
loadTextFonts();
|
|
9
|
+
export * from '../src/index.js';
|
|
10
|
+
export * from '../tests/index.js';
|
|
11
|
+
export default Object.assign(Object.assign({}, VexSrc), VexTests);
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Flow } from '../src/flow.js';
|
|
2
|
+
import { loadAllMusicFonts } from '../src/fonts/load_all.js';
|
|
3
|
+
import { loadTextFonts } from '../src/fonts/textfonts.js';
|
|
4
|
+
loadAllMusicFonts();
|
|
5
|
+
Flow.setMusicFont('Bravura', 'Gonville', 'Custom');
|
|
6
|
+
loadTextFonts();
|
|
7
|
+
export * from '../src/index.js';
|
|
8
|
+
export * as default from '../src/index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Flow } from '../src/flow.js';
|
|
2
|
+
import { loadCustom } from '../src/fonts/load_custom.js';
|
|
3
|
+
import { loadGonville } from '../src/fonts/load_gonville.js';
|
|
4
|
+
import { loadTextFonts } from '../src/fonts/textfonts.js';
|
|
5
|
+
loadGonville();
|
|
6
|
+
loadCustom();
|
|
7
|
+
Flow.setMusicFont('Gonville', 'Custom');
|
|
8
|
+
loadTextFonts();
|
|
9
|
+
export * from '../src/index.js';
|
|
10
|
+
export * as default from '../src/index.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Flow } from '../src/flow.js';
|
|
2
|
+
import { loadCustom } from '../src/fonts/load_custom.js';
|
|
3
|
+
import { loadPetaluma } from '../src/fonts/load_petaluma.js';
|
|
4
|
+
import { loadTextFonts } from '../src/fonts/textfonts.js';
|
|
5
|
+
loadPetaluma();
|
|
6
|
+
loadCustom();
|
|
7
|
+
Flow.setMusicFont('Petaluma', 'Custom');
|
|
8
|
+
loadTextFonts();
|
|
9
|
+
export * from '../src/index.js';
|
|
10
|
+
export * as default from '../src/index.js';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Flow } from '../src/flow.js';
|
|
2
|
+
import { loadAllMusicFonts } from '../src/fonts/load_all.js';
|
|
3
|
+
import { loadTextFonts } from '../src/fonts/textfonts.js';
|
|
4
|
+
loadAllMusicFonts();
|
|
5
|
+
Flow.setMusicFont('Bravura', 'Gonville', 'Custom');
|
|
6
|
+
loadTextFonts();
|
|
7
|
+
export * from '../src/index.js';
|
|
8
|
+
export * as default from '../src/index.js';
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { Fraction } from './fraction.js';
|
|
2
|
+
import { Glyph } from './glyph.js';
|
|
3
|
+
import { Modifier } from './modifier.js';
|
|
4
|
+
import { Music } from './music.js';
|
|
5
|
+
import { Tables } from './tables.js';
|
|
6
|
+
import { isAccidental, isGraceNote, isGraceNoteGroup, isStaveNote } from './typeguard.js';
|
|
7
|
+
import { defined, log } from './util.js';
|
|
8
|
+
function L(...args) {
|
|
9
|
+
if (Accidental.DEBUG)
|
|
10
|
+
log('Vex.Flow.Accidental', args);
|
|
11
|
+
}
|
|
12
|
+
export class Accidental extends Modifier {
|
|
13
|
+
constructor(type) {
|
|
14
|
+
super();
|
|
15
|
+
L('New accidental: ', type);
|
|
16
|
+
this.type = type;
|
|
17
|
+
this.position = Modifier.Position.LEFT;
|
|
18
|
+
this.render_options = {
|
|
19
|
+
font_scale: 38,
|
|
20
|
+
parenLeftPadding: 2,
|
|
21
|
+
parenRightPadding: 2,
|
|
22
|
+
};
|
|
23
|
+
this.accidental = Tables.accidentalCodes(this.type);
|
|
24
|
+
defined(this.accidental, 'ArgumentError', `Unknown accidental type: ${type}`);
|
|
25
|
+
this.cautionary = false;
|
|
26
|
+
this.reset();
|
|
27
|
+
}
|
|
28
|
+
static get CATEGORY() {
|
|
29
|
+
return "Accidental";
|
|
30
|
+
}
|
|
31
|
+
static format(accidentals, state) {
|
|
32
|
+
if (!accidentals || accidentals.length === 0)
|
|
33
|
+
return;
|
|
34
|
+
const musicFont = Tables.currentMusicFont();
|
|
35
|
+
const noteheadAccidentalPadding = musicFont.lookupMetric('accidental.noteheadAccidentalPadding');
|
|
36
|
+
const leftShift = state.left_shift + noteheadAccidentalPadding;
|
|
37
|
+
const accidentalSpacing = musicFont.lookupMetric('accidental.accidentalSpacing');
|
|
38
|
+
const additionalPadding = musicFont.lookupMetric('accidental.leftPadding');
|
|
39
|
+
const accList = [];
|
|
40
|
+
let prevNote = undefined;
|
|
41
|
+
let shiftL = 0;
|
|
42
|
+
for (let i = 0; i < accidentals.length; ++i) {
|
|
43
|
+
const acc = accidentals[i];
|
|
44
|
+
const note = acc.getNote();
|
|
45
|
+
const stave = note.getStave();
|
|
46
|
+
const index = acc.checkIndex();
|
|
47
|
+
const props = note.getKeyProps()[index];
|
|
48
|
+
if (note !== prevNote) {
|
|
49
|
+
for (let n = 0; n < note.keys.length; ++n) {
|
|
50
|
+
shiftL = Math.max(note.getLeftDisplacedHeadPx() - note.getXShift(), shiftL);
|
|
51
|
+
}
|
|
52
|
+
prevNote = note;
|
|
53
|
+
}
|
|
54
|
+
if (stave) {
|
|
55
|
+
const lineSpace = stave.getSpacingBetweenLines();
|
|
56
|
+
const y = stave.getYForLine(props.line);
|
|
57
|
+
const accLine = Math.round((y / lineSpace) * 2) / 2;
|
|
58
|
+
accList.push({ y, line: accLine, shift: shiftL, acc, lineSpace });
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
accList.push({ line: props.line, shift: shiftL, acc });
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
accList.sort((a, b) => b.line - a.line);
|
|
65
|
+
const lineList = [];
|
|
66
|
+
let accShift = 0;
|
|
67
|
+
let previousLine = undefined;
|
|
68
|
+
for (let i = 0; i < accList.length; i++) {
|
|
69
|
+
const acc = accList[i];
|
|
70
|
+
if (previousLine === undefined || previousLine !== acc.line) {
|
|
71
|
+
lineList.push({
|
|
72
|
+
line: acc.line,
|
|
73
|
+
flatLine: true,
|
|
74
|
+
dblSharpLine: true,
|
|
75
|
+
numAcc: 0,
|
|
76
|
+
width: 0,
|
|
77
|
+
column: 0,
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
if (acc.acc.type !== 'b' && acc.acc.type !== 'bb') {
|
|
81
|
+
lineList[lineList.length - 1].flatLine = false;
|
|
82
|
+
}
|
|
83
|
+
if (acc.acc.type !== '##') {
|
|
84
|
+
lineList[lineList.length - 1].dblSharpLine = false;
|
|
85
|
+
}
|
|
86
|
+
lineList[lineList.length - 1].numAcc++;
|
|
87
|
+
lineList[lineList.length - 1].width += acc.acc.getWidth() + accidentalSpacing;
|
|
88
|
+
accShift = acc.shift > accShift ? acc.shift : accShift;
|
|
89
|
+
previousLine = acc.line;
|
|
90
|
+
}
|
|
91
|
+
let totalColumns = 0;
|
|
92
|
+
for (let i = 0; i < lineList.length; i++) {
|
|
93
|
+
let noFurtherConflicts = false;
|
|
94
|
+
const groupStart = i;
|
|
95
|
+
let groupEnd = i;
|
|
96
|
+
while (groupEnd + 1 < lineList.length && !noFurtherConflicts) {
|
|
97
|
+
if (this.checkCollision(lineList[groupEnd], lineList[groupEnd + 1])) {
|
|
98
|
+
groupEnd++;
|
|
99
|
+
}
|
|
100
|
+
else {
|
|
101
|
+
noFurtherConflicts = true;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
const getGroupLine = (index) => lineList[groupStart + index];
|
|
105
|
+
const getGroupLines = (indexes) => indexes.map(getGroupLine);
|
|
106
|
+
const lineDifference = (indexA, indexB) => {
|
|
107
|
+
const [a, b] = getGroupLines([indexA, indexB]).map((item) => item.line);
|
|
108
|
+
return a - b;
|
|
109
|
+
};
|
|
110
|
+
const notColliding = (...indexPairs) => indexPairs.map(getGroupLines).every(([line1, line2]) => !this.checkCollision(line1, line2));
|
|
111
|
+
const groupLength = groupEnd - groupStart + 1;
|
|
112
|
+
let endCase = this.checkCollision(lineList[groupStart], lineList[groupEnd]) ? 'a' : 'b';
|
|
113
|
+
switch (groupLength) {
|
|
114
|
+
case 3:
|
|
115
|
+
if (endCase === 'a' && lineDifference(1, 2) === 0.5 && lineDifference(0, 1) !== 0.5) {
|
|
116
|
+
endCase = 'second_on_bottom';
|
|
117
|
+
}
|
|
118
|
+
break;
|
|
119
|
+
case 4:
|
|
120
|
+
if (notColliding([0, 2], [1, 3])) {
|
|
121
|
+
endCase = 'spaced_out_tetrachord';
|
|
122
|
+
}
|
|
123
|
+
break;
|
|
124
|
+
case 5:
|
|
125
|
+
if (endCase === 'b' && notColliding([1, 3])) {
|
|
126
|
+
endCase = 'spaced_out_pentachord';
|
|
127
|
+
if (notColliding([0, 2], [2, 4])) {
|
|
128
|
+
endCase = 'very_spaced_out_pentachord';
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
break;
|
|
132
|
+
case 6:
|
|
133
|
+
if (notColliding([0, 3], [1, 4], [2, 5])) {
|
|
134
|
+
endCase = 'spaced_out_hexachord';
|
|
135
|
+
}
|
|
136
|
+
if (notColliding([0, 2], [2, 4], [1, 3], [3, 5])) {
|
|
137
|
+
endCase = 'very_spaced_out_hexachord';
|
|
138
|
+
}
|
|
139
|
+
break;
|
|
140
|
+
default:
|
|
141
|
+
break;
|
|
142
|
+
}
|
|
143
|
+
let groupMember;
|
|
144
|
+
let column;
|
|
145
|
+
if (groupLength >= 7) {
|
|
146
|
+
let patternLength = 2;
|
|
147
|
+
let collisionDetected = true;
|
|
148
|
+
while (collisionDetected === true) {
|
|
149
|
+
collisionDetected = false;
|
|
150
|
+
for (let line = 0; line + patternLength < lineList.length; line++) {
|
|
151
|
+
if (this.checkCollision(lineList[line], lineList[line + patternLength])) {
|
|
152
|
+
collisionDetected = true;
|
|
153
|
+
patternLength++;
|
|
154
|
+
break;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
for (groupMember = i; groupMember <= groupEnd; groupMember++) {
|
|
159
|
+
column = ((groupMember - i) % patternLength) + 1;
|
|
160
|
+
lineList[groupMember].column = column;
|
|
161
|
+
totalColumns = totalColumns > column ? totalColumns : column;
|
|
162
|
+
}
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
for (groupMember = i; groupMember <= groupEnd; groupMember++) {
|
|
166
|
+
column = Tables.accidentalColumnsTable[groupLength][endCase][groupMember - i];
|
|
167
|
+
lineList[groupMember].column = column;
|
|
168
|
+
totalColumns = totalColumns > column ? totalColumns : column;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
i = groupEnd;
|
|
172
|
+
}
|
|
173
|
+
const columnWidths = [];
|
|
174
|
+
const columnXOffsets = [];
|
|
175
|
+
for (let i = 0; i <= totalColumns; i++) {
|
|
176
|
+
columnWidths[i] = 0;
|
|
177
|
+
columnXOffsets[i] = 0;
|
|
178
|
+
}
|
|
179
|
+
columnWidths[0] = accShift + leftShift;
|
|
180
|
+
columnXOffsets[0] = accShift + leftShift;
|
|
181
|
+
lineList.forEach((line) => {
|
|
182
|
+
if (line.width > columnWidths[line.column])
|
|
183
|
+
columnWidths[line.column] = line.width;
|
|
184
|
+
});
|
|
185
|
+
for (let i = 1; i < columnWidths.length; i++) {
|
|
186
|
+
columnXOffsets[i] = columnWidths[i] + columnXOffsets[i - 1];
|
|
187
|
+
}
|
|
188
|
+
const totalShift = columnXOffsets[columnXOffsets.length - 1];
|
|
189
|
+
let accCount = 0;
|
|
190
|
+
lineList.forEach((line) => {
|
|
191
|
+
let lineWidth = 0;
|
|
192
|
+
const lastAccOnLine = accCount + line.numAcc;
|
|
193
|
+
for (accCount; accCount < lastAccOnLine; accCount++) {
|
|
194
|
+
const xShift = columnXOffsets[line.column - 1] + lineWidth;
|
|
195
|
+
accList[accCount].acc.setXShift(xShift);
|
|
196
|
+
lineWidth += accList[accCount].acc.getWidth() + accidentalSpacing;
|
|
197
|
+
L('Line, accCount, shift: ', line.line, accCount, xShift);
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
state.left_shift += totalShift + additionalPadding;
|
|
201
|
+
}
|
|
202
|
+
static checkCollision(line1, line2) {
|
|
203
|
+
let clearance = line2.line - line1.line;
|
|
204
|
+
let clearanceRequired = 3;
|
|
205
|
+
if (clearance > 0) {
|
|
206
|
+
clearanceRequired = line2.flatLine || line2.dblSharpLine ? 2.5 : 3.0;
|
|
207
|
+
if (line1.dblSharpLine)
|
|
208
|
+
clearance -= 0.5;
|
|
209
|
+
}
|
|
210
|
+
else {
|
|
211
|
+
clearanceRequired = line1.flatLine || line1.dblSharpLine ? 2.5 : 3.0;
|
|
212
|
+
if (line2.dblSharpLine)
|
|
213
|
+
clearance -= 0.5;
|
|
214
|
+
}
|
|
215
|
+
const collision = Math.abs(clearance) < clearanceRequired;
|
|
216
|
+
L('Line_1, Line_2, Collision: ', line1.line, line2.line, collision);
|
|
217
|
+
return collision;
|
|
218
|
+
}
|
|
219
|
+
static applyAccidentals(voices, keySignature) {
|
|
220
|
+
const tickPositions = [];
|
|
221
|
+
const tickNoteMap = {};
|
|
222
|
+
voices.forEach((voice) => {
|
|
223
|
+
const tickPosition = new Fraction(0, 1);
|
|
224
|
+
const tickable = voice.getTickables();
|
|
225
|
+
tickable.forEach((t) => {
|
|
226
|
+
if (t.shouldIgnoreTicks())
|
|
227
|
+
return;
|
|
228
|
+
const notesAtPosition = tickNoteMap[tickPosition.value()];
|
|
229
|
+
if (!notesAtPosition) {
|
|
230
|
+
tickPositions.push(tickPosition.value());
|
|
231
|
+
tickNoteMap[tickPosition.value()] = [t];
|
|
232
|
+
}
|
|
233
|
+
else {
|
|
234
|
+
notesAtPosition.push(t);
|
|
235
|
+
}
|
|
236
|
+
tickPosition.add(t.getTicks());
|
|
237
|
+
});
|
|
238
|
+
});
|
|
239
|
+
const music = new Music();
|
|
240
|
+
if (!keySignature)
|
|
241
|
+
keySignature = 'C';
|
|
242
|
+
const scaleMapKey = music.createScaleMap(keySignature);
|
|
243
|
+
const scaleMap = {};
|
|
244
|
+
tickPositions.forEach((tickPos) => {
|
|
245
|
+
const tickables = tickNoteMap[tickPos];
|
|
246
|
+
const modifiedPitches = [];
|
|
247
|
+
const processNote = (t) => {
|
|
248
|
+
if (!isStaveNote(t) || t.isRest() || t.shouldIgnoreTicks()) {
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
const staveNote = t;
|
|
252
|
+
staveNote.keys.forEach((keyString, keyIndex) => {
|
|
253
|
+
const key = music.getNoteParts(keyString.split('/')[0]);
|
|
254
|
+
const octave = keyString.split('/')[1];
|
|
255
|
+
const accidentalString = key.accidental || 'n';
|
|
256
|
+
const pitch = key.root + accidentalString;
|
|
257
|
+
if (!scaleMap[key.root + octave])
|
|
258
|
+
scaleMap[key.root + octave] = scaleMapKey[key.root];
|
|
259
|
+
const sameAccidental = scaleMap[key.root + octave] === pitch;
|
|
260
|
+
const previouslyModified = modifiedPitches.indexOf(keyString) > -1;
|
|
261
|
+
staveNote.getModifiers().forEach((modifier, index) => {
|
|
262
|
+
if (isAccidental(modifier) && modifier.type == accidentalString && modifier.getIndex() == keyIndex) {
|
|
263
|
+
staveNote.getModifiers().splice(index, 1);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
if (!sameAccidental || (sameAccidental && previouslyModified)) {
|
|
267
|
+
scaleMap[key.root + octave] = pitch;
|
|
268
|
+
const accidental = new Accidental(accidentalString);
|
|
269
|
+
staveNote.addModifier(accidental, keyIndex);
|
|
270
|
+
modifiedPitches.push(keyString);
|
|
271
|
+
}
|
|
272
|
+
});
|
|
273
|
+
staveNote.getModifiers().forEach((modifier) => {
|
|
274
|
+
if (isGraceNoteGroup(modifier)) {
|
|
275
|
+
modifier.getGraceNotes().forEach(processNote);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
};
|
|
279
|
+
tickables.forEach(processNote);
|
|
280
|
+
});
|
|
281
|
+
}
|
|
282
|
+
reset() {
|
|
283
|
+
const fontScale = this.render_options.font_scale;
|
|
284
|
+
this.glyph = new Glyph(this.accidental.code, fontScale);
|
|
285
|
+
this.glyph.setOriginX(1.0);
|
|
286
|
+
if (this.cautionary) {
|
|
287
|
+
this.parenLeft = new Glyph(Tables.accidentalCodes('{').code, fontScale);
|
|
288
|
+
this.parenRight = new Glyph(Tables.accidentalCodes('}').code, fontScale);
|
|
289
|
+
this.parenLeft.setOriginX(1.0);
|
|
290
|
+
this.parenRight.setOriginX(1.0);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
getWidth() {
|
|
294
|
+
if (this.cautionary) {
|
|
295
|
+
const parenLeft = defined(this.parenLeft);
|
|
296
|
+
const parenRight = defined(this.parenRight);
|
|
297
|
+
const parenWidth = parenLeft.getMetrics().width +
|
|
298
|
+
parenRight.getMetrics().width +
|
|
299
|
+
this.render_options.parenLeftPadding +
|
|
300
|
+
this.render_options.parenRightPadding;
|
|
301
|
+
return this.glyph.getMetrics().width + parenWidth;
|
|
302
|
+
}
|
|
303
|
+
else {
|
|
304
|
+
return this.glyph.getMetrics().width;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
setNote(note) {
|
|
308
|
+
defined(note, 'ArgumentError', `Bad note value: ${note}`);
|
|
309
|
+
this.note = note;
|
|
310
|
+
if (isGraceNote(note)) {
|
|
311
|
+
this.render_options.font_scale = 25;
|
|
312
|
+
this.reset();
|
|
313
|
+
}
|
|
314
|
+
return this;
|
|
315
|
+
}
|
|
316
|
+
setAsCautionary() {
|
|
317
|
+
this.cautionary = true;
|
|
318
|
+
this.render_options.font_scale = 28;
|
|
319
|
+
this.reset();
|
|
320
|
+
return this;
|
|
321
|
+
}
|
|
322
|
+
draw() {
|
|
323
|
+
const { type, position, index, cautionary, x_shift, y_shift, glyph, render_options: { parenLeftPadding, parenRightPadding }, } = this;
|
|
324
|
+
const ctx = this.checkContext();
|
|
325
|
+
const note = this.checkAttachedNote();
|
|
326
|
+
this.setRendered();
|
|
327
|
+
const start = note.getModifierStartXY(position, index);
|
|
328
|
+
let accX = start.x + x_shift;
|
|
329
|
+
const accY = start.y + y_shift;
|
|
330
|
+
L('Rendering: ', type, accX, accY);
|
|
331
|
+
if (!cautionary) {
|
|
332
|
+
glyph.render(ctx, accX, accY);
|
|
333
|
+
}
|
|
334
|
+
else {
|
|
335
|
+
const parenLeft = defined(this.parenLeft);
|
|
336
|
+
const parenRight = defined(this.parenRight);
|
|
337
|
+
parenRight.render(ctx, accX, accY);
|
|
338
|
+
accX -= parenRight.getMetrics().width;
|
|
339
|
+
accX -= parenRightPadding;
|
|
340
|
+
accX -= this.accidental.parenRightPaddingAdjustment;
|
|
341
|
+
glyph.render(ctx, accX, accY);
|
|
342
|
+
accX -= glyph.getMetrics().width;
|
|
343
|
+
accX -= parenLeftPadding;
|
|
344
|
+
parenLeft.render(ctx, accX, accY);
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
Accidental.DEBUG = false;
|