vexflow 4.0.1-beta.1 → 4.0.1-beta.2
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/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 +92 -24
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +38 -16
- 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 +11 -0
- package/build/esm/entry/vexflow-core.js +54 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +4 -0
- package/build/esm/entry/vexflow-debug.js +3 -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 +11 -0
- package/build/esm/entry/vexflow-petaluma.js +11 -0
- package/build/esm/entry/vexflow.js +9 -0
- package/build/esm/src/accidental.js +348 -0
- package/build/esm/src/annotation.js +232 -0
- package/build/esm/src/articulation.js +267 -0
- package/build/esm/src/barnote.js +58 -0
- package/build/esm/src/beam.js +632 -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 +440 -0
- package/build/esm/src/flow.js +275 -0
- package/build/esm/src/font.js +264 -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 +568 -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 +331 -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 +91 -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 +218 -0
- package/build/esm/src/stavemodifier.js +77 -0
- package/build/esm/src/stavenote.js +855 -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 +116 -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 +176 -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 +377 -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 +595 -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 +459 -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 +669 -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 +3 -0
- package/build/types/entry/vexflow-core.d.ts +3 -0
- package/build/types/entry/vexflow-debug.d.ts +3 -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 +3 -0
- package/build/types/entry/vexflow-petaluma.d.ts +3 -0
- package/build/types/entry/vexflow.d.ts +3 -0
- package/build/types/src/accidental.d.ts +66 -0
- package/build/types/src/annotation.d.ts +60 -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 +124 -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 +148 -0
- package/build/types/src/element.d.ts +202 -0
- package/build/types/src/factory.d.ts +271 -0
- package/build/types/src/flow.d.ts +245 -0
- package/build/types/src/font.d.ts +181 -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 +139 -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 +91 -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 +231 -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 +57 -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/package.json +1 -1
- package/src/annotation.ts +27 -6
- package/src/articulation.ts +8 -2
- package/src/fonts/gonville_glyphs.ts +4 -4
|
@@ -0,0 +1,298 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Accidental } from '../src/accidental.js';
|
|
3
|
+
import { Beam } from '../src/beam.js';
|
|
4
|
+
import { Dot } from '../src/dot.js';
|
|
5
|
+
import { Formatter } from '../src/formatter.js';
|
|
6
|
+
import { Glyph } from '../src/glyph.js';
|
|
7
|
+
import { Ornament } from '../src/ornament.js';
|
|
8
|
+
import { Stave } from '../src/stave.js';
|
|
9
|
+
import { StaveNote } from '../src/stavenote.js';
|
|
10
|
+
import { Voice, VoiceMode } from '../src/voice.js';
|
|
11
|
+
const OrnamentTests = {
|
|
12
|
+
Start() {
|
|
13
|
+
QUnit.module('Ornament');
|
|
14
|
+
const run = VexFlowTests.runTests;
|
|
15
|
+
run('Ornaments', drawOrnaments);
|
|
16
|
+
run('Ornaments Vertically Shifted', drawOrnamentsDisplaced);
|
|
17
|
+
run('Ornaments - Delayed turns', drawOrnamentsDelayed);
|
|
18
|
+
run('Ornaments - Delayed turns, Multiple Draws', drawOrnamentsDelayedMultipleDraws);
|
|
19
|
+
run('Stacked', drawOrnamentsStacked);
|
|
20
|
+
run('With Upper/Lower Accidentals', drawOrnamentsWithAccidentals);
|
|
21
|
+
run('Jazz Ornaments', jazzOrnaments);
|
|
22
|
+
},
|
|
23
|
+
};
|
|
24
|
+
function drawOrnaments(options, contextBuilder) {
|
|
25
|
+
expect(0);
|
|
26
|
+
const ctx = contextBuilder(options.elementId, 750, 195);
|
|
27
|
+
const stave = new Stave(10, 30, 700);
|
|
28
|
+
stave.setContext(ctx).draw();
|
|
29
|
+
const notes = [
|
|
30
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
31
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
32
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
33
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
34
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
35
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
36
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
37
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
38
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
39
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
40
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
41
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
42
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
43
|
+
];
|
|
44
|
+
notes[0].addModifier(new Ornament('mordent'), 0);
|
|
45
|
+
notes[1].addModifier(new Ornament('mordent_inverted'), 0);
|
|
46
|
+
notes[2].addModifier(new Ornament('turn'), 0);
|
|
47
|
+
notes[3].addModifier(new Ornament('turn_inverted'), 0);
|
|
48
|
+
notes[4].addModifier(new Ornament('tr'), 0);
|
|
49
|
+
notes[5].addModifier(new Ornament('upprall'), 0);
|
|
50
|
+
notes[6].addModifier(new Ornament('downprall'), 0);
|
|
51
|
+
notes[7].addModifier(new Ornament('prallup'), 0);
|
|
52
|
+
notes[8].addModifier(new Ornament('pralldown'), 0);
|
|
53
|
+
notes[9].addModifier(new Ornament('upmordent'), 0);
|
|
54
|
+
notes[10].addModifier(new Ornament('downmordent'), 0);
|
|
55
|
+
notes[11].addModifier(new Ornament('lineprall'), 0);
|
|
56
|
+
notes[12].addModifier(new Ornament('prallprall'), 0);
|
|
57
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
58
|
+
}
|
|
59
|
+
function drawOrnamentsDisplaced(options, contextBuilder) {
|
|
60
|
+
expect(0);
|
|
61
|
+
const ctx = contextBuilder(options.elementId, 750, 195);
|
|
62
|
+
const stave = new Stave(10, 30, 700);
|
|
63
|
+
stave.setContext(ctx).draw();
|
|
64
|
+
const notes = [
|
|
65
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
66
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
67
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
68
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
69
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
70
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
71
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
72
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
73
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
74
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
75
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
76
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
77
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
78
|
+
];
|
|
79
|
+
notes[0].addModifier(new Ornament('mordent'), 0);
|
|
80
|
+
notes[1].addModifier(new Ornament('mordent_inverted'), 0);
|
|
81
|
+
notes[1].addModifier(new Ornament('mordent_inverted'), 0);
|
|
82
|
+
notes[2].addModifier(new Ornament('turn'), 0);
|
|
83
|
+
notes[3].addModifier(new Ornament('turn_inverted'), 0);
|
|
84
|
+
notes[4].addModifier(new Ornament('tr'), 0);
|
|
85
|
+
notes[5].addModifier(new Ornament('upprall'), 0);
|
|
86
|
+
notes[6].addModifier(new Ornament('downprall'), 0);
|
|
87
|
+
notes[7].addModifier(new Ornament('prallup'), 0);
|
|
88
|
+
notes[8].addModifier(new Ornament('pralldown'), 0);
|
|
89
|
+
notes[9].addModifier(new Ornament('upmordent'), 0);
|
|
90
|
+
notes[10].addModifier(new Ornament('downmordent'), 0);
|
|
91
|
+
notes[11].addModifier(new Ornament('lineprall'), 0);
|
|
92
|
+
notes[12].addModifier(new Ornament('prallprall'), 0);
|
|
93
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
94
|
+
}
|
|
95
|
+
const addDelayedTurns = (options, contextBuilder) => {
|
|
96
|
+
const context = contextBuilder(options.elementId, 550, 195);
|
|
97
|
+
const stave = new Stave(10, 30, 500);
|
|
98
|
+
stave.setContext(context).draw();
|
|
99
|
+
const notes = [
|
|
100
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
101
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
102
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
103
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
104
|
+
];
|
|
105
|
+
notes[0].addModifier(new Ornament('turn').setDelayed(true), 0);
|
|
106
|
+
notes[1].addModifier(new Ornament('turn_inverted').setDelayed(true), 0);
|
|
107
|
+
notes[2].addModifier(new Ornament('turn_inverted').setDelayed(true), 0);
|
|
108
|
+
notes[3].addModifier(new Ornament('turn').setDelayed(true), 0);
|
|
109
|
+
return { context, stave, notes };
|
|
110
|
+
};
|
|
111
|
+
function drawOrnamentsDelayed(options, contextBuilder) {
|
|
112
|
+
expect(0);
|
|
113
|
+
const { context, stave, notes } = addDelayedTurns(options, contextBuilder);
|
|
114
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
115
|
+
}
|
|
116
|
+
function drawOrnamentsDelayedMultipleDraws(options, contextBuilder) {
|
|
117
|
+
expect(0);
|
|
118
|
+
const { context, stave, notes } = addDelayedTurns(options, contextBuilder);
|
|
119
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
120
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
121
|
+
}
|
|
122
|
+
function drawOrnamentsStacked(options, contextBuilder) {
|
|
123
|
+
expect(0);
|
|
124
|
+
const ctx = contextBuilder(options.elementId, 550, 195);
|
|
125
|
+
const stave = new Stave(10, 30, 500);
|
|
126
|
+
stave.setContext(ctx).draw();
|
|
127
|
+
const notes = [
|
|
128
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
129
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
130
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
131
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
132
|
+
];
|
|
133
|
+
notes[0].addModifier(new Ornament('mordent'), 0);
|
|
134
|
+
notes[1].addModifier(new Ornament('turn_inverted'), 0);
|
|
135
|
+
notes[2].addModifier(new Ornament('turn'), 0);
|
|
136
|
+
notes[3].addModifier(new Ornament('turn_inverted'), 0);
|
|
137
|
+
notes[0].addModifier(new Ornament('turn'), 0);
|
|
138
|
+
notes[1].addModifier(new Ornament('prallup'), 0);
|
|
139
|
+
notes[2].addModifier(new Ornament('upmordent'), 0);
|
|
140
|
+
notes[3].addModifier(new Ornament('lineprall'), 0);
|
|
141
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
142
|
+
}
|
|
143
|
+
function drawOrnamentsWithAccidentals(options, contextBuilder) {
|
|
144
|
+
expect(0);
|
|
145
|
+
const ctx = contextBuilder(options.elementId, 650, 250);
|
|
146
|
+
const stave = new Stave(10, 60, 600);
|
|
147
|
+
stave.setContext(ctx).draw();
|
|
148
|
+
const notes = [
|
|
149
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
150
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
151
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
152
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
153
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
154
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
155
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
156
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
157
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
158
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
159
|
+
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
160
|
+
];
|
|
161
|
+
notes[0].addModifier(new Ornament('mordent').setUpperAccidental('#').setLowerAccidental('#'), 0);
|
|
162
|
+
notes[1].addModifier(new Ornament('turn_inverted').setLowerAccidental('b').setUpperAccidental('b'), 0);
|
|
163
|
+
notes[2].addModifier(new Ornament('turn').setUpperAccidental('##').setLowerAccidental('##'), 0);
|
|
164
|
+
notes[3].addModifier(new Ornament('mordent_inverted').setLowerAccidental('db').setUpperAccidental('db'), 0);
|
|
165
|
+
notes[4].addModifier(new Ornament('turn_inverted').setUpperAccidental('++').setLowerAccidental('++'), 0);
|
|
166
|
+
notes[5].addModifier(new Ornament('tr').setUpperAccidental('n').setLowerAccidental('n'), 0);
|
|
167
|
+
notes[6].addModifier(new Ornament('prallup').setUpperAccidental('d').setLowerAccidental('d'), 0);
|
|
168
|
+
notes[7].addModifier(new Ornament('lineprall').setUpperAccidental('db').setLowerAccidental('db'), 0);
|
|
169
|
+
notes[8].addModifier(new Ornament('upmordent').setUpperAccidental('bbs').setLowerAccidental('bbs'), 0);
|
|
170
|
+
notes[9].addModifier(new Ornament('prallprall').setUpperAccidental('bb').setLowerAccidental('bb'), 0);
|
|
171
|
+
notes[10].addModifier(new Ornament('turn_inverted').setUpperAccidental('+').setLowerAccidental('+'), 0);
|
|
172
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
173
|
+
}
|
|
174
|
+
function jazzOrnaments(options) {
|
|
175
|
+
const clefWidth = Glyph.getWidth('gClef', 38);
|
|
176
|
+
function draw(modifiers, keys, x, width, y, stemDirection) {
|
|
177
|
+
const note = (keys, duration, modifier, stemDirection) => {
|
|
178
|
+
const n = new StaveNote({ keys, duration, stem_direction: stemDirection })
|
|
179
|
+
.addModifier(modifier, 0)
|
|
180
|
+
.addModifier(new Accidental('b'), 0);
|
|
181
|
+
const dot = duration.indexOf('d') >= 0;
|
|
182
|
+
if (dot) {
|
|
183
|
+
Dot.buildAndAttach([n], { all: true });
|
|
184
|
+
}
|
|
185
|
+
return n;
|
|
186
|
+
};
|
|
187
|
+
const stave = new Stave(x, y, width).addClef('treble').setContext(ctx).draw();
|
|
188
|
+
const notes = [
|
|
189
|
+
note(keys, '4d', modifiers[0], stemDirection),
|
|
190
|
+
note(keys, '8', modifiers[1], stemDirection),
|
|
191
|
+
note(keys, '4d', modifiers[2], stemDirection),
|
|
192
|
+
note(keys, '8', modifiers[3], stemDirection),
|
|
193
|
+
];
|
|
194
|
+
if (modifiers.length > 4) {
|
|
195
|
+
notes[3].addModifier(modifiers[4], 0);
|
|
196
|
+
}
|
|
197
|
+
Beam.generateBeams(notes);
|
|
198
|
+
const voice = new Voice({
|
|
199
|
+
num_beats: 4,
|
|
200
|
+
beat_value: 4,
|
|
201
|
+
}).setMode(VoiceMode.SOFT);
|
|
202
|
+
voice.addTickables(notes);
|
|
203
|
+
const formatter = new Formatter().joinVoices([voice]);
|
|
204
|
+
formatter.format([voice], width - Stave.defaultPadding - clefWidth);
|
|
205
|
+
stave.setContext(ctx).draw();
|
|
206
|
+
voice.draw(ctx, stave);
|
|
207
|
+
}
|
|
208
|
+
expect(0);
|
|
209
|
+
const f = VexFlowTests.makeFactory(options, 950, 400);
|
|
210
|
+
const ctx = f.getContext();
|
|
211
|
+
ctx.scale(1, 1);
|
|
212
|
+
ctx.fillStyle = '#221';
|
|
213
|
+
ctx.strokeStyle = '#221';
|
|
214
|
+
const xStart = 10;
|
|
215
|
+
const width = 300;
|
|
216
|
+
const yStart = 50;
|
|
217
|
+
const staffHeight = 70;
|
|
218
|
+
let curX = xStart;
|
|
219
|
+
let curY = yStart;
|
|
220
|
+
let mods = [
|
|
221
|
+
new Ornament('scoop'),
|
|
222
|
+
new Ornament('doit'),
|
|
223
|
+
new Ornament('fall'),
|
|
224
|
+
new Ornament('doitLong'),
|
|
225
|
+
];
|
|
226
|
+
draw(mods, ['a/5'], curX, width, curY, -1);
|
|
227
|
+
curX += width;
|
|
228
|
+
mods = [
|
|
229
|
+
new Ornament('fallLong'),
|
|
230
|
+
new Ornament('bend'),
|
|
231
|
+
new Ornament('plungerClosed'),
|
|
232
|
+
new Ornament('plungerOpen'),
|
|
233
|
+
new Ornament('bend'),
|
|
234
|
+
];
|
|
235
|
+
draw(mods, ['a/5'], curX, width, curY, -1);
|
|
236
|
+
curX += width;
|
|
237
|
+
mods = [
|
|
238
|
+
new Ornament('flip'),
|
|
239
|
+
new Ornament('jazzTurn'),
|
|
240
|
+
new Ornament('smear'),
|
|
241
|
+
new Ornament('doit'),
|
|
242
|
+
];
|
|
243
|
+
draw(mods, ['a/5'], curX, width, curY, 1);
|
|
244
|
+
curX = xStart;
|
|
245
|
+
curY += staffHeight;
|
|
246
|
+
mods = [
|
|
247
|
+
new Ornament('scoop'),
|
|
248
|
+
new Ornament('doit'),
|
|
249
|
+
new Ornament('fall'),
|
|
250
|
+
new Ornament('doitLong'),
|
|
251
|
+
];
|
|
252
|
+
draw(mods, ['e/5'], curX, width, curY);
|
|
253
|
+
curX += width;
|
|
254
|
+
mods = [
|
|
255
|
+
new Ornament('fallLong'),
|
|
256
|
+
new Ornament('bend'),
|
|
257
|
+
new Ornament('plungerClosed'),
|
|
258
|
+
new Ornament('plungerOpen'),
|
|
259
|
+
new Ornament('bend'),
|
|
260
|
+
];
|
|
261
|
+
draw(mods, ['e/5'], curX, width, curY);
|
|
262
|
+
curX += width;
|
|
263
|
+
mods = [
|
|
264
|
+
new Ornament('flip'),
|
|
265
|
+
new Ornament('jazzTurn'),
|
|
266
|
+
new Ornament('smear'),
|
|
267
|
+
new Ornament('doit'),
|
|
268
|
+
];
|
|
269
|
+
draw(mods, ['e/5'], curX, width, curY);
|
|
270
|
+
curX = xStart;
|
|
271
|
+
curY += staffHeight;
|
|
272
|
+
mods = [
|
|
273
|
+
new Ornament('scoop'),
|
|
274
|
+
new Ornament('doit'),
|
|
275
|
+
new Ornament('fall'),
|
|
276
|
+
new Ornament('doitLong'),
|
|
277
|
+
];
|
|
278
|
+
draw(mods, ['e/4'], curX, width, curY);
|
|
279
|
+
curX += width;
|
|
280
|
+
mods = [
|
|
281
|
+
new Ornament('fallLong'),
|
|
282
|
+
new Ornament('bend'),
|
|
283
|
+
new Ornament('plungerClosed'),
|
|
284
|
+
new Ornament('plungerOpen'),
|
|
285
|
+
new Ornament('bend'),
|
|
286
|
+
];
|
|
287
|
+
draw(mods, ['e/4'], curX, width, curY);
|
|
288
|
+
curX += width;
|
|
289
|
+
mods = [
|
|
290
|
+
new Ornament('flip'),
|
|
291
|
+
new Ornament('jazzTurn'),
|
|
292
|
+
new Ornament('smear'),
|
|
293
|
+
new Ornament('doit'),
|
|
294
|
+
];
|
|
295
|
+
draw(mods, ['e/4'], curX, width, curY);
|
|
296
|
+
}
|
|
297
|
+
VexFlowTests.register(OrnamentTests);
|
|
298
|
+
export { OrnamentTests };
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Parser } from '../src/parser.js';
|
|
3
|
+
const ParserTests = {
|
|
4
|
+
Start() {
|
|
5
|
+
QUnit.module('Parser');
|
|
6
|
+
test('Basic', basic);
|
|
7
|
+
test('Advanced', advanced);
|
|
8
|
+
test('Mixed', mixed);
|
|
9
|
+
test('Micro Score', microscore);
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
class TestGrammar {
|
|
13
|
+
begin() {
|
|
14
|
+
return () => ({ expect: this.expect });
|
|
15
|
+
}
|
|
16
|
+
BIGORLITTLE() {
|
|
17
|
+
return { expect: [this.BIGLINE, this.LITTLELINE], or: true };
|
|
18
|
+
}
|
|
19
|
+
BIGLINE() {
|
|
20
|
+
return { expect: [this.LBRACE, this.WORD, this.WORDS, this.MAYBEEXCLAIM, this.RBRACE] };
|
|
21
|
+
}
|
|
22
|
+
LITTLELINE() {
|
|
23
|
+
return { expect: [this.WORD, this.WORDS] };
|
|
24
|
+
}
|
|
25
|
+
WORDS() {
|
|
26
|
+
return { expect: [this.COMMA, this.WORD], zeroOrMore: true };
|
|
27
|
+
}
|
|
28
|
+
MAYBEEXCLAIM() {
|
|
29
|
+
return { expect: [this.EXCLAIM], maybe: true };
|
|
30
|
+
}
|
|
31
|
+
LBRACE() {
|
|
32
|
+
return { token: '[{]' };
|
|
33
|
+
}
|
|
34
|
+
RBRACE() {
|
|
35
|
+
return { token: '[}]' };
|
|
36
|
+
}
|
|
37
|
+
WORD() {
|
|
38
|
+
return { token: '[a-zA-Z]+' };
|
|
39
|
+
}
|
|
40
|
+
COMMA() {
|
|
41
|
+
return { token: '[,]' };
|
|
42
|
+
}
|
|
43
|
+
EXCLAIM() {
|
|
44
|
+
return { token: '[!]' };
|
|
45
|
+
}
|
|
46
|
+
EOL() {
|
|
47
|
+
return { token: '$' };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
class MicroScoreGrammar {
|
|
51
|
+
constructor() {
|
|
52
|
+
this.ITEM = () => ({ expect: [this.PIANO_KEY_NUMBER, this.CHORD], or: true });
|
|
53
|
+
this.MAYBE_MORE_ITEMS = () => ({ expect: [this.ITEM], zeroOrMore: true });
|
|
54
|
+
this.PIANO_KEY_NUMBER = () => ({ expect: [this.NUM], oneOrMore: true });
|
|
55
|
+
this.CHORD = () => ({ expect: [this.LEFT_BRACKET, this.PIANO_KEY_NUMBER, this.MORE_CHORD_PARTS, this.RIGHT_BRACKET] });
|
|
56
|
+
this.MORE_CHORD_PARTS = () => ({ expect: [this.PERIOD, this.PIANO_KEY_NUMBER], oneOrMore: true });
|
|
57
|
+
this.NUM = () => ({ token: '\\d+' });
|
|
58
|
+
this.WHITESPACE = () => ({ token: '\\s+' });
|
|
59
|
+
this.PERIOD = () => ({ token: '\\.' });
|
|
60
|
+
this.LEFT_BRACKET = () => ({ token: '\\[' });
|
|
61
|
+
this.RIGHT_BRACKET = () => ({ token: '\\]' });
|
|
62
|
+
this.EOL = () => ({ token: '$' });
|
|
63
|
+
}
|
|
64
|
+
begin() {
|
|
65
|
+
return () => ({ expect: [this.ITEM, this.MAYBE_MORE_ITEMS, this.EOL] });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function fails(result, expectedErrorPos, msg) {
|
|
69
|
+
notOk(result.success, msg);
|
|
70
|
+
equal(result.errorPos, expectedErrorPos, msg);
|
|
71
|
+
}
|
|
72
|
+
function basic() {
|
|
73
|
+
const grammar = new TestGrammar();
|
|
74
|
+
grammar.expect = [grammar.LITTLELINE, grammar.EOL];
|
|
75
|
+
const parser = new Parser(grammar);
|
|
76
|
+
const mustPass = ['first, second', 'first,second', 'first', 'first,second, third'];
|
|
77
|
+
mustPass.forEach((line) => equal(parser.parse(line).success, true, line));
|
|
78
|
+
fails(parser.parse(''), 0);
|
|
79
|
+
fails(parser.parse('first second'), 6);
|
|
80
|
+
fails(parser.parse('first,,'), 5);
|
|
81
|
+
fails(parser.parse('first,'), 5);
|
|
82
|
+
fails(parser.parse(',,'), 0);
|
|
83
|
+
}
|
|
84
|
+
function advanced() {
|
|
85
|
+
const grammar = new TestGrammar();
|
|
86
|
+
grammar.expect = [grammar.BIGLINE, grammar.EOL];
|
|
87
|
+
const parser = new Parser(grammar);
|
|
88
|
+
const mustPass = ['{first}', '{first!}', '{first,second}', '{first,second!}', '{first,second,third!}'];
|
|
89
|
+
mustPass.forEach((line) => equal(parser.parse(line).success, true, line));
|
|
90
|
+
fails(parser.parse('{first,second,third,}'), 19);
|
|
91
|
+
fails(parser.parse('first,second,third'), 0);
|
|
92
|
+
fails(parser.parse('{first,second,third'), 19);
|
|
93
|
+
fails(parser.parse('{!}'), 1);
|
|
94
|
+
}
|
|
95
|
+
function mixed() {
|
|
96
|
+
const grammar = new TestGrammar();
|
|
97
|
+
grammar.expect = [grammar.BIGORLITTLE, grammar.EOL];
|
|
98
|
+
const parser = new Parser(grammar);
|
|
99
|
+
const mustPass = ['{first,second,third!}', 'first, second'];
|
|
100
|
+
mustPass.forEach((line) => equal(parser.parse(line).success, true, line));
|
|
101
|
+
fails(parser.parse('first second'), 6);
|
|
102
|
+
}
|
|
103
|
+
function microscore() {
|
|
104
|
+
const grammar = new MicroScoreGrammar();
|
|
105
|
+
const parser = new Parser(grammar);
|
|
106
|
+
const mustPass = [
|
|
107
|
+
'40 42 44 45 47 49 51 52',
|
|
108
|
+
'[40.44.47] [45.49.52] [47.51.54] [49.52.56]',
|
|
109
|
+
'40 [40.44.47] 45 47 [44.47.51]',
|
|
110
|
+
];
|
|
111
|
+
mustPass.forEach((line) => {
|
|
112
|
+
var _a;
|
|
113
|
+
const result = parser.parse(line);
|
|
114
|
+
equal(result.success, true, line);
|
|
115
|
+
equal((_a = result.matches) === null || _a === void 0 ? void 0 : _a.length, 3, line);
|
|
116
|
+
});
|
|
117
|
+
fails(parser.parse('40 42 44 45 47 49 5A 52'), 19);
|
|
118
|
+
fails(parser.parse('40.44.47] [45.49.52] [47.51.54] [49.52.56]'), 2);
|
|
119
|
+
fails(parser.parse('40 [40] 45 47 [44.47.51]'), 3);
|
|
120
|
+
}
|
|
121
|
+
VexFlowTests.register(ParserTests);
|
|
122
|
+
export { ParserTests };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
const PedalMarkingTests = {
|
|
3
|
+
Start() {
|
|
4
|
+
QUnit.module('PedalMarking');
|
|
5
|
+
const run = VexFlowTests.runTests;
|
|
6
|
+
run('Simple Pedal 1', simple1);
|
|
7
|
+
run('Simple Pedal 2', simple2);
|
|
8
|
+
run('Simple Pedal 3', simple3);
|
|
9
|
+
run('Release and Depress on Same Note 1', releaseDepress1);
|
|
10
|
+
run('Release and Depress on Same Note 2', releaseDepress2);
|
|
11
|
+
run('Custom Text 1', customTest1);
|
|
12
|
+
run('Custom Text 2', customTest2);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
function createTest(makePedal) {
|
|
16
|
+
return (options) => {
|
|
17
|
+
const f = VexFlowTests.makeFactory(options, 550, 200);
|
|
18
|
+
const score = f.EasyScore();
|
|
19
|
+
const stave0 = f.Stave({ width: 250 }).addClef('treble');
|
|
20
|
+
const voice0 = score.voice(score.notes('b4/4, b4, b4, b4[stem="down"]', { stem: 'up' }));
|
|
21
|
+
f.Formatter().joinVoices([voice0]).formatToStave([voice0], stave0);
|
|
22
|
+
const stave1 = f.Stave({ width: 260, x: 250 });
|
|
23
|
+
const voice1 = score.voice(score.notes('c4/4, c4, c4, c4', { stem: 'up' }));
|
|
24
|
+
f.Formatter().joinVoices([voice1]).formatToStave([voice1], stave1);
|
|
25
|
+
makePedal(f, voice0.getTickables(), voice1.getTickables());
|
|
26
|
+
f.draw();
|
|
27
|
+
ok(true, 'Must render');
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
function withSimplePedal(style) {
|
|
31
|
+
return (factory, notes0, notes1) => factory.PedalMarking({
|
|
32
|
+
notes: [notes0[0], notes0[2], notes0[3], notes1[3]],
|
|
33
|
+
options: { style },
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
function withReleaseAndDepressedPedal(style) {
|
|
37
|
+
return (factory, notes0, notes1) => factory.PedalMarking({
|
|
38
|
+
notes: [notes0[0], notes0[3], notes0[3], notes1[1], notes1[1], notes1[3]],
|
|
39
|
+
options: { style },
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
const simple1 = createTest(withSimplePedal('text'));
|
|
43
|
+
const simple2 = createTest(withSimplePedal('bracket'));
|
|
44
|
+
const simple3 = createTest(withSimplePedal('mixed'));
|
|
45
|
+
const releaseDepress1 = createTest(withReleaseAndDepressedPedal('bracket'));
|
|
46
|
+
const releaseDepress2 = createTest(withReleaseAndDepressedPedal('mixed'));
|
|
47
|
+
const customTest1 = createTest((factory, notes0, notes1) => {
|
|
48
|
+
const pedal = factory.PedalMarking({
|
|
49
|
+
notes: [notes0[0], notes1[3]],
|
|
50
|
+
options: { style: 'text' },
|
|
51
|
+
});
|
|
52
|
+
pedal.setCustomText('una corda', 'tre corda');
|
|
53
|
+
return pedal;
|
|
54
|
+
});
|
|
55
|
+
const customTest2 = createTest((factory, notes0, notes1) => {
|
|
56
|
+
const pedal = factory.PedalMarking({
|
|
57
|
+
notes: [notes0[0], notes1[3]],
|
|
58
|
+
options: { style: 'mixed' },
|
|
59
|
+
});
|
|
60
|
+
pedal.setCustomText('Sost. Ped.');
|
|
61
|
+
return pedal;
|
|
62
|
+
});
|
|
63
|
+
VexFlowTests.register(PedalMarkingTests);
|
|
64
|
+
export { PedalMarkingTests };
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Dot, Font, FontStyle, FontWeight, Stave, StaveNote, TickContext, Tremolo, } from '../src/index.js';
|
|
3
|
+
const PercussionTests = {
|
|
4
|
+
Start() {
|
|
5
|
+
QUnit.module('Percussion');
|
|
6
|
+
const run = VexFlowTests.runTests;
|
|
7
|
+
run('Percussion Clef', draw);
|
|
8
|
+
run('Percussion Notes', drawNotes);
|
|
9
|
+
run('Percussion Basic0', basic0);
|
|
10
|
+
run('Percussion Basic1', basic1);
|
|
11
|
+
run('Percussion Basic2', basic2);
|
|
12
|
+
run('Percussion Snare0', snare0);
|
|
13
|
+
run('Percussion Snare1', snare1);
|
|
14
|
+
run('Percussion Snare2', snare2);
|
|
15
|
+
run('Percussion Snare3', snare3);
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
function draw(options, contextBuilder) {
|
|
19
|
+
const ctx = contextBuilder(options.elementId, 400, 120);
|
|
20
|
+
new Stave(10, 10, 300).addClef('percussion').setContext(ctx).draw();
|
|
21
|
+
ok(true);
|
|
22
|
+
}
|
|
23
|
+
function showNote(struct, stave, ctx, x) {
|
|
24
|
+
const staveNote = new StaveNote(struct).setStave(stave);
|
|
25
|
+
new TickContext().addTickable(staveNote).preFormat().setX(x);
|
|
26
|
+
staveNote.setContext(ctx).draw();
|
|
27
|
+
return staveNote;
|
|
28
|
+
}
|
|
29
|
+
function drawNotes(options, contextBuilder) {
|
|
30
|
+
const notes = [
|
|
31
|
+
{ keys: ['g/5/d0'], duration: '4' },
|
|
32
|
+
{ keys: ['g/5/d1'], duration: '4' },
|
|
33
|
+
{ keys: ['g/5/d2'], duration: '4' },
|
|
34
|
+
{ keys: ['g/5/d3'], duration: '4' },
|
|
35
|
+
{ keys: ['x/'], duration: '1' },
|
|
36
|
+
{ keys: ['g/5/t0'], duration: '1' },
|
|
37
|
+
{ keys: ['g/5/t1'], duration: '4' },
|
|
38
|
+
{ keys: ['g/5/t2'], duration: '4' },
|
|
39
|
+
{ keys: ['g/5/t3'], duration: '4' },
|
|
40
|
+
{ keys: ['x/'], duration: '1' },
|
|
41
|
+
{ keys: ['g/5/x0'], duration: '1' },
|
|
42
|
+
{ keys: ['g/5/x1'], duration: '4' },
|
|
43
|
+
{ keys: ['g/5/x2'], duration: '4' },
|
|
44
|
+
{ keys: ['g/5/x3'], duration: '4' },
|
|
45
|
+
];
|
|
46
|
+
const ctx = contextBuilder(options.elementId, notes.length * 25 + 100, 240);
|
|
47
|
+
for (let h = 0; h < 2; ++h) {
|
|
48
|
+
const stave = new Stave(10, 10 + h * 120, notes.length * 25 + 75).addClef('percussion').setContext(ctx).draw();
|
|
49
|
+
for (let i = 0; i < notes.length; ++i) {
|
|
50
|
+
const note = notes[i];
|
|
51
|
+
note.stem_direction = h === 0 ? -1 : 1;
|
|
52
|
+
const staveNote = showNote(note, stave, ctx, (i + 1) * 25);
|
|
53
|
+
ok(staveNote.getX() > 0, 'Note ' + i + ' has X value');
|
|
54
|
+
ok(staveNote.getYs().length > 0, 'Note ' + i + ' has Y values');
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
function createSingleMeasureTest(setup) {
|
|
59
|
+
return (options) => {
|
|
60
|
+
const f = VexFlowTests.makeFactory(options, 500);
|
|
61
|
+
const stave = f.Stave().addClef('percussion');
|
|
62
|
+
setup(f);
|
|
63
|
+
f.Formatter().joinVoices(f.getVoices()).formatToStave(f.getVoices(), stave);
|
|
64
|
+
f.draw();
|
|
65
|
+
ok(true);
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const basic0 = createSingleMeasureTest((f) => {
|
|
69
|
+
const voice0 = f
|
|
70
|
+
.Voice()
|
|
71
|
+
.addTickables([
|
|
72
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
73
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
74
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
75
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
76
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
77
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
78
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
79
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
80
|
+
]);
|
|
81
|
+
const voice1 = f
|
|
82
|
+
.Voice()
|
|
83
|
+
.addTickables([
|
|
84
|
+
f.StaveNote({ keys: ['f/4'], duration: '8', stem_direction: -1 }),
|
|
85
|
+
f.StaveNote({ keys: ['f/4'], duration: '8', stem_direction: -1 }),
|
|
86
|
+
f.StaveNote({ keys: ['d/4/x2', 'c/5'], duration: '4', stem_direction: -1 }),
|
|
87
|
+
f.StaveNote({ keys: ['f/4'], duration: '8', stem_direction: -1 }),
|
|
88
|
+
f.StaveNote({ keys: ['f/4'], duration: '8', stem_direction: -1 }),
|
|
89
|
+
f.StaveNote({ keys: ['d/4/x2', 'c/5'], duration: '4', stem_direction: -1 }),
|
|
90
|
+
]);
|
|
91
|
+
f.Beam({ notes: voice0.getTickables() });
|
|
92
|
+
f.Beam({ notes: voice1.getTickables().slice(0, 2) });
|
|
93
|
+
f.Beam({ notes: voice1.getTickables().slice(3, 5) });
|
|
94
|
+
});
|
|
95
|
+
const basic1 = createSingleMeasureTest((f) => {
|
|
96
|
+
f.Voice().addTickables([
|
|
97
|
+
f.StaveNote({ keys: ['f/5/x2'], duration: '4' }),
|
|
98
|
+
f.StaveNote({ keys: ['f/5/x2'], duration: '4' }),
|
|
99
|
+
f.StaveNote({ keys: ['f/5/x2'], duration: '4' }),
|
|
100
|
+
f.StaveNote({ keys: ['f/5/x2'], duration: '4' }),
|
|
101
|
+
]);
|
|
102
|
+
f.Voice().addTickables([
|
|
103
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: -1 }),
|
|
104
|
+
f.StaveNote({ keys: ['d/4/x2', 'c/5'], duration: '4', stem_direction: -1 }),
|
|
105
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: -1 }),
|
|
106
|
+
f.StaveNote({ keys: ['d/4/x2', 'c/5'], duration: '4', stem_direction: -1 }),
|
|
107
|
+
]);
|
|
108
|
+
});
|
|
109
|
+
const basic2 = createSingleMeasureTest((f) => {
|
|
110
|
+
const voice0 = f
|
|
111
|
+
.Voice()
|
|
112
|
+
.addTickables([
|
|
113
|
+
f.StaveNote({ keys: ['a/5/x3'], duration: '8' }),
|
|
114
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
115
|
+
f.StaveNote({ keys: ['g/5'], duration: '8' }),
|
|
116
|
+
f.StaveNote({ keys: ['g/4/n', 'g/5/x2'], duration: '8' }),
|
|
117
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
118
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
119
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
120
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '8' }),
|
|
121
|
+
]);
|
|
122
|
+
f.Beam({ notes: voice0.getTickables().slice(1, 8) });
|
|
123
|
+
const notes1 = [
|
|
124
|
+
f.StaveNote({ keys: ['f/4'], duration: '8', stem_direction: -1 }),
|
|
125
|
+
f.StaveNote({ keys: ['f/4'], duration: '8', stem_direction: -1 }),
|
|
126
|
+
f.StaveNote({ keys: ['d/4/x2', 'c/5'], duration: '4', stem_direction: -1 }),
|
|
127
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stem_direction: -1 }),
|
|
128
|
+
f.StaveNote({ keys: ['d/4/x2', 'c/5'], duration: '8d', stem_direction: -1 }),
|
|
129
|
+
f.StaveNote({ keys: ['c/5'], duration: '16', stem_direction: -1 }),
|
|
130
|
+
];
|
|
131
|
+
Dot.buildAndAttach([notes1[4]], { all: true });
|
|
132
|
+
const voice1 = f.Voice().addTickables(notes1);
|
|
133
|
+
f.Beam({ notes: voice1.getTickables().slice(0, 2) });
|
|
134
|
+
f.Beam({ notes: voice1.getTickables().slice(4, 6) });
|
|
135
|
+
});
|
|
136
|
+
const snare0 = createSingleMeasureTest((f) => {
|
|
137
|
+
const font = {
|
|
138
|
+
family: Font.SERIF,
|
|
139
|
+
size: 14,
|
|
140
|
+
weight: FontWeight.BOLD,
|
|
141
|
+
style: FontStyle.ITALIC,
|
|
142
|
+
};
|
|
143
|
+
f.Voice().addTickables([
|
|
144
|
+
f
|
|
145
|
+
.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: -1 })
|
|
146
|
+
.addModifier(f.Articulation({ type: 'a>' }), 0)
|
|
147
|
+
.addModifier(f.Annotation({ text: 'L', font }), 0),
|
|
148
|
+
f.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: -1 }).addModifier(f.Annotation({ text: 'R', font }), 0),
|
|
149
|
+
f.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: -1 }).addModifier(f.Annotation({ text: 'L', font }), 0),
|
|
150
|
+
f.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: -1 }).addModifier(f.Annotation({ text: 'L', font }), 0),
|
|
151
|
+
]);
|
|
152
|
+
});
|
|
153
|
+
const snare1 = createSingleMeasureTest((f) => {
|
|
154
|
+
f.Voice().addTickables([
|
|
155
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '4', stem_direction: -1 }).addModifier(f.Articulation({ type: 'ah' }), 0),
|
|
156
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '4', stem_direction: -1 }),
|
|
157
|
+
f.StaveNote({ keys: ['g/5/x2'], duration: '4', stem_direction: -1 }).addModifier(f.Articulation({ type: 'ah' }), 0),
|
|
158
|
+
f.StaveNote({ keys: ['a/5/x3'], duration: '4', stem_direction: -1 }).addModifier(f.Articulation({ type: 'a,' }), 0),
|
|
159
|
+
]);
|
|
160
|
+
});
|
|
161
|
+
const snare2 = createSingleMeasureTest((f) => {
|
|
162
|
+
f.Voice().addTickables([
|
|
163
|
+
f.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: -1 }).addModifier(new Tremolo(1), 0),
|
|
164
|
+
f.GraceNote({ keys: ['c/5'], duration: '4', stem_direction: -1 }).addModifier(new Tremolo(1), 0),
|
|
165
|
+
f.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: -1 }).addModifier(new Tremolo(3), 0),
|
|
166
|
+
f.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: -1 }).addModifier(new Tremolo(5), 0),
|
|
167
|
+
]);
|
|
168
|
+
});
|
|
169
|
+
const snare3 = createSingleMeasureTest((factory) => {
|
|
170
|
+
factory
|
|
171
|
+
.Voice()
|
|
172
|
+
.addTickables([
|
|
173
|
+
factory.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: 1 }).addModifier(new Tremolo(2), 0),
|
|
174
|
+
factory.GraceNote({ keys: ['c/5'], duration: '4', stem_direction: 1 }).addModifier(new Tremolo(2), 0),
|
|
175
|
+
factory.GraceNote({ keys: ['c/5'], duration: '4', stem_direction: 1 }).addModifier(new Tremolo(3), 0),
|
|
176
|
+
factory.StaveNote({ keys: ['c/5'], duration: '4', stem_direction: 1 }).addModifier(new Tremolo(5), 0),
|
|
177
|
+
]);
|
|
178
|
+
});
|
|
179
|
+
VexFlowTests.register(PercussionTests);
|
|
180
|
+
export { PercussionTests };
|