@mcqj/vexflow 0.0.1-alpha.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/LICENSE +22 -0
- package/README.md +208 -0
- package/build/cjs/vexflow-bravura.js +2 -0
- package/build/cjs/vexflow-bravura.js.map +1 -0
- package/build/cjs/vexflow-core.js +2 -0
- package/build/cjs/vexflow-core.js.map +1 -0
- package/build/cjs/vexflow-debug-with-tests.js +43475 -0
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -0
- package/build/cjs/vexflow-debug.js +19194 -0
- package/build/cjs/vexflow-debug.js.map +1 -0
- package/build/cjs/vexflow.js +2 -0
- package/build/cjs/vexflow.js.map +1 -0
- package/build/esm/entry/vexflow-bravura.js +17 -0
- package/build/esm/entry/vexflow-core.js +4 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +38 -0
- package/build/esm/entry/vexflow-debug.js +31 -0
- package/build/esm/entry/vexflow.js +31 -0
- package/build/esm/package.json +3 -0
- package/build/esm/src/accidental.js +330 -0
- package/build/esm/src/annotation.js +231 -0
- package/build/esm/src/articulation.js +281 -0
- package/build/esm/src/barnote.js +56 -0
- package/build/esm/src/beam.js +644 -0
- package/build/esm/src/bend.js +186 -0
- package/build/esm/src/boundingbox.js +59 -0
- package/build/esm/src/canvascontext.js +216 -0
- package/build/esm/src/chordsymbol.js +325 -0
- package/build/esm/src/clef.js +120 -0
- package/build/esm/src/clefnote.js +35 -0
- package/build/esm/src/crescendo.js +78 -0
- package/build/esm/src/curve.js +126 -0
- package/build/esm/src/dot.js +129 -0
- package/build/esm/src/easyscore.js +374 -0
- package/build/esm/src/element.js +409 -0
- package/build/esm/src/factory.js +463 -0
- package/build/esm/src/flag.js +22 -0
- package/build/esm/src/font.js +237 -0
- package/build/esm/src/fonts/academico.js +1 -0
- package/build/esm/src/fonts/academicobold.js +1 -0
- package/build/esm/src/fonts/bravura.js +1 -0
- package/build/esm/src/fonts/gonville.js +1 -0
- package/build/esm/src/fonts/petaluma.js +1 -0
- package/build/esm/src/fonts/petalumascript.js +1 -0
- package/build/esm/src/formatter.js +610 -0
- package/build/esm/src/fraction.js +170 -0
- package/build/esm/src/frethandfinger.js +141 -0
- package/build/esm/src/ghostnote.js +50 -0
- package/build/esm/src/glyphnote.js +44 -0
- package/build/esm/src/glyphs.js +2936 -0
- package/build/esm/src/gracenote.js +106 -0
- package/build/esm/src/gracenotegroup.js +138 -0
- package/build/esm/src/gracetabnote.js +11 -0
- package/build/esm/src/index.js +86 -0
- package/build/esm/src/keymanager.js +99 -0
- package/build/esm/src/keysignature.js +220 -0
- package/build/esm/src/keysignote.js +28 -0
- package/build/esm/src/metrics.js +237 -0
- package/build/esm/src/modifier.js +121 -0
- package/build/esm/src/modifiercontext.js +110 -0
- package/build/esm/src/multimeasurerest.js +127 -0
- package/build/esm/src/music.js +322 -0
- package/build/esm/src/note.js +383 -0
- package/build/esm/src/notehead.js +89 -0
- package/build/esm/src/notesubgroup.js +59 -0
- package/build/esm/src/ornament.js +192 -0
- package/build/esm/src/parenthesis.js +61 -0
- package/build/esm/src/parser.js +164 -0
- package/build/esm/src/pedalmarking.js +168 -0
- package/build/esm/src/registry.js +81 -0
- package/build/esm/src/rendercontext.js +20 -0
- package/build/esm/src/renderer.js +112 -0
- package/build/esm/src/repeatnote.js +17 -0
- package/build/esm/src/stave.js +579 -0
- package/build/esm/src/stavebarline.js +237 -0
- package/build/esm/src/staveconnector.js +180 -0
- package/build/esm/src/stavehairpin.js +115 -0
- package/build/esm/src/staveline.js +199 -0
- package/build/esm/src/stavemodifier.js +56 -0
- package/build/esm/src/stavenote.js +861 -0
- package/build/esm/src/staverepetition.js +120 -0
- package/build/esm/src/stavesection.js +36 -0
- package/build/esm/src/stavetempo.js +110 -0
- package/build/esm/src/stavetext.js +55 -0
- package/build/esm/src/stavetie.js +186 -0
- package/build/esm/src/stavevolta.js +53 -0
- package/build/esm/src/stem.js +133 -0
- package/build/esm/src/stemmablenote.js +193 -0
- package/build/esm/src/stringnumber.js +228 -0
- package/build/esm/src/strokes.js +164 -0
- package/build/esm/src/svgcontext.js +402 -0
- package/build/esm/src/system.js +166 -0
- package/build/esm/src/tables.js +696 -0
- package/build/esm/src/tabnote.js +278 -0
- package/build/esm/src/tabslide.js +68 -0
- package/build/esm/src/tabstave.js +17 -0
- package/build/esm/src/tabtie.js +19 -0
- package/build/esm/src/textbracket.js +128 -0
- package/build/esm/src/textdynamics.js +53 -0
- package/build/esm/src/textnote.js +116 -0
- package/build/esm/src/tickable.js +224 -0
- package/build/esm/src/tickcontext.js +189 -0
- package/build/esm/src/timesignature.js +169 -0
- package/build/esm/src/timesignote.js +30 -0
- package/build/esm/src/tremolo.js +30 -0
- package/build/esm/src/tuning.js +55 -0
- package/build/esm/src/tuplet.js +258 -0
- package/build/esm/src/typeguard.js +30 -0
- package/build/esm/src/util.js +67 -0
- package/build/esm/src/version.js +3 -0
- package/build/esm/src/vexflow.js +309 -0
- package/build/esm/src/vibrato.js +68 -0
- package/build/esm/src/vibratobracket.js +44 -0
- package/build/esm/src/voice.js +178 -0
- package/build/esm/src/web.js +15 -0
- package/build/esm/tests/accidental_tests.js +1055 -0
- package/build/esm/tests/annotation_tests.js +381 -0
- package/build/esm/tests/articulation_tests.js +432 -0
- package/build/esm/tests/auto_beam_formatting_tests.js +551 -0
- package/build/esm/tests/barline_tests.js +52 -0
- package/build/esm/tests/beam_tests.js +669 -0
- package/build/esm/tests/bend_tests.js +223 -0
- package/build/esm/tests/boundingbox_tests.js +53 -0
- package/build/esm/tests/browser_test_runner.js +128 -0
- package/build/esm/tests/chordsymbol_tests.js +405 -0
- package/build/esm/tests/clef_tests.js +141 -0
- package/build/esm/tests/crossbeam_tests.js +306 -0
- package/build/esm/tests/curve_tests.js +152 -0
- package/build/esm/tests/demo_petzold_tests.js +335 -0
- package/build/esm/tests/dot_tests.js +119 -0
- package/build/esm/tests/easyscore_tests.js +488 -0
- package/build/esm/tests/factory_tests.js +44 -0
- package/build/esm/tests/font_tests.js +134 -0
- package/build/esm/tests/formatter/framestack.js +61 -0
- package/build/esm/tests/formatter/tests.js +251 -0
- package/build/esm/tests/formatter_tests.js +759 -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 +119 -0
- package/build/esm/tests/gracenote_tests.js +414 -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 +106 -0
- package/build/esm/tests/keymanager_tests.js +68 -0
- package/build/esm/tests/keysignature_tests.js +322 -0
- package/build/esm/tests/mocks.js +70 -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/node_test_runner.js +31 -0
- package/build/esm/tests/notehead_tests.js +224 -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 +333 -0
- package/build/esm/tests/parser_tests.js +122 -0
- package/build/esm/tests/pedalmarking_tests.js +91 -0
- package/build/esm/tests/percussion_tests.js +184 -0
- package/build/esm/tests/playwright/flow.spec.js +127 -0
- package/build/esm/tests/playwright/visual_helpers.js +30 -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 +266 -0
- package/build/esm/tests/rhythm_tests.js +357 -0
- package/build/esm/tests/stave_tests.js +570 -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 +123 -0
- package/build/esm/tests/stavemodifier_tests.js +51 -0
- package/build/esm/tests/stavenote_tests.js +936 -0
- package/build/esm/tests/stavetie_tests.js +137 -0
- package/build/esm/tests/stringnumber_tests.js +283 -0
- package/build/esm/tests/strokes_tests.js +289 -0
- package/build/esm/tests/style_tests.js +96 -0
- package/build/esm/tests/tabnote_tests.js +462 -0
- package/build/esm/tests/tabslide_tests.js +133 -0
- package/build/esm/tests/tabstave_tests.js +24 -0
- package/build/esm/tests/tabtie_tests.js +171 -0
- package/build/esm/tests/test_runner.js +23 -0
- package/build/esm/tests/textbracket_tests.js +100 -0
- package/build/esm/tests/textnote_tests.js +216 -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 +173 -0
- package/build/esm/tests/tremolo_tests.js +34 -0
- package/build/esm/tests/tuning_tests.js +56 -0
- package/build/esm/tests/tuplet_tests.js +711 -0
- package/build/esm/tests/typeguard_tests.js +82 -0
- package/build/esm/tests/unison_tests.js +74 -0
- package/build/esm/tests/vexflow_test_helpers.js +318 -0
- package/build/esm/tests/vf_prefix_tests.js +101 -0
- package/build/esm/tests/vibrato_tests.js +93 -0
- package/build/esm/tests/vibratobracket_tests.js +45 -0
- package/build/esm/tests/vitest/job-0.test.js +2 -0
- package/build/esm/tests/vitest/job-1.test.js +2 -0
- package/build/esm/tests/vitest/job-2.test.js +2 -0
- package/build/esm/tests/vitest/job-3.test.js +2 -0
- package/build/esm/tests/vitest/run.js +5 -0
- package/build/esm/tests/vitest.setup.js +44 -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.d.ts +3 -0
- package/build/types/src/accidental.d.ts +60 -0
- package/build/types/src/annotation.d.ts +58 -0
- package/build/types/src/articulation.d.ts +78 -0
- package/build/types/src/barnote.d.ts +29 -0
- package/build/types/src/beam.d.ts +158 -0
- package/build/types/src/bend.d.ts +67 -0
- package/build/types/src/boundingbox.d.ts +42 -0
- package/build/types/src/canvascontext.d.ts +93 -0
- package/build/types/src/chordsymbol.d.ts +109 -0
- package/build/types/src/clef.d.ts +38 -0
- package/build/types/src/clefnote.d.ts +17 -0
- package/build/types/src/crescendo.d.ts +26 -0
- package/build/types/src/curve.d.ts +42 -0
- package/build/types/src/dot.d.ts +19 -0
- package/build/types/src/easyscore.d.ts +152 -0
- package/build/types/src/element.d.ts +278 -0
- package/build/types/src/factory.d.ts +273 -0
- package/build/types/src/flag.d.ts +12 -0
- package/build/types/src/font.d.ts +96 -0
- package/build/types/src/fonts/academico.d.ts +1 -0
- package/build/types/src/fonts/academicobold.d.ts +1 -0
- package/build/types/src/fonts/bravura.d.ts +1 -0
- package/build/types/src/fonts/gonville.d.ts +1 -0
- package/build/types/src/fonts/petaluma.d.ts +1 -0
- package/build/types/src/fonts/petalumascript.d.ts +1 -0
- package/build/types/src/formatter.d.ts +226 -0
- package/build/types/src/fraction.d.ts +65 -0
- package/build/types/src/frethandfinger.d.ts +19 -0
- package/build/types/src/ghostnote.d.ts +16 -0
- package/build/types/src/glyphnote.d.ts +14 -0
- package/build/types/src/glyphs.d.ts +2935 -0
- package/build/types/src/gracenote.d.ts +17 -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 +86 -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/metrics.d.ts +25 -0
- package/build/types/src/modifier.d.ts +90 -0
- package/build/types/src/modifiercontext.d.ts +48 -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 +50 -0
- package/build/types/src/notesubgroup.d.ts +18 -0
- package/build/types/src/ornament.d.ts +71 -0
- package/build/types/src/parenthesis.d.ts +21 -0
- package/build/types/src/parser.d.ts +45 -0
- package/build/types/src/pedalmarking.d.ts +63 -0
- package/build/types/src/registry.d.ts +40 -0
- package/build/types/src/rendercontext.d.ts +59 -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 +181 -0
- package/build/types/src/stavebarline.d.ts +38 -0
- package/build/types/src/staveconnector.d.ts +53 -0
- package/build/types/src/stavehairpin.d.ts +56 -0
- package/build/types/src/staveline.d.ts +49 -0
- package/build/types/src/stavemodifier.d.ts +35 -0
- package/build/types/src/stavenote.d.ts +150 -0
- package/build/types/src/staverepetition.d.ts +30 -0
- package/build/types/src/stavesection.d.ts +8 -0
- package/build/types/src/stavetempo.d.ts +43 -0
- package/build/types/src/stavetext.d.ts +11 -0
- package/build/types/src/stavetie.d.ts +104 -0
- package/build/types/src/stavevolta.d.ts +15 -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 +26 -0
- package/build/types/src/strokes.d.ts +35 -0
- package/build/types/src/svgcontext.d.ts +135 -0
- package/build/types/src/system.d.ts +121 -0
- package/build/types/src/tables.d.ts +86 -0
- package/build/types/src/tabnote.d.ts +45 -0
- package/build/types/src/tabslide.d.ts +36 -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 +45 -0
- package/build/types/src/textdynamics.d.ts +34 -0
- package/build/types/src/textnote.d.ts +48 -0
- package/build/types/src/tickable.d.ts +149 -0
- package/build/types/src/tickcontext.d.ts +112 -0
- package/build/types/src/timesignature.d.ts +75 -0
- package/build/types/src/timesignote.d.ts +11 -0
- package/build/types/src/tremolo.d.ts +12 -0
- package/build/types/src/tuning.d.ts +23 -0
- package/build/types/src/tuplet.d.ts +98 -0
- package/build/types/src/typeguard.d.ts +100 -0
- package/build/types/src/util.d.ts +42 -0
- package/build/types/src/version.d.ts +3 -0
- package/build/types/src/vexflow.d.ts +261 -0
- package/build/types/src/vibrato.d.ts +20 -0
- package/build/types/src/vibratobracket.d.ts +28 -0
- package/build/types/src/voice.d.ts +109 -0
- package/build/types/src/web.d.ts +2 -0
- package/package.json +145 -0
- package/tests/flow.html +256 -0
|
@@ -0,0 +1,333 @@
|
|
|
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 { Element } from '../src/element.js';
|
|
6
|
+
import { Formatter } from '../src/formatter.js';
|
|
7
|
+
import { Glyphs } from '../src/glyphs.js';
|
|
8
|
+
import { Ornament } from '../src/ornament.js';
|
|
9
|
+
import { Stave } from '../src/stave.js';
|
|
10
|
+
import { StaveNote } from '../src/stavenote.js';
|
|
11
|
+
import { Voice, VoiceMode } from '../src/voice.js';
|
|
12
|
+
const OrnamentTests = {
|
|
13
|
+
Start() {
|
|
14
|
+
VexFlowTests.module('Ornament');
|
|
15
|
+
const run = VexFlowTests.runTests;
|
|
16
|
+
run('Ornaments', drawOrnaments);
|
|
17
|
+
run('Ornaments Vertically Shifted', drawOrnamentsDisplaced);
|
|
18
|
+
run('Ornaments - Delayed turns', drawOrnamentsDelayed);
|
|
19
|
+
run('Ornaments - Delayed turns, Multiple Draws', drawOrnamentsDelayedMultipleDraws);
|
|
20
|
+
run('Ornaments - Delayed turns, Multiple Voices', drawOrnamentsDelayedMultipleVoices);
|
|
21
|
+
run('Stacked', drawOrnamentsStacked);
|
|
22
|
+
run('With Upper/Lower Accidentals', drawOrnamentsWithAccidentals);
|
|
23
|
+
run('Jazz Ornaments', jazzOrnaments);
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
function drawOrnaments(options, contextBuilder) {
|
|
27
|
+
options.assert.expect(0);
|
|
28
|
+
const ctx = contextBuilder(options.elementId, 750, 195);
|
|
29
|
+
const stave = new Stave(10, 30, 700);
|
|
30
|
+
stave.setContext(ctx).drawWithStyle();
|
|
31
|
+
const notes = [
|
|
32
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
33
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
34
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
35
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
36
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
37
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
38
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
39
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
40
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
41
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
42
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
43
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
44
|
+
new StaveNote({ keys: ['c/4'], duration: '4', stemDirection: 1 }),
|
|
45
|
+
];
|
|
46
|
+
notes[0].addModifier(new Ornament('mordent'), 0);
|
|
47
|
+
notes[1].addModifier(new Ornament('mordentInverted'), 0);
|
|
48
|
+
notes[2].addModifier(new Ornament('turn'), 0);
|
|
49
|
+
notes[3].addModifier(new Ornament('turnInverted'), 0);
|
|
50
|
+
notes[4].addModifier(new Ornament('tr'), 0);
|
|
51
|
+
notes[5].addModifier(new Ornament('upprall'), 0);
|
|
52
|
+
notes[6].addModifier(new Ornament('downprall'), 0);
|
|
53
|
+
notes[7].addModifier(new Ornament('prallup'), 0);
|
|
54
|
+
notes[8].addModifier(new Ornament('pralldown'), 0);
|
|
55
|
+
notes[9].addModifier(new Ornament('upmordent'), 0);
|
|
56
|
+
notes[10].addModifier(new Ornament('downmordent'), 0);
|
|
57
|
+
notes[11].addModifier(new Ornament('lineprall'), 0);
|
|
58
|
+
notes[12].addModifier(new Ornament('prallprall'), 0);
|
|
59
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
60
|
+
}
|
|
61
|
+
function drawOrnamentsDisplaced(options, contextBuilder) {
|
|
62
|
+
options.assert.expect(0);
|
|
63
|
+
const ctx = contextBuilder(options.elementId, 750, 195);
|
|
64
|
+
const stave = new Stave(10, 30, 700);
|
|
65
|
+
stave.setContext(ctx).drawWithStyle();
|
|
66
|
+
const notes = [
|
|
67
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
|
|
68
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
|
|
69
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
|
|
70
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
|
|
71
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
|
|
72
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
|
|
73
|
+
new StaveNote({ keys: ['a/5'], duration: '4', stemDirection: -1 }),
|
|
74
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
75
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
76
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
77
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
78
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
79
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
80
|
+
];
|
|
81
|
+
notes[0].addModifier(new Ornament('mordent'), 0);
|
|
82
|
+
notes[1].addModifier(new Ornament('mordentInverted'), 0);
|
|
83
|
+
notes[1].addModifier(new Ornament('mordentInverted'), 0);
|
|
84
|
+
notes[2].addModifier(new Ornament('turn'), 0);
|
|
85
|
+
notes[3].addModifier(new Ornament('turnInverted'), 0);
|
|
86
|
+
notes[4].addModifier(new Ornament('tr'), 0);
|
|
87
|
+
notes[5].addModifier(new Ornament('upprall'), 0);
|
|
88
|
+
notes[6].addModifier(new Ornament('downprall'), 0);
|
|
89
|
+
notes[7].addModifier(new Ornament('prallup'), 0);
|
|
90
|
+
notes[8].addModifier(new Ornament('pralldown'), 0);
|
|
91
|
+
notes[9].addModifier(new Ornament('upmordent'), 0);
|
|
92
|
+
notes[10].addModifier(new Ornament('downmordent'), 0);
|
|
93
|
+
notes[11].addModifier(new Ornament('lineprall'), 0);
|
|
94
|
+
notes[12].addModifier(new Ornament('prallprall'), 0);
|
|
95
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
96
|
+
}
|
|
97
|
+
const addDelayedTurns = (f) => {
|
|
98
|
+
const context = f.getContext();
|
|
99
|
+
const stave = f.Stave({ x: 10, y: 30, width: 500 });
|
|
100
|
+
stave.setContext(context).drawWithStyle();
|
|
101
|
+
const notes = [
|
|
102
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
103
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
104
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
105
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
106
|
+
];
|
|
107
|
+
notes[0].addModifier(f.Ornament('turn', { delayed: true }), 0);
|
|
108
|
+
notes[1].addModifier(f.Ornament('turnInverted', { delayed: true }), 0);
|
|
109
|
+
notes[2].addModifier(f.Ornament('turnInverted', { delayed: true }), 0);
|
|
110
|
+
notes[3].addModifier(f.Ornament('turn', { delayed: true }), 0);
|
|
111
|
+
return { context, stave, notes };
|
|
112
|
+
};
|
|
113
|
+
function drawOrnamentsDelayed(options) {
|
|
114
|
+
options.assert.expect(0);
|
|
115
|
+
const f = VexFlowTests.makeFactory(options, 550, 195);
|
|
116
|
+
const { context, stave, notes } = addDelayedTurns(f);
|
|
117
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
118
|
+
}
|
|
119
|
+
function drawOrnamentsDelayedMultipleDraws(options) {
|
|
120
|
+
options.assert.expect(0);
|
|
121
|
+
const f = VexFlowTests.makeFactory(options, 550, 195);
|
|
122
|
+
const { context, stave, notes } = addDelayedTurns(f);
|
|
123
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
124
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
125
|
+
}
|
|
126
|
+
function drawOrnamentsDelayedMultipleVoices(options, contextBuilder) {
|
|
127
|
+
options.assert.expect(0);
|
|
128
|
+
const ctx = contextBuilder(options.elementId, 550, 195);
|
|
129
|
+
const stave = new Stave(10, 30, 500);
|
|
130
|
+
stave.addClef('treble');
|
|
131
|
+
stave.addKeySignature('C#');
|
|
132
|
+
stave.addTimeSignature('4/4');
|
|
133
|
+
const notes1 = [
|
|
134
|
+
new StaveNote({ keys: ['f/5'], duration: '2r' }),
|
|
135
|
+
new StaveNote({ keys: ['c/5'], duration: '2', stemDirection: 1 }),
|
|
136
|
+
];
|
|
137
|
+
const notes2 = [
|
|
138
|
+
new StaveNote({ keys: ['a/4'], duration: '4', stemDirection: -1 }),
|
|
139
|
+
new StaveNote({ keys: ['e/4'], duration: '4r' }),
|
|
140
|
+
new StaveNote({ keys: ['e/4'], duration: '2r' }),
|
|
141
|
+
];
|
|
142
|
+
notes1[1].addModifier(new Ornament('turnInverted').setDelayed(true), 0);
|
|
143
|
+
notes2[0].addModifier(new Ornament('turn').setDelayed(true), 0);
|
|
144
|
+
const voice1 = new Voice({ numBeats: 4, beatValue: 4 });
|
|
145
|
+
voice1.addTickables(notes1);
|
|
146
|
+
const voice2 = new Voice({ numBeats: 4, beatValue: 4 });
|
|
147
|
+
voice2.addTickables(notes2);
|
|
148
|
+
const formatWidth = stave.getNoteEndX() - stave.getNoteStartX();
|
|
149
|
+
const formatter = new Formatter();
|
|
150
|
+
formatter.joinVoices([voice1]);
|
|
151
|
+
formatter.joinVoices([voice2]);
|
|
152
|
+
formatter.format([voice1, voice2], formatWidth);
|
|
153
|
+
stave.setContext(ctx).drawWithStyle();
|
|
154
|
+
voice1.draw(ctx, stave);
|
|
155
|
+
voice2.draw(ctx, stave);
|
|
156
|
+
}
|
|
157
|
+
function drawOrnamentsStacked(options) {
|
|
158
|
+
options.assert.expect(0);
|
|
159
|
+
const f = VexFlowTests.makeFactory(options, 550, 195);
|
|
160
|
+
const ctx = f.getContext();
|
|
161
|
+
const stave = f.Stave({ x: 10, y: 30, width: 500 });
|
|
162
|
+
stave.setContext(ctx).drawWithStyle();
|
|
163
|
+
const notes = [
|
|
164
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
165
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
166
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
167
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', stemDirection: 1 }),
|
|
168
|
+
];
|
|
169
|
+
notes[0].addModifier(f.Ornament('mordent'), 0);
|
|
170
|
+
notes[1].addModifier(f.Ornament('turnInverted'), 0);
|
|
171
|
+
notes[2].addModifier(f.Ornament('turn'), 0);
|
|
172
|
+
notes[3].addModifier(f.Ornament('turnInverted'), 0);
|
|
173
|
+
notes[0].addModifier(f.Ornament('turn'), 0);
|
|
174
|
+
notes[1].addModifier(f.Ornament('prallup'), 0);
|
|
175
|
+
notes[2].addModifier(f.Ornament('upmordent'), 0);
|
|
176
|
+
notes[3].addModifier(f.Ornament('lineprall'), 0);
|
|
177
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
178
|
+
}
|
|
179
|
+
function drawOrnamentsWithAccidentals(options) {
|
|
180
|
+
options.assert.expect(0);
|
|
181
|
+
const f = VexFlowTests.makeFactory(options, 650, 250);
|
|
182
|
+
const ctx = f.getContext();
|
|
183
|
+
const stave = f.Stave({ x: 10, y: 60, width: 600 });
|
|
184
|
+
stave.setContext(ctx).drawWithStyle();
|
|
185
|
+
const notes = [
|
|
186
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
187
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
188
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
189
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
190
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
191
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
192
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
193
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
194
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
195
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
196
|
+
f.StaveNote({ keys: ['f/4'], duration: '4', stemDirection: 1 }),
|
|
197
|
+
];
|
|
198
|
+
notes[0].addModifier(f.Ornament('mordent', { lowerAccidental: '#', upperAccidental: '#' }), 0);
|
|
199
|
+
notes[1].addModifier(f.Ornament('turnInverted', { lowerAccidental: 'b', upperAccidental: 'b' }), 0);
|
|
200
|
+
notes[2].addModifier(f.Ornament('turn', { upperAccidental: '##', lowerAccidental: '##' }), 0);
|
|
201
|
+
notes[3].addModifier(f.Ornament('mordentInverted', { lowerAccidental: 'db', upperAccidental: 'db' }), 0);
|
|
202
|
+
notes[4].addModifier(f.Ornament('turnInverted', { upperAccidental: '++', lowerAccidental: '++' }), 0);
|
|
203
|
+
notes[5].addModifier(f.Ornament('tr', { upperAccidental: 'n', lowerAccidental: 'n' }), 0);
|
|
204
|
+
notes[6].addModifier(f.Ornament('prallup', { upperAccidental: 'd', lowerAccidental: 'd' }), 0);
|
|
205
|
+
notes[7].addModifier(f.Ornament('lineprall', { upperAccidental: 'db', lowerAccidental: 'db' }), 0);
|
|
206
|
+
notes[8].addModifier(f.Ornament('upmordent', { upperAccidental: 'bbs', lowerAccidental: 'bbs' }), 0);
|
|
207
|
+
notes[9].addModifier(f.Ornament('prallprall', { upperAccidental: 'bb', lowerAccidental: 'bb' }), 0);
|
|
208
|
+
notes[10].addModifier(f.Ornament('turnInverted', { upperAccidental: '+', lowerAccidental: '+' }), 0);
|
|
209
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
210
|
+
}
|
|
211
|
+
function jazzOrnaments(options) {
|
|
212
|
+
const clefWidth = Element.measureWidth(Glyphs.gClef);
|
|
213
|
+
function draw(modifiers, keys, x, width, y, stemDirection) {
|
|
214
|
+
const note = (keys, duration, modifier, stemDirection) => {
|
|
215
|
+
const n = new StaveNote({ keys, duration, stemDirection })
|
|
216
|
+
.addModifier(modifier, 0)
|
|
217
|
+
.addModifier(new Accidental('b'), 0);
|
|
218
|
+
const dot = duration.indexOf('d') >= 0;
|
|
219
|
+
if (dot) {
|
|
220
|
+
Dot.buildAndAttach([n], { all: true });
|
|
221
|
+
}
|
|
222
|
+
return n;
|
|
223
|
+
};
|
|
224
|
+
const stave = new Stave(x, y, width).addClef('treble').setContext(ctx).drawWithStyle();
|
|
225
|
+
const notes = [
|
|
226
|
+
note(keys, '4d', modifiers[0], stemDirection),
|
|
227
|
+
note(keys, '8', modifiers[1], stemDirection),
|
|
228
|
+
note(keys, '4d', modifiers[2], stemDirection),
|
|
229
|
+
note(keys, '8', modifiers[3], stemDirection),
|
|
230
|
+
];
|
|
231
|
+
if (modifiers.length > 4) {
|
|
232
|
+
notes[3].addModifier(modifiers[4], 0);
|
|
233
|
+
}
|
|
234
|
+
Beam.generateBeams(notes);
|
|
235
|
+
const voice = new Voice({
|
|
236
|
+
numBeats: 4,
|
|
237
|
+
beatValue: 4,
|
|
238
|
+
}).setMode(VoiceMode.SOFT);
|
|
239
|
+
voice.addTickables(notes);
|
|
240
|
+
const formatter = new Formatter().joinVoices([voice]);
|
|
241
|
+
formatter.format([voice], width - Stave.defaultPadding - clefWidth);
|
|
242
|
+
stave.setContext(ctx).drawWithStyle();
|
|
243
|
+
voice.draw(ctx, stave);
|
|
244
|
+
}
|
|
245
|
+
options.assert.expect(0);
|
|
246
|
+
const f = VexFlowTests.makeFactory(options, 950, 400);
|
|
247
|
+
const ctx = f.getContext();
|
|
248
|
+
ctx.scale(1, 1);
|
|
249
|
+
const xStart = 10;
|
|
250
|
+
const width = 300;
|
|
251
|
+
const yStart = 50;
|
|
252
|
+
const staffHeight = 70;
|
|
253
|
+
let curX = xStart;
|
|
254
|
+
let curY = yStart;
|
|
255
|
+
let mods = [
|
|
256
|
+
f.Ornament('scoop'),
|
|
257
|
+
f.Ornament('doit'),
|
|
258
|
+
f.Ornament('fall'),
|
|
259
|
+
f.Ornament('doitLong'),
|
|
260
|
+
];
|
|
261
|
+
draw(mods, ['a/5'], curX, width, curY, -1);
|
|
262
|
+
curX += width;
|
|
263
|
+
mods = [
|
|
264
|
+
f.Ornament('fallLong'),
|
|
265
|
+
f.Ornament('bend'),
|
|
266
|
+
f.Ornament('plungerClosed'),
|
|
267
|
+
f.Ornament('plungerOpen'),
|
|
268
|
+
f.Ornament('bend'),
|
|
269
|
+
];
|
|
270
|
+
draw(mods, ['a/5'], curX, width, curY, -1);
|
|
271
|
+
curX += width;
|
|
272
|
+
mods = [
|
|
273
|
+
f.Ornament('flip'),
|
|
274
|
+
f.Ornament('jazzTurn'),
|
|
275
|
+
f.Ornament('smear'),
|
|
276
|
+
f.Ornament('doit'),
|
|
277
|
+
];
|
|
278
|
+
draw(mods, ['a/5'], curX, width, curY, 1);
|
|
279
|
+
curX = xStart;
|
|
280
|
+
curY += staffHeight;
|
|
281
|
+
mods = [
|
|
282
|
+
f.Ornament('scoop'),
|
|
283
|
+
f.Ornament('doit'),
|
|
284
|
+
f.Ornament('fall'),
|
|
285
|
+
f.Ornament('doitLong'),
|
|
286
|
+
];
|
|
287
|
+
draw(mods, ['e/5'], curX, width, curY);
|
|
288
|
+
curX += width;
|
|
289
|
+
mods = [
|
|
290
|
+
f.Ornament('fallLong'),
|
|
291
|
+
f.Ornament('bend'),
|
|
292
|
+
f.Ornament('plungerClosed'),
|
|
293
|
+
f.Ornament('plungerOpen'),
|
|
294
|
+
f.Ornament('bend'),
|
|
295
|
+
];
|
|
296
|
+
draw(mods, ['e/5'], curX, width, curY);
|
|
297
|
+
curX += width;
|
|
298
|
+
mods = [
|
|
299
|
+
f.Ornament('flip'),
|
|
300
|
+
f.Ornament('jazzTurn'),
|
|
301
|
+
f.Ornament('smear'),
|
|
302
|
+
f.Ornament('doit'),
|
|
303
|
+
];
|
|
304
|
+
draw(mods, ['e/5'], curX, width, curY);
|
|
305
|
+
curX = xStart;
|
|
306
|
+
curY += staffHeight;
|
|
307
|
+
mods = [
|
|
308
|
+
f.Ornament('scoop'),
|
|
309
|
+
f.Ornament('doit'),
|
|
310
|
+
f.Ornament('fall'),
|
|
311
|
+
f.Ornament('doitLong'),
|
|
312
|
+
];
|
|
313
|
+
draw(mods, ['e/4'], curX, width, curY);
|
|
314
|
+
curX += width;
|
|
315
|
+
mods = [
|
|
316
|
+
f.Ornament('fallLong'),
|
|
317
|
+
f.Ornament('bend'),
|
|
318
|
+
f.Ornament('plungerClosed'),
|
|
319
|
+
f.Ornament('plungerOpen'),
|
|
320
|
+
f.Ornament('bend'),
|
|
321
|
+
];
|
|
322
|
+
draw(mods, ['e/4'], curX, width, curY);
|
|
323
|
+
curX += width;
|
|
324
|
+
mods = [
|
|
325
|
+
f.Ornament('flip'),
|
|
326
|
+
f.Ornament('jazzTurn'),
|
|
327
|
+
f.Ornament('smear'),
|
|
328
|
+
f.Ornament('doit'),
|
|
329
|
+
];
|
|
330
|
+
draw(mods, ['e/4'], curX, width, curY);
|
|
331
|
+
}
|
|
332
|
+
VexFlowTests.register(OrnamentTests);
|
|
333
|
+
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
|
+
VexFlowTests.module('Parser');
|
|
6
|
+
VexFlowTests.test('Basic', basic);
|
|
7
|
+
VexFlowTests.test('Advanced', advanced);
|
|
8
|
+
VexFlowTests.test('Mixed', mixed);
|
|
9
|
+
VexFlowTests.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(assert, result, expectedErrorPos, msg) {
|
|
69
|
+
assert.notOk(result.success, msg);
|
|
70
|
+
assert.equal(result.errorPos, expectedErrorPos, msg);
|
|
71
|
+
}
|
|
72
|
+
function basic(assert) {
|
|
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) => assert.equal(parser.parse(line).success, true, line));
|
|
78
|
+
fails(assert, parser.parse(''), 0);
|
|
79
|
+
fails(assert, parser.parse('first second'), 6);
|
|
80
|
+
fails(assert, parser.parse('first,,'), 5);
|
|
81
|
+
fails(assert, parser.parse('first,'), 5);
|
|
82
|
+
fails(assert, parser.parse(',,'), 0);
|
|
83
|
+
}
|
|
84
|
+
function advanced(assert) {
|
|
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) => assert.equal(parser.parse(line).success, true, line));
|
|
90
|
+
fails(assert, parser.parse('{first,second,third,}'), 19);
|
|
91
|
+
fails(assert, parser.parse('first,second,third'), 0);
|
|
92
|
+
fails(assert, parser.parse('{first,second,third'), 19);
|
|
93
|
+
fails(assert, parser.parse('{!}'), 1);
|
|
94
|
+
}
|
|
95
|
+
function mixed(assert) {
|
|
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) => assert.equal(parser.parse(line).success, true, line));
|
|
101
|
+
fails(assert, parser.parse('first second'), 6);
|
|
102
|
+
}
|
|
103
|
+
function microscore(assert) {
|
|
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
|
+
assert.equal(result.success, true, line);
|
|
115
|
+
assert.equal((_a = result.matches) === null || _a === void 0 ? void 0 : _a.length, 3, line);
|
|
116
|
+
});
|
|
117
|
+
fails(assert, parser.parse('40 42 44 45 47 49 5A 52'), 19);
|
|
118
|
+
fails(assert, parser.parse('40.44.47] [45.49.52] [47.51.54] [49.52.56]'), 2);
|
|
119
|
+
fails(assert, parser.parse('40 [40] 45 47 [44.47.51]'), 3);
|
|
120
|
+
}
|
|
121
|
+
VexFlowTests.register(ParserTests);
|
|
122
|
+
export { ParserTests };
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
const PedalMarkingTests = {
|
|
3
|
+
Start() {
|
|
4
|
+
VexFlowTests.module('PedalMarking');
|
|
5
|
+
const run = VexFlowTests.runTests;
|
|
6
|
+
run('Simple Pedal 1', simple1);
|
|
7
|
+
run('Simple Pedal 1b', simple1b);
|
|
8
|
+
run('Simple Pedal 2', simple2);
|
|
9
|
+
run('Simple Pedal 2b', simple2b);
|
|
10
|
+
run('Simple Pedal 3', simple3);
|
|
11
|
+
run('Simple Pedal 3b', simple3b);
|
|
12
|
+
run('Release and Depress on Same Note 1b', releaseDepress1b);
|
|
13
|
+
run('Release and Depress on Same Note 1', releaseDepress1);
|
|
14
|
+
run('Release and Depress on Same Note 2b', releaseDepress2b);
|
|
15
|
+
run('Release and Depress on Same Note 2', releaseDepress2);
|
|
16
|
+
run('Custom Text 1', customTest1);
|
|
17
|
+
run('Custom Text 2', customTest2);
|
|
18
|
+
},
|
|
19
|
+
};
|
|
20
|
+
function createTest(makePedal) {
|
|
21
|
+
return (options) => {
|
|
22
|
+
const f = VexFlowTests.makeFactory(options, 550, 200);
|
|
23
|
+
const score = f.EasyScore();
|
|
24
|
+
const stave0 = f.Stave({ width: 250 }).addClef('treble');
|
|
25
|
+
const voice0 = score.voice(score.notes('b4/4, b4, b4, b4[stem="down"]', { stem: 'up' }));
|
|
26
|
+
f.Formatter().joinVoices([voice0]).formatToStave([voice0], stave0);
|
|
27
|
+
const stave1 = f.Stave({ width: 260, x: 250 });
|
|
28
|
+
const voice1 = score.voice(score.notes('c4/4, c4, c4, c4', { stem: 'up' }));
|
|
29
|
+
f.Formatter().joinVoices([voice1]).formatToStave([voice1], stave1);
|
|
30
|
+
makePedal(f, voice0.getTickables(), voice1.getTickables());
|
|
31
|
+
f.draw();
|
|
32
|
+
options.assert.ok(true, 'Must render');
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function createTest2(makePedal) {
|
|
36
|
+
return (options) => {
|
|
37
|
+
const f = VexFlowTests.makeFactory(options, 550, 200);
|
|
38
|
+
const score = f.EasyScore();
|
|
39
|
+
const stave0 = f.Stave({ width: 250 }).addClef('treble');
|
|
40
|
+
const voice0 = score.voice(score.notes('b4/4, b4, b4, b4', { stem: 'down' }));
|
|
41
|
+
const voice0b = score.voice(score.notes('b5/4, b5, b5, b5', { stem: 'up' }));
|
|
42
|
+
f.Formatter().joinVoices([voice0, voice0b]).formatToStave([voice0, voice0b], stave0);
|
|
43
|
+
const stave1 = f.Stave({ width: 260, x: 250 });
|
|
44
|
+
const voice1 = score.voice(score.notes('c4/4, c4, c4, c4', { stem: 'down' }));
|
|
45
|
+
const voice1b = score.voice(score.notes('c5/4, c5, c5, c5/16, c5/16, c5/16, c5/16', { stem: 'up' }));
|
|
46
|
+
f.Formatter().joinVoices([voice1, voice1b]).formatToStave([voice1, voice1b], stave1);
|
|
47
|
+
makePedal(f, voice0.getTickables(), voice1.getTickables());
|
|
48
|
+
f.draw();
|
|
49
|
+
options.assert.ok(true, 'Must render');
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
function withSimplePedal(style) {
|
|
53
|
+
return (factory, notes0, notes1) => factory.PedalMarking({
|
|
54
|
+
notes: [notes0[0], notes0[2], notes0[3], notes1[3]],
|
|
55
|
+
options: { style },
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function withReleaseAndDepressedPedal(style) {
|
|
59
|
+
return (factory, notes0, notes1) => factory.PedalMarking({
|
|
60
|
+
notes: [notes0[0], notes0[3], notes0[3], notes1[1], notes1[1], notes1[3]],
|
|
61
|
+
options: { style },
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
const simple1 = createTest(withSimplePedal('text'));
|
|
65
|
+
const simple2 = createTest(withSimplePedal('bracket'));
|
|
66
|
+
const simple3 = createTest(withSimplePedal('mixed'));
|
|
67
|
+
const releaseDepress1 = createTest(withReleaseAndDepressedPedal('bracket'));
|
|
68
|
+
const releaseDepress2 = createTest(withReleaseAndDepressedPedal('mixed'));
|
|
69
|
+
const simple1b = createTest2(withSimplePedal('text'));
|
|
70
|
+
const simple2b = createTest2(withSimplePedal('bracket'));
|
|
71
|
+
const simple3b = createTest2(withSimplePedal('mixed'));
|
|
72
|
+
const releaseDepress1b = createTest2(withReleaseAndDepressedPedal('bracket'));
|
|
73
|
+
const releaseDepress2b = createTest2(withReleaseAndDepressedPedal('mixed'));
|
|
74
|
+
const customTest1 = createTest((factory, notes0, notes1) => {
|
|
75
|
+
const pedal = factory.PedalMarking({
|
|
76
|
+
notes: [notes0[0], notes1[3]],
|
|
77
|
+
options: { style: 'text' },
|
|
78
|
+
});
|
|
79
|
+
pedal.setCustomText('una corda', 'tre corda');
|
|
80
|
+
return pedal;
|
|
81
|
+
});
|
|
82
|
+
const customTest2 = createTest((factory, notes0, notes1) => {
|
|
83
|
+
const pedal = factory.PedalMarking({
|
|
84
|
+
notes: [notes0[0], notes1[3]],
|
|
85
|
+
options: { style: 'mixed' },
|
|
86
|
+
});
|
|
87
|
+
pedal.setCustomText('Sost. Ped.');
|
|
88
|
+
return pedal;
|
|
89
|
+
});
|
|
90
|
+
VexFlowTests.register(PedalMarkingTests);
|
|
91
|
+
export { PedalMarkingTests };
|