@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,711 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Dot } from '../src/dot.js';
|
|
3
|
+
import { Formatter } from '../src/formatter.js';
|
|
4
|
+
import { Glyphs } from '../src/glyphs.js';
|
|
5
|
+
import { Stem } from '../src/stem.js';
|
|
6
|
+
import { Tuplet } from '../src/tuplet.js';
|
|
7
|
+
const TupletTests = {
|
|
8
|
+
Start() {
|
|
9
|
+
VexFlowTests.module('Tuplet');
|
|
10
|
+
const run = VexFlowTests.runTests;
|
|
11
|
+
run('Bounding Box Above', aboveBounding);
|
|
12
|
+
run('Bounding Box Below', belowBounding);
|
|
13
|
+
run('Simple Tuplet', simple);
|
|
14
|
+
run('Beamed Tuplet', beamed);
|
|
15
|
+
run('Ratioed Tuplet', ratio);
|
|
16
|
+
run('Suffixed Tuplet', suffix);
|
|
17
|
+
run('Bottom Tuplet', bottom);
|
|
18
|
+
run('Bottom Ratioed Tuplet', bottomRatio);
|
|
19
|
+
run('Bottom Suffixed Tuplet', bottomSuffix);
|
|
20
|
+
run('Awkward Tuplet', awkward);
|
|
21
|
+
run('Complex Tuplet', complex);
|
|
22
|
+
run('Mixed Stem Direction Tuplet', mixedTop);
|
|
23
|
+
run('Mixed Stem Direction Bottom Tuplet', mixedBottom);
|
|
24
|
+
run('Nested Tuplets', nested);
|
|
25
|
+
run('Nested Tuplets Only Tuplet Children', nestedChildren);
|
|
26
|
+
run('Single Tuplets', single);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
const set = (key) => (value) => (object) => {
|
|
30
|
+
object[key] = value;
|
|
31
|
+
return object;
|
|
32
|
+
};
|
|
33
|
+
const setStemDirection = set('stemDirection');
|
|
34
|
+
const setStemUp = setStemDirection(Stem.UP);
|
|
35
|
+
const setStemDown = setStemDirection(Stem.DOWN);
|
|
36
|
+
const setDurationToQuarterNote = set('duration')('4');
|
|
37
|
+
function aboveBounding(options) {
|
|
38
|
+
const f = VexFlowTests.makeFactory(options, 600);
|
|
39
|
+
const stave = f.Stave({ x: 10, y: 10 });
|
|
40
|
+
const notes = [
|
|
41
|
+
{ keys: ['g/4'], duration: '4' },
|
|
42
|
+
{ keys: ['a/4'], duration: '4' },
|
|
43
|
+
{ keys: ['b/4'], duration: '4' },
|
|
44
|
+
{ keys: ['g/4'], duration: '4' },
|
|
45
|
+
{ keys: ['a/4'], duration: '4' },
|
|
46
|
+
{ keys: ['b/4'], duration: '4' },
|
|
47
|
+
{ keys: ['g/4'], duration: '4' },
|
|
48
|
+
{ keys: ['a/4'], duration: '4' },
|
|
49
|
+
{ keys: ['b/4'], duration: '4' },
|
|
50
|
+
{ keys: ['g/4'], duration: '4' },
|
|
51
|
+
{ keys: ['a/4'], duration: '4' },
|
|
52
|
+
{ keys: ['b/4'], duration: '4' },
|
|
53
|
+
{ keys: ['g/4'], duration: '4' },
|
|
54
|
+
{ keys: ['a/4'], duration: '4' },
|
|
55
|
+
{ keys: ['b/4'], duration: '4' },
|
|
56
|
+
{ keys: ['g/4'], duration: '4' },
|
|
57
|
+
{ keys: ['a/4'], duration: '4' },
|
|
58
|
+
{ keys: ['b/4'], duration: '4' },
|
|
59
|
+
{ keys: ['g/4'], duration: '4' },
|
|
60
|
+
{ keys: ['a/4'], duration: '4' },
|
|
61
|
+
{ keys: ['b/4'], duration: '4' },
|
|
62
|
+
]
|
|
63
|
+
.map(setStemUp)
|
|
64
|
+
.map(f.StaveNote.bind(f));
|
|
65
|
+
const tuplet = f.Tuplet({ notes: notes.slice(0, 3), options: { notesOccupied: 2, numNotes: 3, bracketed: false } });
|
|
66
|
+
const ratioedTuplet = f.Tuplet({
|
|
67
|
+
notes: notes.slice(3, 6),
|
|
68
|
+
options: { notesOccupied: 2, numNotes: 3, bracketed: false, ratioed: true },
|
|
69
|
+
});
|
|
70
|
+
const suffixTuplet = f.Tuplet({
|
|
71
|
+
notes: notes.slice(6, 9),
|
|
72
|
+
options: { notesOccupied: 2, numNotes: 3, bracketed: false, suffix: Glyphs.metNoteQuarterUp },
|
|
73
|
+
});
|
|
74
|
+
const ratioedSuffixTuplet = f.Tuplet({
|
|
75
|
+
notes: notes.slice(9, 12),
|
|
76
|
+
options: { notesOccupied: 2, numNotes: 3, bracketed: false, suffix: Glyphs.metNoteQuarterUp, ratioed: true },
|
|
77
|
+
});
|
|
78
|
+
const bracketedTuplet = f.Tuplet({ notes: notes.slice(12, 15), options: { notesOccupied: 2, numNotes: 3 } });
|
|
79
|
+
const bracketedRatioedTuplet = f.Tuplet({
|
|
80
|
+
notes: notes.slice(15, 18),
|
|
81
|
+
options: { notesOccupied: 2, numNotes: 3, ratioed: true },
|
|
82
|
+
});
|
|
83
|
+
const bracketedRatioedSuffixTuplet = f.Tuplet({
|
|
84
|
+
notes: notes.slice(18),
|
|
85
|
+
options: { notesOccupied: 2, numNotes: 3, suffix: Glyphs.metNoteQuarterUp, ratioed: true },
|
|
86
|
+
});
|
|
87
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
88
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
89
|
+
f.draw();
|
|
90
|
+
VexFlowTests.drawBoundingBox(f.getContext(), tuplet);
|
|
91
|
+
VexFlowTests.drawBoundingBox(f.getContext(), ratioedTuplet);
|
|
92
|
+
VexFlowTests.drawBoundingBox(f.getContext(), suffixTuplet);
|
|
93
|
+
VexFlowTests.drawBoundingBox(f.getContext(), ratioedSuffixTuplet);
|
|
94
|
+
VexFlowTests.drawBoundingBox(f.getContext(), bracketedTuplet);
|
|
95
|
+
VexFlowTests.drawBoundingBox(f.getContext(), bracketedRatioedTuplet);
|
|
96
|
+
VexFlowTests.drawBoundingBox(f.getContext(), bracketedRatioedSuffixTuplet);
|
|
97
|
+
options.assert.ok(true, 'Bounding Box Above Test');
|
|
98
|
+
}
|
|
99
|
+
function belowBounding(options) {
|
|
100
|
+
const f = VexFlowTests.makeFactory(options, 600);
|
|
101
|
+
const stave = f.Stave({ x: 10, y: 10 });
|
|
102
|
+
const notes = [
|
|
103
|
+
{ keys: ['g/4'], duration: '4' },
|
|
104
|
+
{ keys: ['a/4'], duration: '4' },
|
|
105
|
+
{ keys: ['b/4'], duration: '4' },
|
|
106
|
+
{ keys: ['g/4'], duration: '4' },
|
|
107
|
+
{ keys: ['a/4'], duration: '4' },
|
|
108
|
+
{ keys: ['b/4'], duration: '4' },
|
|
109
|
+
{ keys: ['g/4'], duration: '4' },
|
|
110
|
+
{ keys: ['a/4'], duration: '4' },
|
|
111
|
+
{ keys: ['b/4'], duration: '4' },
|
|
112
|
+
{ keys: ['g/4'], duration: '4' },
|
|
113
|
+
{ keys: ['a/4'], duration: '4' },
|
|
114
|
+
{ keys: ['b/4'], duration: '4' },
|
|
115
|
+
{ keys: ['g/4'], duration: '4' },
|
|
116
|
+
{ keys: ['a/4'], duration: '4' },
|
|
117
|
+
{ keys: ['b/4'], duration: '4' },
|
|
118
|
+
{ keys: ['g/4'], duration: '4' },
|
|
119
|
+
{ keys: ['a/4'], duration: '4' },
|
|
120
|
+
{ keys: ['b/4'], duration: '4' },
|
|
121
|
+
{ keys: ['g/4'], duration: '4' },
|
|
122
|
+
{ keys: ['a/4'], duration: '4' },
|
|
123
|
+
{ keys: ['b/4'], duration: '4' },
|
|
124
|
+
]
|
|
125
|
+
.map(setStemUp)
|
|
126
|
+
.map(f.StaveNote.bind(f));
|
|
127
|
+
const tuplet = f.Tuplet({
|
|
128
|
+
notes: notes.slice(0, 3),
|
|
129
|
+
options: { notesOccupied: 2, numNotes: 3, bracketed: false, location: -1 },
|
|
130
|
+
});
|
|
131
|
+
const ratioedTuplet = f.Tuplet({
|
|
132
|
+
notes: notes.slice(3, 6),
|
|
133
|
+
options: { notesOccupied: 2, numNotes: 3, bracketed: false, ratioed: true, location: -1 },
|
|
134
|
+
});
|
|
135
|
+
const suffixTuplet = f.Tuplet({
|
|
136
|
+
notes: notes.slice(6, 9),
|
|
137
|
+
options: { notesOccupied: 2, numNotes: 3, bracketed: false, suffix: Glyphs.metNoteQuarterUp, location: -1 },
|
|
138
|
+
});
|
|
139
|
+
const ratioedSuffixTuplet = f.Tuplet({
|
|
140
|
+
notes: notes.slice(9, 12),
|
|
141
|
+
options: {
|
|
142
|
+
notesOccupied: 2,
|
|
143
|
+
numNotes: 3,
|
|
144
|
+
bracketed: false,
|
|
145
|
+
suffix: Glyphs.metNoteQuarterUp,
|
|
146
|
+
ratioed: true,
|
|
147
|
+
location: -1,
|
|
148
|
+
},
|
|
149
|
+
});
|
|
150
|
+
const bracketedTuplet = f.Tuplet({
|
|
151
|
+
notes: notes.slice(12, 15),
|
|
152
|
+
options: { notesOccupied: 2, numNotes: 3, location: -1 },
|
|
153
|
+
});
|
|
154
|
+
const bracketedRatioedTuplet = f.Tuplet({
|
|
155
|
+
notes: notes.slice(15, 18),
|
|
156
|
+
options: { notesOccupied: 2, numNotes: 3, ratioed: true, location: -1 },
|
|
157
|
+
});
|
|
158
|
+
const bracketedRatioedSuffixTuplet = f.Tuplet({
|
|
159
|
+
notes: notes.slice(18),
|
|
160
|
+
options: { notesOccupied: 2, numNotes: 3, suffix: Glyphs.metNoteQuarterUp, ratioed: true, location: -1 },
|
|
161
|
+
});
|
|
162
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
163
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
164
|
+
f.draw();
|
|
165
|
+
VexFlowTests.drawBoundingBox(f.getContext(), tuplet);
|
|
166
|
+
VexFlowTests.drawBoundingBox(f.getContext(), ratioedTuplet);
|
|
167
|
+
VexFlowTests.drawBoundingBox(f.getContext(), suffixTuplet);
|
|
168
|
+
VexFlowTests.drawBoundingBox(f.getContext(), ratioedSuffixTuplet);
|
|
169
|
+
VexFlowTests.drawBoundingBox(f.getContext(), bracketedTuplet);
|
|
170
|
+
VexFlowTests.drawBoundingBox(f.getContext(), bracketedRatioedTuplet);
|
|
171
|
+
VexFlowTests.drawBoundingBox(f.getContext(), bracketedRatioedSuffixTuplet);
|
|
172
|
+
options.assert.ok(true, 'Bounding Box Below Test');
|
|
173
|
+
}
|
|
174
|
+
function simple(options) {
|
|
175
|
+
const f = VexFlowTests.makeFactory(options);
|
|
176
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addTimeSignature('3/4');
|
|
177
|
+
const notes = [
|
|
178
|
+
{ keys: ['g/4'], duration: '4' },
|
|
179
|
+
{ keys: ['a/4'], duration: '4' },
|
|
180
|
+
{ keys: ['b/4'], duration: '4' },
|
|
181
|
+
{ keys: ['b/4'], duration: '8' },
|
|
182
|
+
{ keys: ['a/4'], duration: '8' },
|
|
183
|
+
{ keys: ['g/4'], duration: '8' },
|
|
184
|
+
]
|
|
185
|
+
.map(setStemUp)
|
|
186
|
+
.map(f.StaveNote.bind(f));
|
|
187
|
+
f.Tuplet({ notes: notes.slice(0, 3) });
|
|
188
|
+
f.Tuplet({ notes: notes.slice(3, 6) });
|
|
189
|
+
const voice = f
|
|
190
|
+
.Voice({ time: { numBeats: 3, beatValue: 4 } })
|
|
191
|
+
.setStrict(true)
|
|
192
|
+
.addTickables(notes);
|
|
193
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
194
|
+
f.draw();
|
|
195
|
+
options.assert.ok(true, 'Simple Test');
|
|
196
|
+
}
|
|
197
|
+
function beamed(options) {
|
|
198
|
+
const f = VexFlowTests.makeFactory(options);
|
|
199
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addTimeSignature('3/8');
|
|
200
|
+
const notes = [
|
|
201
|
+
{ keys: ['b/4'], duration: '16' },
|
|
202
|
+
{ keys: ['a/4'], duration: '16' },
|
|
203
|
+
{ keys: ['g/4'], duration: '16' },
|
|
204
|
+
{ keys: ['a/4'], duration: '8' },
|
|
205
|
+
{ keys: ['f/4'], duration: '8' },
|
|
206
|
+
{ keys: ['a/4'], duration: '8' },
|
|
207
|
+
{ keys: ['f/4'], duration: '8' },
|
|
208
|
+
{ keys: ['a/4'], duration: '8' },
|
|
209
|
+
{ keys: ['f/4'], duration: '8' },
|
|
210
|
+
{ keys: ['g/4'], duration: '8' },
|
|
211
|
+
]
|
|
212
|
+
.map(setStemUp)
|
|
213
|
+
.map(f.StaveNote.bind(f));
|
|
214
|
+
f.Beam({ notes: notes.slice(0, 3) });
|
|
215
|
+
f.Beam({ notes: notes.slice(3, 10) });
|
|
216
|
+
f.Tuplet({ notes: notes.slice(0, 3) });
|
|
217
|
+
f.Tuplet({ notes: notes.slice(3, 10) });
|
|
218
|
+
const voice = f
|
|
219
|
+
.Voice({ time: { numBeats: 3, beatValue: 8 } })
|
|
220
|
+
.setStrict(true)
|
|
221
|
+
.addTickables(notes);
|
|
222
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
223
|
+
f.draw();
|
|
224
|
+
options.assert.ok(true, 'Beamed Test');
|
|
225
|
+
}
|
|
226
|
+
function ratio(options) {
|
|
227
|
+
const f = VexFlowTests.makeFactory(options);
|
|
228
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addTimeSignature('4/4');
|
|
229
|
+
const notes = [
|
|
230
|
+
{ keys: ['f/4'], duration: '4' },
|
|
231
|
+
{ keys: ['a/4'], duration: '4' },
|
|
232
|
+
{ keys: ['b/4'], duration: '4' },
|
|
233
|
+
{ keys: ['g/4'], duration: '8' },
|
|
234
|
+
{ keys: ['e/4'], duration: '8' },
|
|
235
|
+
{ keys: ['g/4'], duration: '8' },
|
|
236
|
+
]
|
|
237
|
+
.map(setStemUp)
|
|
238
|
+
.map(f.StaveNote.bind(f));
|
|
239
|
+
f.Beam({
|
|
240
|
+
notes: notes.slice(3, 6),
|
|
241
|
+
});
|
|
242
|
+
f.Tuplet({
|
|
243
|
+
notes: notes.slice(0, 3),
|
|
244
|
+
options: {
|
|
245
|
+
ratioed: true,
|
|
246
|
+
},
|
|
247
|
+
});
|
|
248
|
+
f.Tuplet({
|
|
249
|
+
notes: notes.slice(3, 6),
|
|
250
|
+
options: {
|
|
251
|
+
ratioed: true,
|
|
252
|
+
notesOccupied: 4,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
const voice = f.Voice().setStrict(true).addTickables(notes);
|
|
256
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
257
|
+
f.draw();
|
|
258
|
+
options.assert.ok(true, 'Ratioed Test');
|
|
259
|
+
}
|
|
260
|
+
function suffix(options) {
|
|
261
|
+
const f = VexFlowTests.makeFactory(options);
|
|
262
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addTimeSignature('4/4');
|
|
263
|
+
const notes = [
|
|
264
|
+
{ keys: ['f/4'], duration: '4' },
|
|
265
|
+
{ keys: ['a/4'], duration: '4' },
|
|
266
|
+
{ keys: ['b/4'], duration: '4' },
|
|
267
|
+
{ keys: ['g/4'], duration: '8' },
|
|
268
|
+
{ keys: ['e/4'], duration: '8' },
|
|
269
|
+
{ keys: ['g/4'], duration: '8' },
|
|
270
|
+
]
|
|
271
|
+
.map(setStemUp)
|
|
272
|
+
.map(f.StaveNote.bind(f));
|
|
273
|
+
f.Beam({
|
|
274
|
+
notes: notes.slice(3, 6),
|
|
275
|
+
});
|
|
276
|
+
f.Tuplet({
|
|
277
|
+
notes: notes.slice(0, 3),
|
|
278
|
+
options: {
|
|
279
|
+
ratioed: true,
|
|
280
|
+
suffix: Glyphs.noteQuarterUp,
|
|
281
|
+
},
|
|
282
|
+
});
|
|
283
|
+
f.Tuplet({
|
|
284
|
+
notes: notes.slice(3, 6),
|
|
285
|
+
options: {
|
|
286
|
+
ratioed: true,
|
|
287
|
+
notesOccupied: 4,
|
|
288
|
+
suffix: Glyphs.note8thUp,
|
|
289
|
+
},
|
|
290
|
+
});
|
|
291
|
+
const voice = f.Voice().setStrict(true).addTickables(notes);
|
|
292
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
293
|
+
f.draw();
|
|
294
|
+
options.assert.ok(true, 'Base Duration Test');
|
|
295
|
+
}
|
|
296
|
+
function bottom(options) {
|
|
297
|
+
const f = VexFlowTests.makeFactory(options, 350, 160);
|
|
298
|
+
const stave = f.Stave({ x: 10, y: 10 }).addTimeSignature('3/4');
|
|
299
|
+
const notes = [
|
|
300
|
+
{ keys: ['f/4'], duration: '4' },
|
|
301
|
+
{ keys: ['c/4'], duration: '4' },
|
|
302
|
+
{ keys: ['g/4'], duration: '4' },
|
|
303
|
+
{ keys: ['d/5'], duration: '8' },
|
|
304
|
+
{ keys: ['g/3'], duration: '8' },
|
|
305
|
+
{ keys: ['b/4'], duration: '8' },
|
|
306
|
+
]
|
|
307
|
+
.map(setStemDown)
|
|
308
|
+
.map(f.StaveNote.bind(f));
|
|
309
|
+
f.Beam({
|
|
310
|
+
notes: notes.slice(3, 6),
|
|
311
|
+
});
|
|
312
|
+
f.Tuplet({
|
|
313
|
+
notes: notes.slice(0, 3),
|
|
314
|
+
options: { location: Tuplet.LOCATION_BOTTOM },
|
|
315
|
+
});
|
|
316
|
+
f.Tuplet({
|
|
317
|
+
notes: notes.slice(3, 6),
|
|
318
|
+
options: { location: Tuplet.LOCATION_BOTTOM },
|
|
319
|
+
});
|
|
320
|
+
const voice = f
|
|
321
|
+
.Voice({ time: { numBeats: 3, beatValue: 4 } })
|
|
322
|
+
.setStrict(true)
|
|
323
|
+
.addTickables(notes);
|
|
324
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
325
|
+
f.draw();
|
|
326
|
+
options.assert.ok(true, 'Bottom Test');
|
|
327
|
+
}
|
|
328
|
+
function bottomRatio(options) {
|
|
329
|
+
const f = VexFlowTests.makeFactory(options, 350, 160);
|
|
330
|
+
const stave = f.Stave({ x: 10, y: 10 }).addTimeSignature('5/8');
|
|
331
|
+
const notes = [
|
|
332
|
+
{ keys: ['f/4'], duration: '4' },
|
|
333
|
+
{ keys: ['c/4'], duration: '4' },
|
|
334
|
+
{ keys: ['d/4'], duration: '4' },
|
|
335
|
+
{ keys: ['d/5'], duration: '8' },
|
|
336
|
+
{ keys: ['g/5'], duration: '8' },
|
|
337
|
+
{ keys: ['b/4'], duration: '8' },
|
|
338
|
+
]
|
|
339
|
+
.map(setStemDown)
|
|
340
|
+
.map(f.StaveNote.bind(f));
|
|
341
|
+
f.Beam({
|
|
342
|
+
notes: notes.slice(3, 6),
|
|
343
|
+
});
|
|
344
|
+
f.Tuplet({
|
|
345
|
+
notes: notes.slice(0, 3),
|
|
346
|
+
options: {
|
|
347
|
+
location: Tuplet.LOCATION_BOTTOM,
|
|
348
|
+
ratioed: true,
|
|
349
|
+
},
|
|
350
|
+
});
|
|
351
|
+
f.Tuplet({
|
|
352
|
+
notes: notes.slice(3, 6),
|
|
353
|
+
options: {
|
|
354
|
+
location: Tuplet.LOCATION_BOTTOM,
|
|
355
|
+
notesOccupied: 1,
|
|
356
|
+
},
|
|
357
|
+
});
|
|
358
|
+
const voice = f
|
|
359
|
+
.Voice({ time: { numBeats: 5, beatValue: 8 } })
|
|
360
|
+
.setStrict(true)
|
|
361
|
+
.addTickables(notes);
|
|
362
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
363
|
+
f.draw();
|
|
364
|
+
options.assert.ok(true, 'Bottom Ratioed Test');
|
|
365
|
+
}
|
|
366
|
+
function bottomSuffix(options) {
|
|
367
|
+
const f = VexFlowTests.makeFactory(options, 350, 160);
|
|
368
|
+
const stave = f.Stave({ x: 10, y: 10 }).addTimeSignature('5/8');
|
|
369
|
+
const notes = [
|
|
370
|
+
{ keys: ['f/4'], duration: '4' },
|
|
371
|
+
{ keys: ['c/4'], duration: '4' },
|
|
372
|
+
{ keys: ['d/4'], duration: '4' },
|
|
373
|
+
{ keys: ['d/5'], duration: '8' },
|
|
374
|
+
{ keys: ['g/5'], duration: '8' },
|
|
375
|
+
{ keys: ['b/4'], duration: '8' },
|
|
376
|
+
]
|
|
377
|
+
.map(setStemDown)
|
|
378
|
+
.map(f.StaveNote.bind(f));
|
|
379
|
+
f.Beam({
|
|
380
|
+
notes: notes.slice(3, 6),
|
|
381
|
+
});
|
|
382
|
+
f.Tuplet({
|
|
383
|
+
notes: notes.slice(0, 3),
|
|
384
|
+
options: {
|
|
385
|
+
location: Tuplet.LOCATION_BOTTOM,
|
|
386
|
+
ratioed: true,
|
|
387
|
+
suffix: Glyphs.metNoteQuarterUp,
|
|
388
|
+
},
|
|
389
|
+
});
|
|
390
|
+
f.Tuplet({
|
|
391
|
+
notes: notes.slice(3, 6),
|
|
392
|
+
options: {
|
|
393
|
+
location: Tuplet.LOCATION_BOTTOM,
|
|
394
|
+
notesOccupied: 1,
|
|
395
|
+
suffix: Glyphs.metNote8thUp,
|
|
396
|
+
},
|
|
397
|
+
});
|
|
398
|
+
const voice = f
|
|
399
|
+
.Voice({ time: { numBeats: 5, beatValue: 8 } })
|
|
400
|
+
.setStrict(true)
|
|
401
|
+
.addTickables(notes);
|
|
402
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
403
|
+
f.draw();
|
|
404
|
+
options.assert.ok(true, 'Bottom Base Duration Test');
|
|
405
|
+
}
|
|
406
|
+
function awkward(options) {
|
|
407
|
+
const f = VexFlowTests.makeFactory(options, 370, 160);
|
|
408
|
+
const stave = f.Stave({ x: 10, y: 10 });
|
|
409
|
+
const notes = [
|
|
410
|
+
{ keys: ['g/4'], duration: '16' },
|
|
411
|
+
{ keys: ['b/4'], duration: '16' },
|
|
412
|
+
{ keys: ['a/4'], duration: '16' },
|
|
413
|
+
{ keys: ['a/4'], duration: '16' },
|
|
414
|
+
{ keys: ['g/4'], duration: '16' },
|
|
415
|
+
{ keys: ['f/4'], duration: '16' },
|
|
416
|
+
{ keys: ['e/4'], duration: '16' },
|
|
417
|
+
{ keys: ['c/4'], duration: '16' },
|
|
418
|
+
{ keys: ['g/4'], duration: '16' },
|
|
419
|
+
{ keys: ['a/4'], duration: '16' },
|
|
420
|
+
{ keys: ['f/4'], duration: '16' },
|
|
421
|
+
{ keys: ['e/4'], duration: '16' },
|
|
422
|
+
{ keys: ['c/4'], duration: '8' },
|
|
423
|
+
{ keys: ['d/4'], duration: '8' },
|
|
424
|
+
{ keys: ['e/4'], duration: '8' },
|
|
425
|
+
]
|
|
426
|
+
.map(setStemUp)
|
|
427
|
+
.map(f.StaveNote.bind(f));
|
|
428
|
+
f.Beam({ notes: notes.slice(0, 12) });
|
|
429
|
+
f.Tuplet({
|
|
430
|
+
notes: notes.slice(0, 12),
|
|
431
|
+
options: {
|
|
432
|
+
notesOccupied: 142,
|
|
433
|
+
ratioed: true,
|
|
434
|
+
},
|
|
435
|
+
});
|
|
436
|
+
f.Tuplet({
|
|
437
|
+
notes: notes.slice(12, 15),
|
|
438
|
+
options: {
|
|
439
|
+
ratioed: true,
|
|
440
|
+
},
|
|
441
|
+
}).setBracketed(true);
|
|
442
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
443
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
444
|
+
f.draw();
|
|
445
|
+
options.assert.ok(true, 'Awkward Test');
|
|
446
|
+
}
|
|
447
|
+
function complex(options) {
|
|
448
|
+
const f = VexFlowTests.makeFactory(options, 600);
|
|
449
|
+
const stave = f.Stave({ x: 10, y: 10 }).addTimeSignature('4/4');
|
|
450
|
+
const notes1 = [
|
|
451
|
+
{ keys: ['b/4'], duration: '8d' },
|
|
452
|
+
{ keys: ['a/4'], duration: '16' },
|
|
453
|
+
{ keys: ['g/4'], duration: '8' },
|
|
454
|
+
{ keys: ['a/4'], duration: '16' },
|
|
455
|
+
{ keys: ['b/4'], duration: '16r' },
|
|
456
|
+
{ keys: ['g/4'], duration: '32' },
|
|
457
|
+
{ keys: ['f/4'], duration: '32' },
|
|
458
|
+
{ keys: ['g/4'], duration: '32' },
|
|
459
|
+
{ keys: ['f/4'], duration: '32' },
|
|
460
|
+
{ keys: ['a/4'], duration: '16' },
|
|
461
|
+
{ keys: ['f/4'], duration: '8' },
|
|
462
|
+
{ keys: ['b/4'], duration: '8' },
|
|
463
|
+
{ keys: ['a/4'], duration: '8' },
|
|
464
|
+
{ keys: ['g/4'], duration: '8' },
|
|
465
|
+
{ keys: ['b/4'], duration: '8' },
|
|
466
|
+
{ keys: ['a/4'], duration: '8' },
|
|
467
|
+
]
|
|
468
|
+
.map(setStemUp)
|
|
469
|
+
.map(f.StaveNote.bind(f));
|
|
470
|
+
Dot.buildAndAttach([notes1[0]], { all: true });
|
|
471
|
+
const notes2 = [{ keys: ['c/4'] }, { keys: ['c/4'] }, { keys: ['c/4'] }, { keys: ['c/4'] }]
|
|
472
|
+
.map(setDurationToQuarterNote)
|
|
473
|
+
.map(setStemDown)
|
|
474
|
+
.map(f.StaveNote.bind(f));
|
|
475
|
+
f.Beam({ notes: notes1.slice(0, 3) });
|
|
476
|
+
f.Beam({ notes: notes1.slice(5, 9) });
|
|
477
|
+
f.Beam({ notes: notes1.slice(11, 16) });
|
|
478
|
+
f.Tuplet({
|
|
479
|
+
notes: notes1.slice(0, 3),
|
|
480
|
+
});
|
|
481
|
+
f.Tuplet({
|
|
482
|
+
notes: notes1.slice(3, 11),
|
|
483
|
+
options: {
|
|
484
|
+
numNotes: 7,
|
|
485
|
+
notesOccupied: 4,
|
|
486
|
+
ratioed: false,
|
|
487
|
+
},
|
|
488
|
+
});
|
|
489
|
+
f.Tuplet({
|
|
490
|
+
notes: notes1.slice(11, 16),
|
|
491
|
+
options: {
|
|
492
|
+
notesOccupied: 4,
|
|
493
|
+
},
|
|
494
|
+
});
|
|
495
|
+
const voice1 = f.Voice().setStrict(true).addTickables(notes1);
|
|
496
|
+
const voice2 = f.Voice().setStrict(true).addTickables(notes2);
|
|
497
|
+
new Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave);
|
|
498
|
+
f.draw();
|
|
499
|
+
options.assert.ok(true, 'Complex Test');
|
|
500
|
+
}
|
|
501
|
+
function mixedTop(options) {
|
|
502
|
+
const f = VexFlowTests.makeFactory(options);
|
|
503
|
+
const stave = f.Stave({ x: 10, y: 10 });
|
|
504
|
+
const notes = [
|
|
505
|
+
{ keys: ['a/4'], stemDirection: 1 },
|
|
506
|
+
{ keys: ['c/6'], stemDirection: -1 },
|
|
507
|
+
{ keys: ['a/4'], stemDirection: 1 },
|
|
508
|
+
{ keys: ['f/5'], stemDirection: 1 },
|
|
509
|
+
{ keys: ['a/4'], stemDirection: -1 },
|
|
510
|
+
{ keys: ['c/6'], stemDirection: -1 },
|
|
511
|
+
]
|
|
512
|
+
.map(setDurationToQuarterNote)
|
|
513
|
+
.map(f.StaveNote.bind(f));
|
|
514
|
+
f.Tuplet({
|
|
515
|
+
notes: notes.slice(0, 2),
|
|
516
|
+
options: {
|
|
517
|
+
notesOccupied: 3,
|
|
518
|
+
},
|
|
519
|
+
});
|
|
520
|
+
f.Tuplet({
|
|
521
|
+
notes: notes.slice(2, 4),
|
|
522
|
+
options: {
|
|
523
|
+
notesOccupied: 3,
|
|
524
|
+
},
|
|
525
|
+
});
|
|
526
|
+
f.Tuplet({
|
|
527
|
+
notes: notes.slice(4, 6),
|
|
528
|
+
options: {
|
|
529
|
+
notesOccupied: 3,
|
|
530
|
+
},
|
|
531
|
+
});
|
|
532
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
533
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
534
|
+
f.draw();
|
|
535
|
+
options.assert.ok(true, 'Mixed Stem Direction Tuplet');
|
|
536
|
+
}
|
|
537
|
+
function mixedBottom(options) {
|
|
538
|
+
const f = VexFlowTests.makeFactory(options);
|
|
539
|
+
const stave = f.Stave({ x: 10, y: 10 });
|
|
540
|
+
const notes = [
|
|
541
|
+
{ keys: ['f/3'], stemDirection: 1 },
|
|
542
|
+
{ keys: ['a/5'], stemDirection: -1 },
|
|
543
|
+
{ keys: ['a/4'], stemDirection: 1 },
|
|
544
|
+
{ keys: ['f/3'], stemDirection: 1 },
|
|
545
|
+
{ keys: ['a/4'], stemDirection: -1 },
|
|
546
|
+
{ keys: ['c/4'], stemDirection: -1 },
|
|
547
|
+
]
|
|
548
|
+
.map(setDurationToQuarterNote)
|
|
549
|
+
.map(f.StaveNote.bind(f));
|
|
550
|
+
f.Tuplet({
|
|
551
|
+
notes: notes.slice(0, 2),
|
|
552
|
+
options: {
|
|
553
|
+
notesOccupied: 3,
|
|
554
|
+
},
|
|
555
|
+
});
|
|
556
|
+
f.Tuplet({
|
|
557
|
+
notes: notes.slice(2, 4),
|
|
558
|
+
options: {
|
|
559
|
+
notesOccupied: 3,
|
|
560
|
+
},
|
|
561
|
+
});
|
|
562
|
+
f.Tuplet({
|
|
563
|
+
notes: notes.slice(4, 6),
|
|
564
|
+
options: {
|
|
565
|
+
notesOccupied: 3,
|
|
566
|
+
},
|
|
567
|
+
});
|
|
568
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
569
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
570
|
+
f.draw();
|
|
571
|
+
options.assert.ok(true, 'Mixed Stem Direction Bottom Tuplet');
|
|
572
|
+
}
|
|
573
|
+
function nested(options) {
|
|
574
|
+
const f = VexFlowTests.makeFactory(options);
|
|
575
|
+
const stave = f.Stave({ x: 10, y: 10 }).addTimeSignature('4/4');
|
|
576
|
+
const notes = [
|
|
577
|
+
{ keys: ['b/4'], duration: '4' },
|
|
578
|
+
{ keys: ['a/4'], duration: '4' },
|
|
579
|
+
{ keys: ['g/4'], duration: '16' },
|
|
580
|
+
{ keys: ['a/4'], duration: '16' },
|
|
581
|
+
{ keys: ['f/4'], duration: '16' },
|
|
582
|
+
{ keys: ['a/4'], duration: '16' },
|
|
583
|
+
{ keys: ['g/4'], duration: '16' },
|
|
584
|
+
{ keys: ['b/4'], duration: '2' },
|
|
585
|
+
]
|
|
586
|
+
.map(setStemUp)
|
|
587
|
+
.map(f.StaveNote.bind(f));
|
|
588
|
+
f.Beam({
|
|
589
|
+
notes: notes.slice(2, 7),
|
|
590
|
+
});
|
|
591
|
+
f.Tuplet({
|
|
592
|
+
notes: notes.slice(2, 7),
|
|
593
|
+
options: {
|
|
594
|
+
notesOccupied: 4,
|
|
595
|
+
numNotes: 5,
|
|
596
|
+
},
|
|
597
|
+
});
|
|
598
|
+
f.Tuplet({
|
|
599
|
+
notes: notes.slice(0, 7),
|
|
600
|
+
options: {
|
|
601
|
+
notesOccupied: 2,
|
|
602
|
+
numNotes: 3,
|
|
603
|
+
},
|
|
604
|
+
});
|
|
605
|
+
const voice = f.Voice().setStrict(true).addTickables(notes);
|
|
606
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
607
|
+
f.draw();
|
|
608
|
+
options.assert.ok(true, 'Nested Tuplets');
|
|
609
|
+
}
|
|
610
|
+
function nestedChildren(options) {
|
|
611
|
+
const f = VexFlowTests.makeFactory(options);
|
|
612
|
+
const stave = f.Stave({ x: 10, y: 10 }).addTimeSignature('4/4');
|
|
613
|
+
const notes = [
|
|
614
|
+
{ keys: ['b/4'], duration: '4' },
|
|
615
|
+
{ keys: ['a/4'], duration: '4' },
|
|
616
|
+
{ keys: ['c/4'], duration: '4' },
|
|
617
|
+
{ keys: ['g/4'], duration: '8' },
|
|
618
|
+
{ keys: ['a/4'], duration: '8' },
|
|
619
|
+
{ keys: ['f/4'], duration: '8' },
|
|
620
|
+
]
|
|
621
|
+
.map(setStemUp)
|
|
622
|
+
.map(f.StaveNote.bind(f));
|
|
623
|
+
f.Beam({
|
|
624
|
+
notes: notes.slice(3),
|
|
625
|
+
});
|
|
626
|
+
f.Tuplet({
|
|
627
|
+
notes: notes.slice(0, 3),
|
|
628
|
+
options: {
|
|
629
|
+
notesOccupied: 2,
|
|
630
|
+
numNotes: 3,
|
|
631
|
+
},
|
|
632
|
+
});
|
|
633
|
+
f.Tuplet({
|
|
634
|
+
notes: notes.slice(3),
|
|
635
|
+
options: {
|
|
636
|
+
notesOccupied: 2,
|
|
637
|
+
numNotes: 3,
|
|
638
|
+
},
|
|
639
|
+
});
|
|
640
|
+
f.Tuplet({
|
|
641
|
+
notes: notes.slice(),
|
|
642
|
+
options: {
|
|
643
|
+
notesOccupied: 4,
|
|
644
|
+
numNotes: 3,
|
|
645
|
+
},
|
|
646
|
+
});
|
|
647
|
+
const voice = f.Voice().setStrict(true).addTickables(notes);
|
|
648
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
649
|
+
f.draw();
|
|
650
|
+
options.assert.ok(true, 'Nested Tuplets Only Tuplet Children');
|
|
651
|
+
}
|
|
652
|
+
function single(options) {
|
|
653
|
+
const f = VexFlowTests.makeFactory(options);
|
|
654
|
+
const stave = f.Stave({ x: 10, y: 10 }).addTimeSignature('4/4');
|
|
655
|
+
const notes = [
|
|
656
|
+
{ keys: ['c/4'], duration: '4' },
|
|
657
|
+
{ keys: ['d/4'], duration: '8' },
|
|
658
|
+
{ keys: ['e/4'], duration: '8' },
|
|
659
|
+
{ keys: ['f/4'], duration: '8' },
|
|
660
|
+
{ keys: ['g/4'], duration: '8' },
|
|
661
|
+
{ keys: ['a/4'], duration: '2' },
|
|
662
|
+
{ keys: ['b/4'], duration: '4' },
|
|
663
|
+
]
|
|
664
|
+
.map(setStemUp)
|
|
665
|
+
.map(f.StaveNote.bind(f));
|
|
666
|
+
f.Beam({
|
|
667
|
+
notes: notes.slice(1, 4),
|
|
668
|
+
});
|
|
669
|
+
f.Tuplet({
|
|
670
|
+
notes: notes.slice(0, 1),
|
|
671
|
+
options: {
|
|
672
|
+
numNotes: 3,
|
|
673
|
+
notesOccupied: 2,
|
|
674
|
+
ratioed: true,
|
|
675
|
+
},
|
|
676
|
+
});
|
|
677
|
+
f.Tuplet({
|
|
678
|
+
notes: notes.slice(1, 4),
|
|
679
|
+
options: {
|
|
680
|
+
numNotes: 3,
|
|
681
|
+
notesOccupied: 2,
|
|
682
|
+
},
|
|
683
|
+
});
|
|
684
|
+
f.Tuplet({
|
|
685
|
+
notes: notes.slice(4, 5),
|
|
686
|
+
options: {
|
|
687
|
+
numNotes: 3,
|
|
688
|
+
notesOccupied: 2,
|
|
689
|
+
ratioed: true,
|
|
690
|
+
bracketed: true,
|
|
691
|
+
},
|
|
692
|
+
});
|
|
693
|
+
f.Tuplet({
|
|
694
|
+
notes: notes.slice(0, -1),
|
|
695
|
+
options: {
|
|
696
|
+
numNotes: 4,
|
|
697
|
+
notesOccupied: 3,
|
|
698
|
+
ratioed: true,
|
|
699
|
+
bracketed: true,
|
|
700
|
+
},
|
|
701
|
+
});
|
|
702
|
+
const voice = f
|
|
703
|
+
.Voice({ time: { numBeats: 4, beatValue: 4 } })
|
|
704
|
+
.setStrict(true)
|
|
705
|
+
.addTickables(notes);
|
|
706
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
707
|
+
f.draw();
|
|
708
|
+
options.assert.ok(true, 'Nested Tuplets');
|
|
709
|
+
}
|
|
710
|
+
VexFlowTests.register(TupletTests);
|
|
711
|
+
export { TupletTests };
|