@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,266 @@
|
|
|
1
|
+
import { VexFlow } from '../src/vexflow.js';
|
|
2
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
3
|
+
import { Beam } from '../src/beam.js';
|
|
4
|
+
import { Dot } from '../src/dot.js';
|
|
5
|
+
import { Formatter } from '../src/formatter.js';
|
|
6
|
+
import { Stave } from '../src/stave.js';
|
|
7
|
+
import { StaveNote } from '../src/stavenote.js';
|
|
8
|
+
import { Tuplet } from '../src/tuplet.js';
|
|
9
|
+
import { Voice } from '../src/voice.js';
|
|
10
|
+
const RestsTests = {
|
|
11
|
+
Start() {
|
|
12
|
+
VexFlowTests.module('Rests');
|
|
13
|
+
const run = VexFlowTests.runTests;
|
|
14
|
+
run('Outside Stave', ledgerRest);
|
|
15
|
+
run('Dotted', basic);
|
|
16
|
+
run('Auto Align - Beamed Notes Stems Up', beamsUp);
|
|
17
|
+
run('Auto Align - Beamed Notes Stems Down', beamsDown);
|
|
18
|
+
run('Auto Align - Tuplets Stems Up', tupletsUp);
|
|
19
|
+
run('Auto Align - Tuplets Stems Down', tupletsDown);
|
|
20
|
+
run('Auto Align - Single Voice (Default)', singleVoiceDefaultAlignment);
|
|
21
|
+
run('Auto Align - Single Voice (Align All)', singleVoiceAlignAll);
|
|
22
|
+
run('Auto Align - Multi Voice', multiVoice);
|
|
23
|
+
},
|
|
24
|
+
};
|
|
25
|
+
function setupContext(options, contextBuilder, width = 350, height = 150) {
|
|
26
|
+
const context = contextBuilder(options.elementId, width, height);
|
|
27
|
+
context.scale(0.9, 0.9);
|
|
28
|
+
context.font = '10pt Arial';
|
|
29
|
+
const stave = new Stave(10, 30, width).addClef('treble').addTimeSignature('4/4').setContext(context).drawWithStyle();
|
|
30
|
+
return { context, stave };
|
|
31
|
+
}
|
|
32
|
+
function basic(options, contextBuilder) {
|
|
33
|
+
const { context, stave } = setupContext(options, contextBuilder, 700);
|
|
34
|
+
const notes = [
|
|
35
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: 'mr' }),
|
|
36
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: 'lr' }),
|
|
37
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '1/2r' }),
|
|
38
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: 'wr' }),
|
|
39
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: 'hr' }),
|
|
40
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '4r' }),
|
|
41
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '8r' }),
|
|
42
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '16r' }),
|
|
43
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '32r' }),
|
|
44
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '64r' }),
|
|
45
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '128r' }),
|
|
46
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '256r' }),
|
|
47
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '512r' }),
|
|
48
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: '1024r' }),
|
|
49
|
+
];
|
|
50
|
+
Dot.buildAndAttach(notes, { all: true });
|
|
51
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
52
|
+
options.assert.ok(true, 'Dotted Rest Test');
|
|
53
|
+
}
|
|
54
|
+
function ledgerRest(options, contextBuilder) {
|
|
55
|
+
const { context, stave } = setupContext(options, contextBuilder, 700);
|
|
56
|
+
const notes = [
|
|
57
|
+
new StaveNote({ keys: ['a/5'], stemDirection: 1, duration: 'wr' }),
|
|
58
|
+
new StaveNote({ keys: ['c/6'], stemDirection: 1, duration: 'hr' }),
|
|
59
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: 'hr' }),
|
|
60
|
+
new StaveNote({ keys: ['a/3'], stemDirection: 1, duration: 'wr' }),
|
|
61
|
+
new StaveNote({ keys: ['f/3'], stemDirection: 1, duration: 'hr' }),
|
|
62
|
+
new StaveNote({ keys: ['b/4'], stemDirection: 1, duration: 'wr' }),
|
|
63
|
+
];
|
|
64
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
65
|
+
options.assert.ok(true, 'Leger/Ledger Rest Test');
|
|
66
|
+
}
|
|
67
|
+
const note = (noteStruct) => new StaveNote(noteStruct);
|
|
68
|
+
function beamsUp(options, contextBuilder) {
|
|
69
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
70
|
+
const notes = [
|
|
71
|
+
note({ keys: ['e/5'], stemDirection: 1, duration: '8' }),
|
|
72
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '8r' }),
|
|
73
|
+
note({ keys: ['b/5'], stemDirection: 1, duration: '8' }),
|
|
74
|
+
note({ keys: ['c/5'], stemDirection: 1, duration: '8' }),
|
|
75
|
+
note({ keys: ['b/4', 'd/5', 'a/5'], stemDirection: 1, duration: '8' }),
|
|
76
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '8r' }),
|
|
77
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '8r' }),
|
|
78
|
+
note({ keys: ['c/4'], stemDirection: 1, duration: '8' }),
|
|
79
|
+
note({ keys: ['b/4', 'd/5', 'a/5'], stemDirection: 1, duration: '8' }),
|
|
80
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '8' }),
|
|
81
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '8r' }),
|
|
82
|
+
note({ keys: ['c/4'], stemDirection: 1, duration: '8' }),
|
|
83
|
+
];
|
|
84
|
+
const beam1 = new Beam(notes.slice(0, 4));
|
|
85
|
+
const beam2 = new Beam(notes.slice(4, 8));
|
|
86
|
+
const beam3 = new Beam(notes.slice(8, 12));
|
|
87
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
88
|
+
beam1.setContext(context).drawWithStyle();
|
|
89
|
+
beam2.setContext(context).drawWithStyle();
|
|
90
|
+
beam3.setContext(context).drawWithStyle();
|
|
91
|
+
options.assert.ok(true, 'Auto Align Rests - Beams Up Test');
|
|
92
|
+
}
|
|
93
|
+
function beamsDown(options, contextBuilder) {
|
|
94
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
95
|
+
const notes = [
|
|
96
|
+
note({ keys: ['a/5'], stemDirection: -1, duration: '8' }),
|
|
97
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
98
|
+
note({ keys: ['b/5'], stemDirection: -1, duration: '8' }),
|
|
99
|
+
note({ keys: ['c/5'], stemDirection: -1, duration: '8' }),
|
|
100
|
+
note({ keys: ['b/4', 'd/5', 'a/5'], stemDirection: -1, duration: '8' }),
|
|
101
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
102
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
103
|
+
note({ keys: ['e/4'], stemDirection: -1, duration: '8' }),
|
|
104
|
+
note({ keys: ['b/4', 'd/5', 'a/5'], stemDirection: -1, duration: '8' }),
|
|
105
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8' }),
|
|
106
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
107
|
+
note({ keys: ['e/4'], stemDirection: -1, duration: '8' }),
|
|
108
|
+
];
|
|
109
|
+
const beam1 = new Beam(notes.slice(0, 4));
|
|
110
|
+
const beam2 = new Beam(notes.slice(4, 8));
|
|
111
|
+
const beam3 = new Beam(notes.slice(8, 12));
|
|
112
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
113
|
+
beam1.setContext(context).drawWithStyle();
|
|
114
|
+
beam2.setContext(context).drawWithStyle();
|
|
115
|
+
beam3.setContext(context).drawWithStyle();
|
|
116
|
+
options.assert.ok(true, 'Auto Align Rests - Beams Down Test');
|
|
117
|
+
}
|
|
118
|
+
function tupletsUp(options, contextBuilder) {
|
|
119
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
120
|
+
const notes = [
|
|
121
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '4' }),
|
|
122
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '4' }),
|
|
123
|
+
note({ keys: ['a/5'], stemDirection: 1, duration: '4r' }),
|
|
124
|
+
note({ keys: ['a/5'], stemDirection: 1, duration: '4r' }),
|
|
125
|
+
note({ keys: ['g/5'], stemDirection: 1, duration: '4r' }),
|
|
126
|
+
note({ keys: ['b/5'], stemDirection: 1, duration: '4' }),
|
|
127
|
+
note({ keys: ['a/5'], stemDirection: 1, duration: '4' }),
|
|
128
|
+
note({ keys: ['g/5'], stemDirection: 1, duration: '4r' }),
|
|
129
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '4' }),
|
|
130
|
+
note({ keys: ['a/5'], stemDirection: 1, duration: '4' }),
|
|
131
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '4r' }),
|
|
132
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '4r' }),
|
|
133
|
+
];
|
|
134
|
+
const tuplet1 = new Tuplet(notes.slice(0, 3)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
135
|
+
const tuplet2 = new Tuplet(notes.slice(3, 6)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
136
|
+
const tuplet3 = new Tuplet(notes.slice(6, 9)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
137
|
+
const tuplet4 = new Tuplet(notes.slice(9, 12)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
138
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
139
|
+
tuplet1.setContext(context).drawWithStyle();
|
|
140
|
+
tuplet2.setContext(context).drawWithStyle();
|
|
141
|
+
tuplet3.setContext(context).drawWithStyle();
|
|
142
|
+
tuplet4.setContext(context).drawWithStyle();
|
|
143
|
+
options.assert.ok(true, 'Auto Align Rests - Tuplets Stem Up Test');
|
|
144
|
+
}
|
|
145
|
+
function tupletsDown(options, contextBuilder) {
|
|
146
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
147
|
+
const notes = [
|
|
148
|
+
note({ keys: ['a/5'], stemDirection: -1, duration: '8r' }),
|
|
149
|
+
note({ keys: ['g/5'], stemDirection: -1, duration: '8r' }),
|
|
150
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8' }),
|
|
151
|
+
note({ keys: ['a/5'], stemDirection: -1, duration: '8r' }),
|
|
152
|
+
note({ keys: ['g/5'], stemDirection: -1, duration: '8' }),
|
|
153
|
+
note({ keys: ['b/5'], stemDirection: -1, duration: '8' }),
|
|
154
|
+
note({ keys: ['a/5'], stemDirection: -1, duration: '8' }),
|
|
155
|
+
note({ keys: ['g/5'], stemDirection: -1, duration: '8r' }),
|
|
156
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8' }),
|
|
157
|
+
note({ keys: ['a/5'], stemDirection: -1, duration: '8' }),
|
|
158
|
+
note({ keys: ['g/5'], stemDirection: -1, duration: '8r' }),
|
|
159
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
160
|
+
];
|
|
161
|
+
const beam1 = new Beam(notes.slice(0, 3));
|
|
162
|
+
const beam2 = new Beam(notes.slice(3, 6));
|
|
163
|
+
const beam3 = new Beam(notes.slice(6, 9));
|
|
164
|
+
const beam4 = new Beam(notes.slice(9, 12));
|
|
165
|
+
const tuplet1 = new Tuplet(notes.slice(0, 3)).setTupletLocation(Tuplet.LOCATION_BOTTOM);
|
|
166
|
+
const tuplet2 = new Tuplet(notes.slice(3, 6)).setTupletLocation(Tuplet.LOCATION_BOTTOM);
|
|
167
|
+
const tuplet3 = new Tuplet(notes.slice(6, 9)).setTupletLocation(Tuplet.LOCATION_BOTTOM);
|
|
168
|
+
const tuplet4 = new Tuplet(notes.slice(9, 12)).setTupletLocation(Tuplet.LOCATION_BOTTOM);
|
|
169
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
170
|
+
tuplet1.setContext(context).drawWithStyle();
|
|
171
|
+
tuplet2.setContext(context).drawWithStyle();
|
|
172
|
+
tuplet3.setContext(context).drawWithStyle();
|
|
173
|
+
tuplet4.setContext(context).drawWithStyle();
|
|
174
|
+
beam1.setContext(context).drawWithStyle();
|
|
175
|
+
beam2.setContext(context).drawWithStyle();
|
|
176
|
+
beam3.setContext(context).drawWithStyle();
|
|
177
|
+
beam4.setContext(context).drawWithStyle();
|
|
178
|
+
options.assert.ok(true, 'Auto Align Rests - Tuplets Stem Down Test');
|
|
179
|
+
}
|
|
180
|
+
function singleVoiceDefaultAlignment(options, contextBuilder) {
|
|
181
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
182
|
+
const notes = [
|
|
183
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '4r' }),
|
|
184
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '4r' }),
|
|
185
|
+
note({ keys: ['f/4'], stemDirection: -1, duration: '4' }),
|
|
186
|
+
note({ keys: ['e/5'], stemDirection: -1, duration: '8' }),
|
|
187
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
188
|
+
note({ keys: ['a/5'], stemDirection: -1, duration: '8' }),
|
|
189
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
190
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8' }),
|
|
191
|
+
note({ keys: ['e/5'], stemDirection: -1, duration: '8' }),
|
|
192
|
+
note({ keys: ['a/5'], stemDirection: 1, duration: '4' }),
|
|
193
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '4r' }),
|
|
194
|
+
note({ keys: ['b/5'], stemDirection: 1, duration: '4' }),
|
|
195
|
+
note({ keys: ['d/5'], stemDirection: -1, duration: '4' }),
|
|
196
|
+
note({ keys: ['g/5'], stemDirection: -1, duration: '4' }),
|
|
197
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '4r' }),
|
|
198
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '4r' }),
|
|
199
|
+
];
|
|
200
|
+
const beam = new Beam(notes.slice(5, 9));
|
|
201
|
+
const tuplet = new Tuplet(notes.slice(9, 12)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
202
|
+
Formatter.FormatAndDraw(context, stave, notes);
|
|
203
|
+
tuplet.setContext(context).drawWithStyle();
|
|
204
|
+
beam.setContext(context).drawWithStyle();
|
|
205
|
+
options.assert.ok(true, 'Auto Align Rests - Default Test');
|
|
206
|
+
}
|
|
207
|
+
function singleVoiceAlignAll(options, contextBuilder) {
|
|
208
|
+
const { context, stave } = setupContext(options, contextBuilder, 600, 160);
|
|
209
|
+
const notes = [
|
|
210
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '4r' }),
|
|
211
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '4r' }),
|
|
212
|
+
note({ keys: ['f/4'], stemDirection: -1, duration: '4' }),
|
|
213
|
+
note({ keys: ['e/5'], stemDirection: -1, duration: '8' }),
|
|
214
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
215
|
+
note({ keys: ['a/5'], stemDirection: -1, duration: '8' }),
|
|
216
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
217
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '8' }),
|
|
218
|
+
note({ keys: ['e/5'], stemDirection: -1, duration: '8' }),
|
|
219
|
+
note({ keys: ['a/5'], stemDirection: 1, duration: '4' }),
|
|
220
|
+
note({ keys: ['b/4'], stemDirection: 1, duration: '4r' }),
|
|
221
|
+
note({ keys: ['b/5'], stemDirection: 1, duration: '4' }),
|
|
222
|
+
note({ keys: ['d/5'], stemDirection: -1, duration: '4' }),
|
|
223
|
+
note({ keys: ['g/5'], stemDirection: -1, duration: '4' }),
|
|
224
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '4r' }),
|
|
225
|
+
note({ keys: ['b/4'], stemDirection: -1, duration: '4r' }),
|
|
226
|
+
];
|
|
227
|
+
const beam = new Beam(notes.slice(5, 9));
|
|
228
|
+
const tuplet = new Tuplet(notes.slice(9, 12)).setTupletLocation(Tuplet.LOCATION_TOP);
|
|
229
|
+
Formatter.FormatAndDraw(context, stave, notes, { alignRests: true });
|
|
230
|
+
tuplet.setContext(context).drawWithStyle();
|
|
231
|
+
beam.setContext(context).drawWithStyle();
|
|
232
|
+
options.assert.ok(true, 'Auto Align Rests - Align All Test');
|
|
233
|
+
}
|
|
234
|
+
function multiVoice(options, contextBuilder) {
|
|
235
|
+
const ctx = contextBuilder(options.elementId, 600, 200);
|
|
236
|
+
const stave = new Stave(50, 10, 500).addClef('treble').setContext(ctx).addTimeSignature('4/4').drawWithStyle();
|
|
237
|
+
const noteOnStave = (noteStruct) => new StaveNote(noteStruct).setStave(stave);
|
|
238
|
+
const notes1 = [
|
|
239
|
+
noteOnStave({ keys: ['c/4', 'e/4', 'g/4'], duration: '4' }),
|
|
240
|
+
noteOnStave({ keys: ['b/4'], duration: '4r' }),
|
|
241
|
+
noteOnStave({ keys: ['c/4', 'd/4', 'a/4'], duration: '4' }),
|
|
242
|
+
noteOnStave({ keys: ['b/4'], duration: '4r' }),
|
|
243
|
+
];
|
|
244
|
+
const notes2 = [
|
|
245
|
+
noteOnStave({ keys: ['e/3'], stemDirection: -1, duration: '8' }),
|
|
246
|
+
noteOnStave({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
247
|
+
noteOnStave({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
248
|
+
noteOnStave({ keys: ['e/3'], stemDirection: -1, duration: '8' }),
|
|
249
|
+
noteOnStave({ keys: ['e/3'], stemDirection: -1, duration: '8' }),
|
|
250
|
+
noteOnStave({ keys: ['b/4'], stemDirection: -1, duration: '8r' }),
|
|
251
|
+
noteOnStave({ keys: ['e/3'], stemDirection: -1, duration: '8' }),
|
|
252
|
+
noteOnStave({ keys: ['e/3'], stemDirection: -1, duration: '8' }),
|
|
253
|
+
];
|
|
254
|
+
const voice1 = new Voice(VexFlow.TIME4_4).addTickables(notes1);
|
|
255
|
+
const voice2 = new Voice(VexFlow.TIME4_4).addTickables(notes2);
|
|
256
|
+
new Formatter().joinVoices([voice1, voice2]).formatToStave([voice1, voice2], stave, { alignRests: true });
|
|
257
|
+
const beam2_1 = new Beam(notes2.slice(0, 4));
|
|
258
|
+
const beam2_2 = new Beam(notes2.slice(4, 8));
|
|
259
|
+
voice2.draw(ctx);
|
|
260
|
+
voice1.draw(ctx);
|
|
261
|
+
beam2_1.setContext(ctx).drawWithStyle();
|
|
262
|
+
beam2_2.setContext(ctx).drawWithStyle();
|
|
263
|
+
options.assert.ok(true, 'Strokes Test Multi Voice');
|
|
264
|
+
}
|
|
265
|
+
VexFlowTests.register(RestsTests);
|
|
266
|
+
export { RestsTests };
|
|
@@ -0,0 +1,357 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Annotation } from '../src/annotation.js';
|
|
3
|
+
import { Beam } from '../src/beam.js';
|
|
4
|
+
import { Formatter } from '../src/formatter.js';
|
|
5
|
+
import { Stave } from '../src/stave.js';
|
|
6
|
+
import { BarlineType } from '../src/stavebarline.js';
|
|
7
|
+
import { StaveNote } from '../src/stavenote.js';
|
|
8
|
+
const RhythmTests = {
|
|
9
|
+
Start() {
|
|
10
|
+
VexFlowTests.module('Rhythm');
|
|
11
|
+
const run = VexFlowTests.runTests;
|
|
12
|
+
run('Rhythm Draw - slash notes', drawBasic);
|
|
13
|
+
run('Rhythm Draw - beamed slash notes', drawBeamedSlashNotes);
|
|
14
|
+
run('Rhythm Draw - beamed slash notes, some rests', drawSlashAndBeamAndRests);
|
|
15
|
+
run('Rhythm Draw - 16th note rhythm with scratches', drawSixtenthWithScratches);
|
|
16
|
+
run('Rhythm Draw - 32nd note rhythm with scratches', drawThirtySecondWithScratches);
|
|
17
|
+
},
|
|
18
|
+
};
|
|
19
|
+
function drawBasic(options, contextBuilder) {
|
|
20
|
+
const ctx = contextBuilder(options.elementId, 800, 150);
|
|
21
|
+
const staveBar1 = new Stave(10, 30, 150);
|
|
22
|
+
staveBar1.setBegBarType(BarlineType.DOUBLE);
|
|
23
|
+
staveBar1.setEndBarType(BarlineType.SINGLE);
|
|
24
|
+
staveBar1.addClef('treble');
|
|
25
|
+
staveBar1.addTimeSignature('4/4');
|
|
26
|
+
staveBar1.addKeySignature('C');
|
|
27
|
+
staveBar1.setContext(ctx).drawWithStyle();
|
|
28
|
+
const notesBar1 = [new StaveNote({ keys: ['b/4'], duration: '1s', stemDirection: -1 })];
|
|
29
|
+
Formatter.FormatAndDraw(ctx, staveBar1, notesBar1);
|
|
30
|
+
const staveBar2 = new Stave(staveBar1.getWidth() + staveBar1.getX(), staveBar1.getY(), 120);
|
|
31
|
+
staveBar2.setBegBarType(BarlineType.SINGLE);
|
|
32
|
+
staveBar2.setEndBarType(BarlineType.SINGLE);
|
|
33
|
+
staveBar2.setContext(ctx).drawWithStyle();
|
|
34
|
+
const notesBar2 = [
|
|
35
|
+
new StaveNote({ keys: ['b/4'], duration: '2s', stemDirection: -1 }),
|
|
36
|
+
new StaveNote({ keys: ['b/4'], duration: '2s', stemDirection: -1 }),
|
|
37
|
+
];
|
|
38
|
+
Formatter.FormatAndDraw(ctx, staveBar2, notesBar2);
|
|
39
|
+
const staveBar3 = new Stave(staveBar2.getWidth() + staveBar2.getX(), staveBar2.getY(), 170);
|
|
40
|
+
staveBar3.setContext(ctx).drawWithStyle();
|
|
41
|
+
const notesBar3 = [
|
|
42
|
+
new StaveNote({
|
|
43
|
+
keys: ['b/4'],
|
|
44
|
+
duration: '4s',
|
|
45
|
+
stemDirection: -1,
|
|
46
|
+
}),
|
|
47
|
+
new StaveNote({
|
|
48
|
+
keys: ['b/4'],
|
|
49
|
+
duration: '4s',
|
|
50
|
+
stemDirection: -1,
|
|
51
|
+
}),
|
|
52
|
+
new StaveNote({
|
|
53
|
+
keys: ['b/4'],
|
|
54
|
+
duration: '4s',
|
|
55
|
+
stemDirection: -1,
|
|
56
|
+
}),
|
|
57
|
+
new StaveNote({
|
|
58
|
+
keys: ['b/4'],
|
|
59
|
+
duration: '4s',
|
|
60
|
+
stemDirection: -1,
|
|
61
|
+
}),
|
|
62
|
+
];
|
|
63
|
+
Formatter.FormatAndDraw(ctx, staveBar3, notesBar3);
|
|
64
|
+
const staveBar4 = new Stave(staveBar3.getWidth() + staveBar3.getX(), staveBar3.getY(), 200);
|
|
65
|
+
staveBar4.setContext(ctx).drawWithStyle();
|
|
66
|
+
const notesBar4 = [
|
|
67
|
+
new StaveNote({
|
|
68
|
+
keys: ['b/4'],
|
|
69
|
+
duration: '8s',
|
|
70
|
+
stemDirection: -1,
|
|
71
|
+
}),
|
|
72
|
+
new StaveNote({
|
|
73
|
+
keys: ['b/4'],
|
|
74
|
+
duration: '8s',
|
|
75
|
+
stemDirection: -1,
|
|
76
|
+
}),
|
|
77
|
+
new StaveNote({
|
|
78
|
+
keys: ['b/4'],
|
|
79
|
+
duration: '8s',
|
|
80
|
+
stemDirection: -1,
|
|
81
|
+
}),
|
|
82
|
+
new StaveNote({
|
|
83
|
+
keys: ['b/4'],
|
|
84
|
+
duration: '8s',
|
|
85
|
+
stemDirection: -1,
|
|
86
|
+
}),
|
|
87
|
+
new StaveNote({
|
|
88
|
+
keys: ['b/4'],
|
|
89
|
+
duration: '8s',
|
|
90
|
+
stemDirection: -1,
|
|
91
|
+
}),
|
|
92
|
+
new StaveNote({
|
|
93
|
+
keys: ['b/4'],
|
|
94
|
+
duration: '8s',
|
|
95
|
+
stemDirection: -1,
|
|
96
|
+
}),
|
|
97
|
+
new StaveNote({
|
|
98
|
+
keys: ['b/4'],
|
|
99
|
+
duration: '8s',
|
|
100
|
+
stemDirection: -1,
|
|
101
|
+
}),
|
|
102
|
+
new StaveNote({
|
|
103
|
+
keys: ['b/4'],
|
|
104
|
+
duration: '8s',
|
|
105
|
+
stemDirection: -1,
|
|
106
|
+
}),
|
|
107
|
+
];
|
|
108
|
+
Formatter.FormatAndDraw(ctx, staveBar4, notesBar4);
|
|
109
|
+
options.assert.expect(0);
|
|
110
|
+
}
|
|
111
|
+
function drawBeamedSlashNotes(options, contextBuilder) {
|
|
112
|
+
const ctx = contextBuilder(options.elementId, 800, 150);
|
|
113
|
+
const staveBar1 = new Stave(10, 30, 300);
|
|
114
|
+
staveBar1.setBegBarType(BarlineType.DOUBLE);
|
|
115
|
+
staveBar1.setEndBarType(BarlineType.SINGLE);
|
|
116
|
+
staveBar1.addClef('treble');
|
|
117
|
+
staveBar1.addTimeSignature('4/4');
|
|
118
|
+
staveBar1.addKeySignature('C');
|
|
119
|
+
staveBar1.setContext(ctx).drawWithStyle();
|
|
120
|
+
const notesBar1Part1 = [
|
|
121
|
+
new StaveNote({
|
|
122
|
+
keys: ['b/4'],
|
|
123
|
+
duration: '8s',
|
|
124
|
+
stemDirection: -1,
|
|
125
|
+
}),
|
|
126
|
+
new StaveNote({
|
|
127
|
+
keys: ['b/4'],
|
|
128
|
+
duration: '8s',
|
|
129
|
+
stemDirection: -1,
|
|
130
|
+
}),
|
|
131
|
+
new StaveNote({
|
|
132
|
+
keys: ['b/4'],
|
|
133
|
+
duration: '8s',
|
|
134
|
+
stemDirection: -1,
|
|
135
|
+
}),
|
|
136
|
+
new StaveNote({
|
|
137
|
+
keys: ['b/4'],
|
|
138
|
+
duration: '8s',
|
|
139
|
+
stemDirection: -1,
|
|
140
|
+
}),
|
|
141
|
+
];
|
|
142
|
+
const notesBar1Part2 = [
|
|
143
|
+
new StaveNote({
|
|
144
|
+
keys: ['b/4'],
|
|
145
|
+
duration: '8s',
|
|
146
|
+
stemDirection: -1,
|
|
147
|
+
}),
|
|
148
|
+
new StaveNote({
|
|
149
|
+
keys: ['b/4'],
|
|
150
|
+
duration: '8s',
|
|
151
|
+
stemDirection: -1,
|
|
152
|
+
}),
|
|
153
|
+
new StaveNote({
|
|
154
|
+
keys: ['b/4'],
|
|
155
|
+
duration: '8s',
|
|
156
|
+
stemDirection: -1,
|
|
157
|
+
}),
|
|
158
|
+
new StaveNote({
|
|
159
|
+
keys: ['b/4'],
|
|
160
|
+
duration: '8s',
|
|
161
|
+
stemDirection: -1,
|
|
162
|
+
}),
|
|
163
|
+
];
|
|
164
|
+
const beam1 = new Beam(notesBar1Part1);
|
|
165
|
+
const beam2 = new Beam(notesBar1Part2);
|
|
166
|
+
const notesBar1 = notesBar1Part1.concat(notesBar1Part2);
|
|
167
|
+
Formatter.FormatAndDraw(ctx, staveBar1, notesBar1);
|
|
168
|
+
beam1.setContext(ctx).drawWithStyle();
|
|
169
|
+
beam2.setContext(ctx).drawWithStyle();
|
|
170
|
+
options.assert.expect(0);
|
|
171
|
+
}
|
|
172
|
+
function drawSlashAndBeamAndRests(options, contextBuilder) {
|
|
173
|
+
const ctx = contextBuilder(options.elementId, 800, 150);
|
|
174
|
+
const staveBar1 = new Stave(10, 30, 300);
|
|
175
|
+
staveBar1.setBegBarType(BarlineType.DOUBLE);
|
|
176
|
+
staveBar1.setEndBarType(BarlineType.SINGLE);
|
|
177
|
+
staveBar1.addClef('treble');
|
|
178
|
+
staveBar1.addTimeSignature('4/4');
|
|
179
|
+
staveBar1.addKeySignature('F');
|
|
180
|
+
staveBar1.setContext(ctx).drawWithStyle();
|
|
181
|
+
const notesBar1Part1 = [
|
|
182
|
+
new StaveNote({
|
|
183
|
+
keys: ['b/4'],
|
|
184
|
+
duration: '8s',
|
|
185
|
+
stemDirection: -1,
|
|
186
|
+
}),
|
|
187
|
+
new StaveNote({ keys: ['b/4'], duration: '8s', stemDirection: -1 }),
|
|
188
|
+
];
|
|
189
|
+
notesBar1Part1[0].addModifier(new Annotation('C7').setFont('Times', VexFlowTests.Font.size + 2), 0);
|
|
190
|
+
const notesBar1Part2 = [
|
|
191
|
+
new StaveNote({
|
|
192
|
+
keys: ['b/4'],
|
|
193
|
+
duration: '8r',
|
|
194
|
+
stemDirection: -1,
|
|
195
|
+
}),
|
|
196
|
+
new StaveNote({
|
|
197
|
+
keys: ['b/4'],
|
|
198
|
+
duration: '8s',
|
|
199
|
+
stemDirection: -1,
|
|
200
|
+
}),
|
|
201
|
+
new StaveNote({
|
|
202
|
+
keys: ['b/4'],
|
|
203
|
+
duration: '8r',
|
|
204
|
+
stemDirection: -1,
|
|
205
|
+
}),
|
|
206
|
+
new StaveNote({
|
|
207
|
+
keys: ['b/4'],
|
|
208
|
+
duration: '8s',
|
|
209
|
+
stemDirection: -1,
|
|
210
|
+
}),
|
|
211
|
+
new StaveNote({
|
|
212
|
+
keys: ['b/4'],
|
|
213
|
+
duration: '8r',
|
|
214
|
+
stemDirection: -1,
|
|
215
|
+
}),
|
|
216
|
+
new StaveNote({
|
|
217
|
+
keys: ['b/4'],
|
|
218
|
+
duration: '8s',
|
|
219
|
+
stemDirection: -1,
|
|
220
|
+
}),
|
|
221
|
+
];
|
|
222
|
+
const beam1 = new Beam(notesBar1Part1);
|
|
223
|
+
Formatter.FormatAndDraw(ctx, staveBar1, notesBar1Part1.concat(notesBar1Part2));
|
|
224
|
+
beam1.setContext(ctx).drawWithStyle();
|
|
225
|
+
const staveBar2 = new Stave(staveBar1.getWidth() + staveBar1.getX(), staveBar1.getY(), 220);
|
|
226
|
+
staveBar2.setContext(ctx).drawWithStyle();
|
|
227
|
+
const notesBar2 = [
|
|
228
|
+
new StaveNote({
|
|
229
|
+
keys: ['b/4'],
|
|
230
|
+
duration: '1s',
|
|
231
|
+
stemDirection: -1,
|
|
232
|
+
}),
|
|
233
|
+
];
|
|
234
|
+
notesBar2[0].addModifier(new Annotation('F').setFont('Times', VexFlowTests.Font.size + 2), 0);
|
|
235
|
+
Formatter.FormatAndDraw(ctx, staveBar2, notesBar2);
|
|
236
|
+
options.assert.expect(0);
|
|
237
|
+
}
|
|
238
|
+
function drawSixtenthWithScratches(options, contextBuilder) {
|
|
239
|
+
const ctx = contextBuilder(options.elementId, 800, 150);
|
|
240
|
+
const staveBar1 = new Stave(10, 30, 300);
|
|
241
|
+
staveBar1.setBegBarType(BarlineType.DOUBLE);
|
|
242
|
+
staveBar1.setEndBarType(BarlineType.SINGLE);
|
|
243
|
+
staveBar1.addClef('treble');
|
|
244
|
+
staveBar1.addTimeSignature('4/4');
|
|
245
|
+
staveBar1.addKeySignature('F');
|
|
246
|
+
staveBar1.setContext(ctx).drawWithStyle();
|
|
247
|
+
const notesBar1Part1 = [
|
|
248
|
+
new StaveNote({
|
|
249
|
+
keys: ['b/4'],
|
|
250
|
+
duration: '16s',
|
|
251
|
+
stemDirection: -1,
|
|
252
|
+
}),
|
|
253
|
+
new StaveNote({
|
|
254
|
+
keys: ['b/4'],
|
|
255
|
+
duration: '16s',
|
|
256
|
+
stemDirection: -1,
|
|
257
|
+
}),
|
|
258
|
+
new StaveNote({
|
|
259
|
+
keys: ['b/4'],
|
|
260
|
+
duration: '16m',
|
|
261
|
+
stemDirection: -1,
|
|
262
|
+
}),
|
|
263
|
+
new StaveNote({
|
|
264
|
+
keys: ['b/4'],
|
|
265
|
+
duration: '16s',
|
|
266
|
+
stemDirection: -1,
|
|
267
|
+
}),
|
|
268
|
+
];
|
|
269
|
+
const notesBar1Part2 = [
|
|
270
|
+
new StaveNote({
|
|
271
|
+
keys: ['b/4'],
|
|
272
|
+
duration: '16m',
|
|
273
|
+
stemDirection: -1,
|
|
274
|
+
}),
|
|
275
|
+
new StaveNote({
|
|
276
|
+
keys: ['b/4'],
|
|
277
|
+
duration: '16s',
|
|
278
|
+
stemDirection: -1,
|
|
279
|
+
}),
|
|
280
|
+
new StaveNote({
|
|
281
|
+
keys: ['b/4'],
|
|
282
|
+
duration: '16r',
|
|
283
|
+
stemDirection: -1,
|
|
284
|
+
}),
|
|
285
|
+
new StaveNote({
|
|
286
|
+
keys: ['b/4'],
|
|
287
|
+
duration: '16s',
|
|
288
|
+
stemDirection: -1,
|
|
289
|
+
}),
|
|
290
|
+
];
|
|
291
|
+
notesBar1Part1[0].addModifier(new Annotation('C7').setFont('Times', VexFlowTests.Font.size + 3), 0);
|
|
292
|
+
const beam1 = new Beam(notesBar1Part1);
|
|
293
|
+
const beam2 = new Beam(notesBar1Part2);
|
|
294
|
+
Formatter.FormatAndDraw(ctx, staveBar1, notesBar1Part1.concat(notesBar1Part2));
|
|
295
|
+
beam1.setContext(ctx).drawWithStyle();
|
|
296
|
+
beam2.setContext(ctx).drawWithStyle();
|
|
297
|
+
options.assert.expect(0);
|
|
298
|
+
}
|
|
299
|
+
function drawThirtySecondWithScratches(options, contextBuilder) {
|
|
300
|
+
const ctx = contextBuilder(options.elementId, 800, 150);
|
|
301
|
+
const staveBar1 = new Stave(10, 30, 300);
|
|
302
|
+
staveBar1.setBegBarType(BarlineType.DOUBLE);
|
|
303
|
+
staveBar1.setEndBarType(BarlineType.SINGLE);
|
|
304
|
+
staveBar1.addClef('treble');
|
|
305
|
+
staveBar1.addTimeSignature('4/4');
|
|
306
|
+
staveBar1.addKeySignature('F');
|
|
307
|
+
staveBar1.setContext(ctx).drawWithStyle();
|
|
308
|
+
const notesBar1Part1 = [
|
|
309
|
+
new StaveNote({
|
|
310
|
+
keys: ['b/4'],
|
|
311
|
+
duration: '32s',
|
|
312
|
+
stemDirection: 1,
|
|
313
|
+
}),
|
|
314
|
+
new StaveNote({
|
|
315
|
+
keys: ['b/4'],
|
|
316
|
+
duration: '32s',
|
|
317
|
+
stemDirection: 1,
|
|
318
|
+
}),
|
|
319
|
+
new StaveNote({
|
|
320
|
+
keys: ['b/4'],
|
|
321
|
+
duration: '32m',
|
|
322
|
+
stemDirection: 1,
|
|
323
|
+
}),
|
|
324
|
+
new StaveNote({
|
|
325
|
+
keys: ['b/4'],
|
|
326
|
+
duration: '32s',
|
|
327
|
+
stemDirection: 1,
|
|
328
|
+
}),
|
|
329
|
+
new StaveNote({
|
|
330
|
+
keys: ['b/4'],
|
|
331
|
+
duration: '32m',
|
|
332
|
+
stemDirection: 1,
|
|
333
|
+
}),
|
|
334
|
+
new StaveNote({
|
|
335
|
+
keys: ['b/4'],
|
|
336
|
+
duration: '32s',
|
|
337
|
+
stemDirection: 1,
|
|
338
|
+
}),
|
|
339
|
+
new StaveNote({
|
|
340
|
+
keys: ['b/4'],
|
|
341
|
+
duration: '32r',
|
|
342
|
+
stemDirection: 1,
|
|
343
|
+
}),
|
|
344
|
+
new StaveNote({
|
|
345
|
+
keys: ['b/4'],
|
|
346
|
+
duration: '32s',
|
|
347
|
+
stemDirection: 1,
|
|
348
|
+
}),
|
|
349
|
+
];
|
|
350
|
+
notesBar1Part1[0].addModifier(new Annotation('C7').setFont('Times', VexFlowTests.Font.size + 3), 0);
|
|
351
|
+
const beam1 = new Beam(notesBar1Part1);
|
|
352
|
+
Formatter.FormatAndDraw(ctx, staveBar1, notesBar1Part1);
|
|
353
|
+
beam1.setContext(ctx).drawWithStyle();
|
|
354
|
+
options.assert.expect(0);
|
|
355
|
+
}
|
|
356
|
+
VexFlowTests.register(RhythmTests);
|
|
357
|
+
export { RhythmTests };
|