@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,414 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { ModifierPosition } from '../src.js';
|
|
3
|
+
import { Accidental } from '../src/accidental.js';
|
|
4
|
+
import { Annotation } from '../src/annotation.js';
|
|
5
|
+
import { Articulation } from '../src/articulation.js';
|
|
6
|
+
import { Dot } from '../src/dot.js';
|
|
7
|
+
import { Formatter } from '../src/formatter.js';
|
|
8
|
+
const GraceNoteTests = {
|
|
9
|
+
Start() {
|
|
10
|
+
VexFlowTests.module('Grace Notes');
|
|
11
|
+
const run = VexFlowTests.runTests;
|
|
12
|
+
run('Grace Note Basic', basic);
|
|
13
|
+
run('With Articulation and Annotation on Parent Note', graceNoteModifiers);
|
|
14
|
+
run('Grace Note Basic with Slurs', basicSlurred);
|
|
15
|
+
run('Grace Note Stem', stem);
|
|
16
|
+
run('Grace Note Stem with Beams 1', stemWithBeamed, {
|
|
17
|
+
keys1: ['g/4'],
|
|
18
|
+
stemDirection1: 1,
|
|
19
|
+
keys2: ['d/5'],
|
|
20
|
+
stemDirection2: -1,
|
|
21
|
+
});
|
|
22
|
+
run('Grace Note Stem with Beams 2', stemWithBeamed, {
|
|
23
|
+
keys1: ['a/3'],
|
|
24
|
+
stemDirection1: 1,
|
|
25
|
+
keys2: ['a/5'],
|
|
26
|
+
stemDirection2: -1,
|
|
27
|
+
});
|
|
28
|
+
run('Grace Note Stem with Beams 3', stemWithBeamed, {
|
|
29
|
+
keys1: ['c/4'],
|
|
30
|
+
stemDirection1: 1,
|
|
31
|
+
keys2: ['c/6'],
|
|
32
|
+
stemDirection2: -1,
|
|
33
|
+
});
|
|
34
|
+
run('Grace Note Slash', slash);
|
|
35
|
+
run('Grace Note Slash with Beams', slashWithBeams);
|
|
36
|
+
run('Grace Notes Multiple Voices', multipleVoices);
|
|
37
|
+
run('Grace Notes Multiple Voices Multiple Draws', multipleVoicesMultipleDraws);
|
|
38
|
+
},
|
|
39
|
+
};
|
|
40
|
+
function basic(options) {
|
|
41
|
+
const f = VexFlowTests.makeFactory(options, 700, 130);
|
|
42
|
+
const stave = f.Stave({ x: 10, y: 10, width: 650 });
|
|
43
|
+
const gracenotes = [
|
|
44
|
+
{ keys: ['e/4'], duration: '32' },
|
|
45
|
+
{ keys: ['f/4'], duration: '32' },
|
|
46
|
+
{ keys: ['g/4'], duration: '32' },
|
|
47
|
+
{ keys: ['a/4'], duration: '32' },
|
|
48
|
+
].map(f.GraceNote.bind(f));
|
|
49
|
+
const gracenotes1 = [{ keys: ['b/4'], duration: '8', slash: false }].map(f.GraceNote.bind(f));
|
|
50
|
+
const gracenotes2 = [{ keys: ['b/4'], duration: '8', slash: true }].map(f.GraceNote.bind(f));
|
|
51
|
+
const gracenotes3 = [
|
|
52
|
+
{ keys: ['e/4'], duration: '8' },
|
|
53
|
+
{ keys: ['f/4'], duration: '16' },
|
|
54
|
+
{ keys: ['e/4', 'g/4'], duration: '8' },
|
|
55
|
+
{ keys: ['a/4'], duration: '32' },
|
|
56
|
+
{ keys: ['b/4'], duration: '32' },
|
|
57
|
+
].map(f.GraceNote.bind(f));
|
|
58
|
+
const gracenotes4 = [
|
|
59
|
+
{ keys: ['g/4'], duration: '8' },
|
|
60
|
+
{ keys: ['g/4'], duration: '16' },
|
|
61
|
+
{ keys: ['g/4'], duration: '16' },
|
|
62
|
+
].map(f.GraceNote.bind(f));
|
|
63
|
+
gracenotes[1].addModifier(f.Accidental({ type: '##' }), 0);
|
|
64
|
+
gracenotes3[3].addModifier(f.Accidental({ type: 'bb' }), 0);
|
|
65
|
+
Dot.buildAndAttach([gracenotes4[0]], { all: true });
|
|
66
|
+
const notes = [
|
|
67
|
+
f
|
|
68
|
+
.StaveNote({ keys: ['b/4'], duration: '4', autoStem: true })
|
|
69
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }).beamNotes(), 0),
|
|
70
|
+
f
|
|
71
|
+
.StaveNote({ keys: ['c/5'], duration: '4', autoStem: true })
|
|
72
|
+
.addModifier(f.Accidental({ type: '#' }), 0)
|
|
73
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes1 }).beamNotes(), 0),
|
|
74
|
+
f
|
|
75
|
+
.StaveNote({ keys: ['c/5', 'd/5'], duration: '4', autoStem: true })
|
|
76
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes2 }).beamNotes(), 0),
|
|
77
|
+
f
|
|
78
|
+
.StaveNote({ keys: ['a/4'], duration: '4', autoStem: true })
|
|
79
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes3 }).beamNotes(), 0),
|
|
80
|
+
f
|
|
81
|
+
.StaveNote({ keys: ['a/4'], duration: '4', autoStem: true })
|
|
82
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes4 }).beamNotes().setPosition(ModifierPosition.RIGHT), 0),
|
|
83
|
+
];
|
|
84
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
85
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
86
|
+
f.draw();
|
|
87
|
+
options.assert.ok(true, 'GraceNoteBasic');
|
|
88
|
+
}
|
|
89
|
+
function graceNoteModifiers(options) {
|
|
90
|
+
const f = VexFlowTests.makeFactory(options, 700, 130);
|
|
91
|
+
const stave = f.Stave({ x: 10, y: 10, width: 650 });
|
|
92
|
+
const gracenotes = [{ keys: ['b/4'], duration: '8', slash: false }].map(f.GraceNote.bind(f));
|
|
93
|
+
const notes = [
|
|
94
|
+
f
|
|
95
|
+
.StaveNote({ keys: ['c/5'], duration: '4', autoStem: true })
|
|
96
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0),
|
|
97
|
+
f
|
|
98
|
+
.StaveNote({ keys: ['c/5'], duration: '4', autoStem: true })
|
|
99
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
100
|
+
.addModifier(new Articulation('a-').setPosition(3), 0),
|
|
101
|
+
f
|
|
102
|
+
.StaveNote({ keys: ['c/5'], duration: '4', autoStem: true })
|
|
103
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
104
|
+
.addModifier(new Articulation('a-').setPosition(3), 0)
|
|
105
|
+
.addModifier(new Accidental('#')),
|
|
106
|
+
f
|
|
107
|
+
.StaveNote({ keys: ['c/5'], duration: '4', autoStem: true })
|
|
108
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
109
|
+
.addModifier(new Articulation('a-').setPosition(3), 0)
|
|
110
|
+
.addModifier(new Annotation('words')),
|
|
111
|
+
f
|
|
112
|
+
.StaveNote({ keys: ['c/5'], duration: '4', autoStem: true })
|
|
113
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
114
|
+
.addModifier(new Articulation('a-').setPosition(3), 0)
|
|
115
|
+
.addModifier(new Articulation('a>').setPosition(3), 0),
|
|
116
|
+
f
|
|
117
|
+
.StaveNote({ keys: ['c/5'], duration: '4', autoStem: true })
|
|
118
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0)
|
|
119
|
+
.addModifier(new Articulation('a-').setPosition(3), 0)
|
|
120
|
+
.addModifier(new Articulation('a>').setPosition(3), 0)
|
|
121
|
+
.addModifier(new Articulation('a@a').setPosition(3), 0),
|
|
122
|
+
];
|
|
123
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
124
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
125
|
+
f.draw();
|
|
126
|
+
options.assert.ok(true, 'GraceNoteModifiers');
|
|
127
|
+
}
|
|
128
|
+
function basicSlurred(options) {
|
|
129
|
+
const f = VexFlowTests.makeFactory(options, 700, 130);
|
|
130
|
+
const stave = f.Stave({ x: 10, y: 10, width: 650 });
|
|
131
|
+
const gracenotes0 = [
|
|
132
|
+
{ keys: ['e/4'], duration: '32' },
|
|
133
|
+
{ keys: ['f/4'], duration: '32' },
|
|
134
|
+
{ keys: ['g/4'], duration: '32' },
|
|
135
|
+
{ keys: ['a/4'], duration: '32' },
|
|
136
|
+
].map(f.GraceNote.bind(f));
|
|
137
|
+
const gracenotes1 = [{ keys: ['b/4'], duration: '8', slash: false }].map(f.GraceNote.bind(f));
|
|
138
|
+
const gracenotes2 = [{ keys: ['b/4'], duration: '8', slash: true }].map(f.GraceNote.bind(f));
|
|
139
|
+
const gracenotes3 = [
|
|
140
|
+
{ keys: ['e/4'], duration: '8' },
|
|
141
|
+
{ keys: ['f/4'], duration: '16' },
|
|
142
|
+
{ keys: ['e/4', 'g/4'], duration: '8' },
|
|
143
|
+
{ keys: ['a/4'], duration: '32' },
|
|
144
|
+
{ keys: ['b/4'], duration: '32' },
|
|
145
|
+
].map(f.GraceNote.bind(f));
|
|
146
|
+
const gracenotes4 = [
|
|
147
|
+
{ keys: ['a/4'], duration: '8' },
|
|
148
|
+
{ keys: ['a/4'], duration: '16' },
|
|
149
|
+
{ keys: ['a/4'], duration: '16' },
|
|
150
|
+
].map(f.GraceNote.bind(f));
|
|
151
|
+
gracenotes0[1].addModifier(f.Accidental({ type: '#' }), 0);
|
|
152
|
+
gracenotes3[3].addModifier(f.Accidental({ type: 'b' }), 0);
|
|
153
|
+
gracenotes3[2].addModifier(f.Accidental({ type: 'n' }), 0);
|
|
154
|
+
Dot.buildAndAttach([gracenotes4[0]], { all: true });
|
|
155
|
+
const notes = [
|
|
156
|
+
f
|
|
157
|
+
.StaveNote({ keys: ['b/4'], duration: '4', autoStem: true })
|
|
158
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes0, slur: true }).beamNotes(), 0),
|
|
159
|
+
f
|
|
160
|
+
.StaveNote({ keys: ['c/5'], duration: '4', autoStem: true })
|
|
161
|
+
.addModifier(f.Accidental({ type: '#' }), 0)
|
|
162
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes1, slur: true }).beamNotes(), 0),
|
|
163
|
+
f
|
|
164
|
+
.StaveNote({ keys: ['c/5', 'd/5'], duration: '4', autoStem: true })
|
|
165
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes2, slur: true }).beamNotes(), 0),
|
|
166
|
+
f
|
|
167
|
+
.StaveNote({ keys: ['a/4'], duration: '4', autoStem: true })
|
|
168
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes3, slur: true }).beamNotes(), 0),
|
|
169
|
+
f
|
|
170
|
+
.StaveNote({ keys: ['a/4'], duration: '4', autoStem: true })
|
|
171
|
+
.addModifier(f.GraceNoteGroup({ notes: gracenotes4, slur: true }).beamNotes(), 0),
|
|
172
|
+
f.StaveNote({ keys: ['a/4'], duration: '4', autoStem: true }),
|
|
173
|
+
];
|
|
174
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
175
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
176
|
+
f.draw();
|
|
177
|
+
options.assert.ok(true, 'GraceNoteBasic');
|
|
178
|
+
}
|
|
179
|
+
const createNoteForStemTest = (duration, noteBuilder, keys, stemDirection, slash = false) => {
|
|
180
|
+
const struct = { duration, slash };
|
|
181
|
+
struct.stemDirection = stemDirection;
|
|
182
|
+
struct.keys = keys;
|
|
183
|
+
return noteBuilder(struct);
|
|
184
|
+
};
|
|
185
|
+
const durationsForStemTest = ['8', '16', '32', '64', '128'];
|
|
186
|
+
function stem(options) {
|
|
187
|
+
const f = VexFlowTests.makeFactory(options, 700, 130);
|
|
188
|
+
const stave = f.Stave({ x: 10, y: 10, width: 650 });
|
|
189
|
+
function createNotes(noteBuilder, keys, stemDirection) {
|
|
190
|
+
return durationsForStemTest.map((duration) => createNoteForStemTest(duration, noteBuilder, keys, stemDirection));
|
|
191
|
+
}
|
|
192
|
+
function createNoteBlock(keys, stemDirection) {
|
|
193
|
+
const staveNotes = createNotes(f.StaveNote.bind(f), keys, stemDirection);
|
|
194
|
+
const gracenotes = createNotes(f.GraceNote.bind(f), keys, stemDirection);
|
|
195
|
+
staveNotes[0].addModifier(f.GraceNoteGroup({ notes: gracenotes }), 0);
|
|
196
|
+
return staveNotes;
|
|
197
|
+
}
|
|
198
|
+
const voice = f.Voice().setStrict(false);
|
|
199
|
+
voice.addTickables(createNoteBlock(['g/4'], 1));
|
|
200
|
+
voice.addTickables(createNoteBlock(['d/5'], -1));
|
|
201
|
+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
202
|
+
f.draw();
|
|
203
|
+
options.assert.ok(true, 'GraceNoteStem');
|
|
204
|
+
}
|
|
205
|
+
function stemWithBeamed(options) {
|
|
206
|
+
const f = VexFlowTests.makeFactory(options, 700, 130);
|
|
207
|
+
const stave = f.Stave({ x: 10, y: 10, width: 650 });
|
|
208
|
+
function createBeamedNotes(noteBuilder, keys, stemDirection, beams, isGrace = false, notesToBeam) {
|
|
209
|
+
const ret = [];
|
|
210
|
+
durationsForStemTest.map((duration) => {
|
|
211
|
+
const n0 = createNoteForStemTest(duration, noteBuilder, keys, stemDirection);
|
|
212
|
+
const n1 = createNoteForStemTest(duration, noteBuilder, keys, stemDirection);
|
|
213
|
+
ret.push(n0);
|
|
214
|
+
ret.push(n1);
|
|
215
|
+
if (notesToBeam) {
|
|
216
|
+
notesToBeam.push([n0, n1]);
|
|
217
|
+
}
|
|
218
|
+
if (!isGrace) {
|
|
219
|
+
beams.push(f.Beam({ notes: [n0, n1] }));
|
|
220
|
+
}
|
|
221
|
+
});
|
|
222
|
+
return ret;
|
|
223
|
+
}
|
|
224
|
+
function createBeamedNoteBlock(keys, stemDirection, beams) {
|
|
225
|
+
const bnotes = createBeamedNotes(f.StaveNote.bind(f), keys, stemDirection, beams);
|
|
226
|
+
const notesToBeam = [];
|
|
227
|
+
const gracenotes = createBeamedNotes(f.GraceNote.bind(f), keys, stemDirection, beams, true, notesToBeam);
|
|
228
|
+
const graceNoteGroup = f.GraceNoteGroup({ notes: gracenotes });
|
|
229
|
+
notesToBeam.map(graceNoteGroup.beamNotes.bind(graceNoteGroup));
|
|
230
|
+
bnotes[0].addModifier(graceNoteGroup, 0);
|
|
231
|
+
return bnotes;
|
|
232
|
+
}
|
|
233
|
+
const beams = [];
|
|
234
|
+
const voice = f.Voice().setStrict(false);
|
|
235
|
+
voice.addTickables(createBeamedNoteBlock(options.params.keys1, options.params.stemDirection1, beams));
|
|
236
|
+
voice.addTickables(createBeamedNoteBlock(options.params.keys2, options.params.stemDirection2, beams));
|
|
237
|
+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
238
|
+
f.draw();
|
|
239
|
+
options.assert.ok(true, 'GraceNoteStem');
|
|
240
|
+
}
|
|
241
|
+
function slash(options) {
|
|
242
|
+
const f = VexFlowTests.makeFactory(options, 700, 130);
|
|
243
|
+
const stave = f.Stave({ x: 10, y: 10, width: 650 });
|
|
244
|
+
function createNotes(noteT, keys, stemDirection, slash) {
|
|
245
|
+
return durationsForStemTest.map((d) => createNoteForStemTest(d, noteT, keys, stemDirection, slash));
|
|
246
|
+
}
|
|
247
|
+
function createNoteBlock(keys, stemDirection) {
|
|
248
|
+
const notes = [f.StaveNote({ keys: ['f/4'], stemDirection, duration: '16' })];
|
|
249
|
+
let graceNotes = createNotes(f.GraceNote.bind(f), keys, stemDirection, true);
|
|
250
|
+
const duration = '8';
|
|
251
|
+
const gns = [
|
|
252
|
+
{ keys: ['d/4', 'a/4'], stemDirection, duration, slash: true },
|
|
253
|
+
{ keys: ['d/4', 'a/4'], stemDirection, duration, slash: true },
|
|
254
|
+
{ keys: ['d/4', 'a/4'], stemDirection, duration, slash: true },
|
|
255
|
+
{ keys: ['e/4', 'a/4'], stemDirection, duration, slash: true },
|
|
256
|
+
{ keys: ['e/4', 'a/4'], stemDirection, duration, slash: true },
|
|
257
|
+
{ keys: ['b/4', 'f/5'], stemDirection, duration, slash: true },
|
|
258
|
+
{ keys: ['b/4', 'f/5'], stemDirection, duration, slash: true },
|
|
259
|
+
{ keys: ['b/4', 'f/5'], stemDirection, duration, slash: true },
|
|
260
|
+
{ keys: ['e/4', 'a/4'], stemDirection, duration, slash: true },
|
|
261
|
+
].map(f.GraceNote.bind(f));
|
|
262
|
+
const notesToBeam = [];
|
|
263
|
+
notesToBeam.push([gns[0], gns[1], gns[2]]);
|
|
264
|
+
notesToBeam.push([gns[3], gns[4], gns[5]]);
|
|
265
|
+
notesToBeam.push([gns[6], gns[7], gns[8]]);
|
|
266
|
+
graceNotes = graceNotes.concat(gns);
|
|
267
|
+
const graceNoteGroup = f.GraceNoteGroup({ notes: graceNotes });
|
|
268
|
+
notesToBeam.forEach((notes) => graceNoteGroup.beamNotes(notes));
|
|
269
|
+
notes[0].addModifier(graceNoteGroup, 0);
|
|
270
|
+
return notes;
|
|
271
|
+
}
|
|
272
|
+
const voice = f.Voice().setStrict(false);
|
|
273
|
+
voice.addTickables(createNoteBlock(['d/4', 'a/4'], 1));
|
|
274
|
+
voice.addTickables(createNoteBlock(['d/4', 'a/4'], -1));
|
|
275
|
+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
276
|
+
f.draw();
|
|
277
|
+
options.assert.ok(true, 'GraceNoteSlash');
|
|
278
|
+
}
|
|
279
|
+
function slashWithBeams(options) {
|
|
280
|
+
const f = VexFlowTests.makeFactory(options, 800, 130);
|
|
281
|
+
const stave = f.Stave({ x: 10, y: 10, width: 750 });
|
|
282
|
+
function createNoteBlock(keys, stemDirection) {
|
|
283
|
+
const notes = [f.StaveNote({ keys: ['f/4'], stemDirection, duration: '16' })];
|
|
284
|
+
let allGraceNotes = [];
|
|
285
|
+
const graceNotesToBeam = [];
|
|
286
|
+
['8', '16', '32', '64'].forEach(function (duration) {
|
|
287
|
+
const graceNotes = [
|
|
288
|
+
{ keys: ['d/4', 'a/4'], stemDirection, duration, slash: true },
|
|
289
|
+
{ keys: ['d/4', 'a/4'], stemDirection, duration, slash: false },
|
|
290
|
+
{ keys: ['e/4', 'a/4'], stemDirection, duration, slash: true },
|
|
291
|
+
{ keys: ['b/4', 'f/5'], stemDirection, duration, slash: false },
|
|
292
|
+
{ keys: ['b/4', 'f/5'], stemDirection, duration, slash: true },
|
|
293
|
+
{ keys: ['e/4', 'a/4'], stemDirection, duration, slash: false },
|
|
294
|
+
].map(f.GraceNote.bind(f));
|
|
295
|
+
graceNotesToBeam.push([graceNotes[0], graceNotes[1]]);
|
|
296
|
+
graceNotesToBeam.push([graceNotes[2], graceNotes[3]]);
|
|
297
|
+
graceNotesToBeam.push([graceNotes[4], graceNotes[5]]);
|
|
298
|
+
allGraceNotes = allGraceNotes.concat(graceNotes);
|
|
299
|
+
});
|
|
300
|
+
const graceNoteGroup = f.GraceNoteGroup({ notes: allGraceNotes });
|
|
301
|
+
graceNotesToBeam.forEach((g) => graceNoteGroup.beamNotes(g));
|
|
302
|
+
notes[0].addModifier(graceNoteGroup, 0);
|
|
303
|
+
return notes;
|
|
304
|
+
}
|
|
305
|
+
const voice = f.Voice().setStrict(false);
|
|
306
|
+
voice.addTickables(createNoteBlock(['d/4', 'a/4'], 1));
|
|
307
|
+
voice.addTickables(createNoteBlock(['d/4', 'a/4'], -1));
|
|
308
|
+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
309
|
+
f.draw();
|
|
310
|
+
options.assert.ok(true, 'GraceNoteSlashWithBeams');
|
|
311
|
+
}
|
|
312
|
+
function multipleVoices(options) {
|
|
313
|
+
const f = VexFlowTests.makeFactory(options, 450, 140);
|
|
314
|
+
const stave = f.Stave({ x: 10, y: 10, width: 450 });
|
|
315
|
+
const notes = [
|
|
316
|
+
{ keys: ['f/5'], stemDirection: 1, duration: '16' },
|
|
317
|
+
{ keys: ['f/5'], stemDirection: 1, duration: '16' },
|
|
318
|
+
{ keys: ['d/5'], stemDirection: 1, duration: '16' },
|
|
319
|
+
{ keys: ['c/5'], stemDirection: 1, duration: '16' },
|
|
320
|
+
{ keys: ['c/5'], stemDirection: 1, duration: '16' },
|
|
321
|
+
{ keys: ['d/5'], stemDirection: 1, duration: '16' },
|
|
322
|
+
{ keys: ['f/5'], stemDirection: 1, duration: '16' },
|
|
323
|
+
{ keys: ['e/5'], stemDirection: 1, duration: '16' },
|
|
324
|
+
].map(f.StaveNote.bind(f));
|
|
325
|
+
const notes2 = [
|
|
326
|
+
{ keys: ['f/4'], stemDirection: -1, duration: '16' },
|
|
327
|
+
{ keys: ['e/4'], stemDirection: -1, duration: '16' },
|
|
328
|
+
{ keys: ['d/4'], stemDirection: -1, duration: '16' },
|
|
329
|
+
{ keys: ['c/4'], stemDirection: -1, duration: '16' },
|
|
330
|
+
{ keys: ['c/4'], stemDirection: -1, duration: '16' },
|
|
331
|
+
{ keys: ['d/4'], stemDirection: -1, duration: '16' },
|
|
332
|
+
{ keys: ['f/4'], stemDirection: -1, duration: '16' },
|
|
333
|
+
{ keys: ['e/4'], stemDirection: -1, duration: '16' },
|
|
334
|
+
].map(f.StaveNote.bind(f));
|
|
335
|
+
const gracenotes1 = [{ keys: ['b/4'], stemDirection: 1, duration: '8', slash: true }].map(f.GraceNote.bind(f));
|
|
336
|
+
const gracenotes2 = [{ keys: ['f/4'], stemDirection: -1, duration: '8', slash: true }].map(f.GraceNote.bind(f));
|
|
337
|
+
const gracenotes3 = [
|
|
338
|
+
{ keys: ['f/4'], duration: '32', stemDirection: -1 },
|
|
339
|
+
{ keys: ['e/4'], duration: '32', stemDirection: -1 },
|
|
340
|
+
].map(f.GraceNote.bind(f));
|
|
341
|
+
const gracenotes4 = [
|
|
342
|
+
{ keys: ['f/5'], duration: '32', stemDirection: 1 },
|
|
343
|
+
{ keys: ['e/5'], duration: '32', stemDirection: 1 },
|
|
344
|
+
{ keys: ['e/5'], duration: '8', stemDirection: 1 },
|
|
345
|
+
].map(f.GraceNote.bind(f));
|
|
346
|
+
gracenotes2[0].setStemDirection(-1);
|
|
347
|
+
gracenotes2[0].addModifier(f.Accidental({ type: '#' }), 0);
|
|
348
|
+
notes[1].addModifier(f.GraceNoteGroup({ notes: gracenotes4 }).beamNotes(), 0);
|
|
349
|
+
notes[3].addModifier(f.GraceNoteGroup({ notes: gracenotes1 }), 0);
|
|
350
|
+
notes2[1].addModifier(f.GraceNoteGroup({ notes: gracenotes2 }).beamNotes(), 0);
|
|
351
|
+
notes2[5].addModifier(f.GraceNoteGroup({ notes: gracenotes3 }).beamNotes(), 0);
|
|
352
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
353
|
+
const voice2 = f.Voice().setStrict(false).addTickables(notes2);
|
|
354
|
+
f.Beam({ notes: notes.slice(0, 4) });
|
|
355
|
+
f.Beam({ notes: notes.slice(4, 8) });
|
|
356
|
+
f.Beam({ notes: notes2.slice(0, 4) });
|
|
357
|
+
f.Beam({ notes: notes2.slice(4, 8) });
|
|
358
|
+
f.Formatter().joinVoices([voice, voice2]).formatToStave([voice, voice2], stave);
|
|
359
|
+
f.draw();
|
|
360
|
+
options.assert.ok(true, 'Sixteenth Test');
|
|
361
|
+
}
|
|
362
|
+
function multipleVoicesMultipleDraws(options) {
|
|
363
|
+
const f = VexFlowTests.makeFactory(options, 450, 140);
|
|
364
|
+
const stave = f.Stave({ x: 10, y: 10, width: 450 });
|
|
365
|
+
const notes = [
|
|
366
|
+
{ keys: ['f/5'], stemDirection: 1, duration: '16' },
|
|
367
|
+
{ keys: ['f/5'], stemDirection: 1, duration: '16' },
|
|
368
|
+
{ keys: ['d/5'], stemDirection: 1, duration: '16' },
|
|
369
|
+
{ keys: ['c/5'], stemDirection: 1, duration: '16' },
|
|
370
|
+
{ keys: ['c/5'], stemDirection: 1, duration: '16' },
|
|
371
|
+
{ keys: ['d/5'], stemDirection: 1, duration: '16' },
|
|
372
|
+
{ keys: ['f/5'], stemDirection: 1, duration: '16' },
|
|
373
|
+
{ keys: ['e/5'], stemDirection: 1, duration: '16' },
|
|
374
|
+
].map(f.StaveNote.bind(f));
|
|
375
|
+
const notes2 = [
|
|
376
|
+
{ keys: ['f/4'], stemDirection: -1, duration: '16' },
|
|
377
|
+
{ keys: ['e/4'], stemDirection: -1, duration: '16' },
|
|
378
|
+
{ keys: ['d/4'], stemDirection: -1, duration: '16' },
|
|
379
|
+
{ keys: ['c/4'], stemDirection: -1, duration: '16' },
|
|
380
|
+
{ keys: ['c/4'], stemDirection: -1, duration: '16' },
|
|
381
|
+
{ keys: ['d/4'], stemDirection: -1, duration: '16' },
|
|
382
|
+
{ keys: ['f/4'], stemDirection: -1, duration: '16' },
|
|
383
|
+
{ keys: ['e/4'], stemDirection: -1, duration: '16' },
|
|
384
|
+
].map(f.StaveNote.bind(f));
|
|
385
|
+
const gracenotes1 = [{ keys: ['b/4'], stemDirection: 1, duration: '8', slash: true }].map(f.GraceNote.bind(f));
|
|
386
|
+
const gracenotes2 = [{ keys: ['f/4'], stemDirection: -1, duration: '8', slash: true }].map(f.GraceNote.bind(f));
|
|
387
|
+
const gracenotes3 = [
|
|
388
|
+
{ keys: ['f/4'], duration: '32', stemDirection: -1 },
|
|
389
|
+
{ keys: ['e/4'], duration: '32', stemDirection: -1 },
|
|
390
|
+
].map(f.GraceNote.bind(f));
|
|
391
|
+
const gracenotes4 = [
|
|
392
|
+
{ keys: ['f/5'], duration: '32', stemDirection: 1 },
|
|
393
|
+
{ keys: ['e/5'], duration: '32', stemDirection: 1 },
|
|
394
|
+
{ keys: ['e/5'], duration: '8', stemDirection: 1 },
|
|
395
|
+
].map(f.GraceNote.bind(f));
|
|
396
|
+
gracenotes2[0].setStemDirection(-1);
|
|
397
|
+
gracenotes2[0].addModifier(f.Accidental({ type: '#' }), 0);
|
|
398
|
+
notes[1].addModifier(f.GraceNoteGroup({ notes: gracenotes4 }).beamNotes(), 0);
|
|
399
|
+
notes[3].addModifier(f.GraceNoteGroup({ notes: gracenotes1 }), 0);
|
|
400
|
+
notes2[1].addModifier(f.GraceNoteGroup({ notes: gracenotes2 }).beamNotes(), 0);
|
|
401
|
+
notes2[5].addModifier(f.GraceNoteGroup({ notes: gracenotes3 }).beamNotes(), 0);
|
|
402
|
+
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
403
|
+
const voice2 = f.Voice().setStrict(false).addTickables(notes2);
|
|
404
|
+
f.Beam({ notes: notes.slice(0, 4) });
|
|
405
|
+
f.Beam({ notes: notes.slice(4, 8) });
|
|
406
|
+
f.Beam({ notes: notes2.slice(0, 4) });
|
|
407
|
+
f.Beam({ notes: notes2.slice(4, 8) });
|
|
408
|
+
f.Formatter().joinVoices([voice, voice2]).formatToStave([voice, voice2], stave);
|
|
409
|
+
f.draw();
|
|
410
|
+
f.draw();
|
|
411
|
+
options.assert.ok(true, 'Seventeenth Test');
|
|
412
|
+
}
|
|
413
|
+
VexFlowTests.register(GraceNoteTests);
|
|
414
|
+
export { GraceNoteTests };
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { VexFlow } from '../src/vexflow.js';
|
|
2
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
3
|
+
import { Formatter } from '../src/formatter.js';
|
|
4
|
+
import { GraceNoteGroup } from '../src/gracenotegroup.js';
|
|
5
|
+
import { GraceTabNote } from '../src/gracetabnote.js';
|
|
6
|
+
import { TabNote } from '../src/tabnote.js';
|
|
7
|
+
import { TabStave } from '../src/tabstave.js';
|
|
8
|
+
import { Voice } from '../src/voice.js';
|
|
9
|
+
const GraceTabNoteTests = {
|
|
10
|
+
Start() {
|
|
11
|
+
VexFlowTests.module('Grace Tab Notes');
|
|
12
|
+
const run = VexFlowTests.runTests;
|
|
13
|
+
run('Grace Tab Note Simple', simple);
|
|
14
|
+
run('Grace Tab Note Slurred', slurred);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const tabNote = (noteStruct) => new TabNote(noteStruct);
|
|
18
|
+
const graceTabNote = (noteStruct) => new GraceTabNote(noteStruct);
|
|
19
|
+
function setupContext(opts, ctxBuilder) {
|
|
20
|
+
const context = ctxBuilder(opts.elementId, 350, 140);
|
|
21
|
+
const stave = new TabStave(10, 10, 350).addTabGlyph().setContext(context).drawWithStyle();
|
|
22
|
+
return { context, stave };
|
|
23
|
+
}
|
|
24
|
+
function simple(options, contextBuilder) {
|
|
25
|
+
const { context, stave } = setupContext(options, contextBuilder);
|
|
26
|
+
const note0 = tabNote({ positions: [{ str: 4, fret: 6 }], duration: '4' });
|
|
27
|
+
const note1 = tabNote({ positions: [{ str: 4, fret: 12 }], duration: '4' });
|
|
28
|
+
const note2 = tabNote({ positions: [{ str: 4, fret: 10 }], duration: '4' });
|
|
29
|
+
const note3 = tabNote({ positions: [{ str: 4, fret: 10 }], duration: '4' });
|
|
30
|
+
const gracenoteGroup0 = [{ positions: [{ str: 4, fret: 'x' }], duration: '8' }];
|
|
31
|
+
const gracenoteGroup1 = [
|
|
32
|
+
{ positions: [{ str: 4, fret: 9 }], duration: '16' },
|
|
33
|
+
{ positions: [{ str: 4, fret: 10 }], duration: '16' },
|
|
34
|
+
];
|
|
35
|
+
const gracenoteGroup2 = [{ positions: [{ str: 4, fret: 9 }], duration: '8' }];
|
|
36
|
+
const gracenoteGroup3 = [
|
|
37
|
+
{ positions: [{ str: 5, fret: 10 }], duration: '8' },
|
|
38
|
+
{ positions: [{ str: 4, fret: 9 }], duration: '8' },
|
|
39
|
+
];
|
|
40
|
+
const gracenotes0 = gracenoteGroup0.map(graceTabNote);
|
|
41
|
+
const gracenotes1 = gracenoteGroup1.map(graceTabNote);
|
|
42
|
+
const gracenotes2 = gracenoteGroup2.map(graceTabNote);
|
|
43
|
+
gracenotes2[0].setGhost(true);
|
|
44
|
+
const gracenotes3 = gracenoteGroup3.map(graceTabNote);
|
|
45
|
+
note0.addModifier(new GraceNoteGroup(gracenotes0), 0);
|
|
46
|
+
note1.addModifier(new GraceNoteGroup(gracenotes1), 0);
|
|
47
|
+
note2.addModifier(new GraceNoteGroup(gracenotes2), 0);
|
|
48
|
+
note3.addModifier(new GraceNoteGroup(gracenotes3), 0);
|
|
49
|
+
const voice = new Voice(VexFlow.TIME4_4);
|
|
50
|
+
voice.addTickables([note0, note1, note2, note3]);
|
|
51
|
+
new Formatter().joinVoices([voice]).format([voice], 250);
|
|
52
|
+
voice.draw(context, stave);
|
|
53
|
+
options.assert.ok(true, 'Simple Test');
|
|
54
|
+
}
|
|
55
|
+
function slurred(options, contextBuilder) {
|
|
56
|
+
const { context, stave } = setupContext(options, contextBuilder);
|
|
57
|
+
const note0 = tabNote({ positions: [{ str: 4, fret: 12 }], duration: 'h' });
|
|
58
|
+
const note1 = tabNote({ positions: [{ str: 4, fret: 10 }], duration: 'h' });
|
|
59
|
+
const gracenoteGroup0 = [
|
|
60
|
+
{ positions: [{ str: 4, fret: 9 }], duration: '8' },
|
|
61
|
+
{ positions: [{ str: 4, fret: 10 }], duration: '8' },
|
|
62
|
+
];
|
|
63
|
+
const gracenoteGroup1 = [
|
|
64
|
+
{ positions: [{ str: 4, fret: 7 }], duration: '16' },
|
|
65
|
+
{ positions: [{ str: 4, fret: 8 }], duration: '16' },
|
|
66
|
+
{ positions: [{ str: 4, fret: 9 }], duration: '16' },
|
|
67
|
+
];
|
|
68
|
+
const gracenotes0 = gracenoteGroup0.map(graceTabNote);
|
|
69
|
+
const gracenotes1 = gracenoteGroup1.map(graceTabNote);
|
|
70
|
+
note0.addModifier(new GraceNoteGroup(gracenotes0, true), 0);
|
|
71
|
+
note1.addModifier(new GraceNoteGroup(gracenotes1, true), 0);
|
|
72
|
+
const voice = new Voice(VexFlow.TIME4_4);
|
|
73
|
+
voice.addTickables([note0, note1]);
|
|
74
|
+
new Formatter().joinVoices([voice]).format([voice], 200);
|
|
75
|
+
voice.draw(context, stave);
|
|
76
|
+
options.assert.ok(true, 'Slurred Test');
|
|
77
|
+
}
|
|
78
|
+
VexFlowTests.register(GraceTabNoteTests);
|
|
79
|
+
export { GraceTabNoteTests };
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
export * from './accidental_tests.js';
|
|
2
|
+
export * from './annotation_tests.js';
|
|
3
|
+
export * from './articulation_tests.js';
|
|
4
|
+
export * from './auto_beam_formatting_tests.js';
|
|
5
|
+
export * from './barline_tests.js';
|
|
6
|
+
export * from './beam_tests.js';
|
|
7
|
+
export * from './bend_tests.js';
|
|
8
|
+
export * from './boundingbox_tests.js';
|
|
9
|
+
export * from './chordsymbol_tests.js';
|
|
10
|
+
export * from './clef_tests.js';
|
|
11
|
+
export * from './crossbeam_tests.js';
|
|
12
|
+
export * from './curve_tests.js';
|
|
13
|
+
export * from './demo_petzold_tests.js';
|
|
14
|
+
export * from './dot_tests.js';
|
|
15
|
+
export * from './easyscore_tests.js';
|
|
16
|
+
export * from './factory_tests.js';
|
|
17
|
+
export * from './font_tests.js';
|
|
18
|
+
export * from './formatter_tests.js';
|
|
19
|
+
export * from './fraction_tests.js';
|
|
20
|
+
export * from './ghostnote_tests.js';
|
|
21
|
+
export * from './glyphnote_tests.js';
|
|
22
|
+
export * from './gracenote_tests.js';
|
|
23
|
+
export * from './gracetabnote_tests.js';
|
|
24
|
+
export * from './key_clef_tests.js';
|
|
25
|
+
export * from './keymanager_tests.js';
|
|
26
|
+
export * from './keysignature_tests.js';
|
|
27
|
+
export * from './modifier_tests.js';
|
|
28
|
+
export * from './multimeasurerest_tests.js';
|
|
29
|
+
export * from './music_tests.js';
|
|
30
|
+
export * from './notehead_tests.js';
|
|
31
|
+
export * from './notesubgroup_tests.js';
|
|
32
|
+
export * from './offscreencanvas_tests.js';
|
|
33
|
+
export * from './ornament_tests.js';
|
|
34
|
+
export * from './parser_tests.js';
|
|
35
|
+
export * from './pedalmarking_tests.js';
|
|
36
|
+
export * from './percussion_tests.js';
|
|
37
|
+
export * from './registry_tests.js';
|
|
38
|
+
export * from './renderer_tests.js';
|
|
39
|
+
export * from './rests_tests.js';
|
|
40
|
+
export * from './rhythm_tests.js';
|
|
41
|
+
export * from './stave_tests.js';
|
|
42
|
+
export * from './staveconnector_tests.js';
|
|
43
|
+
export * from './stavehairpin_tests.js';
|
|
44
|
+
export * from './staveline_tests.js';
|
|
45
|
+
export * from './stavemodifier_tests.js';
|
|
46
|
+
export * from './stavenote_tests.js';
|
|
47
|
+
export * from './stavetie_tests.js';
|
|
48
|
+
export * from './stringnumber_tests.js';
|
|
49
|
+
export * from './strokes_tests.js';
|
|
50
|
+
export * from './style_tests.js';
|
|
51
|
+
export * from './tabnote_tests.js';
|
|
52
|
+
export * from './tabslide_tests.js';
|
|
53
|
+
export * from './tabstave_tests.js';
|
|
54
|
+
export * from './tabtie_tests.js';
|
|
55
|
+
export * from './textbracket_tests.js';
|
|
56
|
+
export * from './textnote_tests.js';
|
|
57
|
+
export * from './threevoice_tests.js';
|
|
58
|
+
export * from './tickcontext_tests.js';
|
|
59
|
+
export * from './timesignature_tests.js';
|
|
60
|
+
export * from './tremolo_tests.js';
|
|
61
|
+
export * from './tuning_tests.js';
|
|
62
|
+
export * from './tuplet_tests.js';
|
|
63
|
+
export * from './typeguard_tests.js';
|
|
64
|
+
export * from './unison_tests.js';
|
|
65
|
+
export * from './vf_prefix_tests.js';
|
|
66
|
+
export * from './vibrato_tests.js';
|
|
67
|
+
export * from './vibratobracket_tests.js';
|
|
68
|
+
export * from './voice_tests.js';
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import { MAJOR_KEYS, MINOR_KEYS, VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Element } from '../src/element.js';
|
|
3
|
+
import { Glyphs } from '../src/glyphs.js';
|
|
4
|
+
import { KeySignature } from '../src/keysignature.js';
|
|
5
|
+
import { Stave } from '../src/stave.js';
|
|
6
|
+
const ClefKeySignatureTests = {
|
|
7
|
+
Start() {
|
|
8
|
+
VexFlowTests.module('Clef Keys');
|
|
9
|
+
const run = VexFlowTests.runTests;
|
|
10
|
+
run('Major Key Clef Test', keys, { majorKeys: true });
|
|
11
|
+
run('Minor Key Clef Test', keys, { majorKeys: false });
|
|
12
|
+
run('Stave Helper', staveHelper);
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
const fontWidths = () => {
|
|
16
|
+
const sharpWidth = Element.measureWidth(Glyphs.accidentalSharp) + 1;
|
|
17
|
+
const flatWidth = Element.measureWidth(Glyphs.accidentalFlat) + 1;
|
|
18
|
+
const ksPadding = 10;
|
|
19
|
+
const naturalWidth = Element.measureWidth(Glyphs.accidentalNatural) + 2;
|
|
20
|
+
const clefWidth = Element.measureWidth(Glyphs.gClef);
|
|
21
|
+
return { sharpWidth, flatWidth, naturalWidth, clefWidth, ksPadding };
|
|
22
|
+
};
|
|
23
|
+
function keys(options, contextBuilder) {
|
|
24
|
+
const w = fontWidths();
|
|
25
|
+
const accidentalCount = 28;
|
|
26
|
+
const sharpTestWidth = accidentalCount * w.sharpWidth + w.clefWidth + Stave.defaultPadding + 6 * w.ksPadding;
|
|
27
|
+
const flatTestWidth = accidentalCount * w.flatWidth + w.clefWidth + Stave.defaultPadding + 6 * w.ksPadding;
|
|
28
|
+
const clefs = [
|
|
29
|
+
'treble',
|
|
30
|
+
'soprano',
|
|
31
|
+
'mezzo-soprano',
|
|
32
|
+
'alto',
|
|
33
|
+
'tenor',
|
|
34
|
+
'baritone-f',
|
|
35
|
+
'baritone-c',
|
|
36
|
+
'bass',
|
|
37
|
+
'french',
|
|
38
|
+
'subbass',
|
|
39
|
+
'percussion',
|
|
40
|
+
];
|
|
41
|
+
const ctx = contextBuilder(options.elementId, Math.max(sharpTestWidth, flatTestWidth) + 100, 20 + 80 * 2 * clefs.length);
|
|
42
|
+
const staves = [];
|
|
43
|
+
const keys = options.params.majorKeys ? MAJOR_KEYS : MINOR_KEYS;
|
|
44
|
+
let i;
|
|
45
|
+
let flat;
|
|
46
|
+
let sharp;
|
|
47
|
+
let keySig;
|
|
48
|
+
const yOffsetForFlatStaves = 10 + 80 * clefs.length;
|
|
49
|
+
for (i = 0; i < clefs.length; i++) {
|
|
50
|
+
staves[i] = new Stave(10, 10 + 80 * i, flatTestWidth);
|
|
51
|
+
staves[i].addClef(clefs[i]);
|
|
52
|
+
staves[i + clefs.length] = new Stave(10, yOffsetForFlatStaves + 10 + 80 * i, sharpTestWidth);
|
|
53
|
+
staves[i + clefs.length].addClef(clefs[i]);
|
|
54
|
+
for (flat = 0; flat < 8; flat++) {
|
|
55
|
+
keySig = new KeySignature(keys[flat]);
|
|
56
|
+
keySig.addToStave(staves[i]);
|
|
57
|
+
}
|
|
58
|
+
for (sharp = 8; sharp < keys.length; sharp++) {
|
|
59
|
+
keySig = new KeySignature(keys[sharp]);
|
|
60
|
+
keySig.addToStave(staves[i + clefs.length]);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
Stave.formatBegModifiers(staves);
|
|
64
|
+
for (i = 0; i < clefs.length; i++) {
|
|
65
|
+
staves[i].setContext(ctx);
|
|
66
|
+
staves[i].drawWithStyle();
|
|
67
|
+
staves[i + clefs.length].setContext(ctx);
|
|
68
|
+
staves[i + clefs.length].drawWithStyle();
|
|
69
|
+
}
|
|
70
|
+
options.assert.ok(true, 'all pass');
|
|
71
|
+
}
|
|
72
|
+
function staveHelper(options, contextBuilder) {
|
|
73
|
+
const w = fontWidths();
|
|
74
|
+
const accidentalCount = 28;
|
|
75
|
+
const sharpTestWidth = accidentalCount * w.sharpWidth + w.clefWidth + Stave.defaultPadding + 7 * w.ksPadding;
|
|
76
|
+
const flatTestWidth = accidentalCount * w.flatWidth + w.clefWidth + Stave.defaultPadding + 7 * w.ksPadding;
|
|
77
|
+
const ctx = contextBuilder(options.elementId, Math.max(sharpTestWidth, flatTestWidth) + 100, 400);
|
|
78
|
+
const stave1 = new Stave(10, 10, flatTestWidth);
|
|
79
|
+
const stave2 = new Stave(10, 90, flatTestWidth);
|
|
80
|
+
const stave3 = new Stave(10, 170, sharpTestWidth);
|
|
81
|
+
const stave4 = new Stave(10, 260, sharpTestWidth);
|
|
82
|
+
const keys = MAJOR_KEYS;
|
|
83
|
+
stave1.addClef('treble');
|
|
84
|
+
stave2.addClef('bass');
|
|
85
|
+
stave3.addClef('alto');
|
|
86
|
+
stave4.addClef('tenor');
|
|
87
|
+
for (let n = 0; n < 8; ++n) {
|
|
88
|
+
stave1.addKeySignature(keys[n]);
|
|
89
|
+
stave2.addKeySignature(keys[n]);
|
|
90
|
+
}
|
|
91
|
+
for (let i = 8; i < keys.length; ++i) {
|
|
92
|
+
stave3.addKeySignature(keys[i]);
|
|
93
|
+
stave4.addKeySignature(keys[i]);
|
|
94
|
+
}
|
|
95
|
+
stave1.setContext(ctx);
|
|
96
|
+
stave1.drawWithStyle();
|
|
97
|
+
stave2.setContext(ctx);
|
|
98
|
+
stave2.drawWithStyle();
|
|
99
|
+
stave3.setContext(ctx);
|
|
100
|
+
stave3.drawWithStyle();
|
|
101
|
+
stave4.setContext(ctx);
|
|
102
|
+
stave4.drawWithStyle();
|
|
103
|
+
options.assert.ok(true, 'all pass');
|
|
104
|
+
}
|
|
105
|
+
VexFlowTests.register(ClefKeySignatureTests);
|
|
106
|
+
export { ClefKeySignatureTests };
|