vexflow 4.0.1-beta.1 → 4.0.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +92 -24
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +38 -16
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow-font-gonville.js +1 -1
- package/build/cjs/vexflow-font-gonville.js.map +1 -1
- package/build/cjs/vexflow-gonville.js +2 -2
- package/build/cjs/vexflow-gonville.js.map +1 -1
- package/build/cjs/vexflow-petaluma.js +2 -2
- package/build/cjs/vexflow-petaluma.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/entry/vexflow-bravura.js +11 -0
- package/build/esm/entry/vexflow-core.js +54 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +4 -0
- package/build/esm/entry/vexflow-debug.js +3 -0
- package/build/esm/entry/vexflow-font-bravura.js +7 -0
- package/build/esm/entry/vexflow-font-custom.js +7 -0
- package/build/esm/entry/vexflow-font-gonville.js +7 -0
- package/build/esm/entry/vexflow-font-petaluma.js +7 -0
- package/build/esm/entry/vexflow-gonville.js +11 -0
- package/build/esm/entry/vexflow-petaluma.js +11 -0
- package/build/esm/entry/vexflow.js +9 -0
- package/build/esm/src/accidental.js +348 -0
- package/build/esm/src/annotation.js +232 -0
- package/build/esm/src/articulation.js +267 -0
- package/build/esm/src/barnote.js +58 -0
- package/build/esm/src/beam.js +632 -0
- package/build/esm/src/bend.js +202 -0
- package/build/esm/src/boundingbox.js +59 -0
- package/build/esm/src/boundingboxcomputation.js +107 -0
- package/build/esm/src/canvascontext.js +202 -0
- package/build/esm/src/chordsymbol.js +578 -0
- package/build/esm/src/clef.js +153 -0
- package/build/esm/src/clefnote.js +65 -0
- package/build/esm/src/crescendo.js +77 -0
- package/build/esm/src/curve.js +118 -0
- package/build/esm/src/dot.js +137 -0
- package/build/esm/src/easyscore.js +374 -0
- package/build/esm/src/element.js +216 -0
- package/build/esm/src/factory.js +440 -0
- package/build/esm/src/flow.js +275 -0
- package/build/esm/src/font.js +264 -0
- package/build/esm/src/fonts/bravura_glyphs.js +3239 -0
- package/build/esm/src/fonts/bravura_metrics.js +507 -0
- package/build/esm/src/fonts/custom_glyphs.js +78 -0
- package/build/esm/src/fonts/custom_metrics.js +5 -0
- package/build/esm/src/fonts/gonville_glyphs.js +828 -0
- package/build/esm/src/fonts/gonville_metrics.js +421 -0
- package/build/esm/src/fonts/load_all.js +10 -0
- package/build/esm/src/fonts/load_bravura.js +6 -0
- package/build/esm/src/fonts/load_custom.js +6 -0
- package/build/esm/src/fonts/load_gonville.js +6 -0
- package/build/esm/src/fonts/load_petaluma.js +6 -0
- package/build/esm/src/fonts/petaluma_glyphs.js +1335 -0
- package/build/esm/src/fonts/petaluma_metrics.js +536 -0
- package/build/esm/src/fonts/petalumascript_glyphs.js +863 -0
- package/build/esm/src/fonts/robotoslab_glyphs.js +863 -0
- package/build/esm/src/fonts/textfonts.js +44 -0
- package/build/esm/src/formatter.js +568 -0
- package/build/esm/src/fraction.js +171 -0
- package/build/esm/src/frethandfinger.js +156 -0
- package/build/esm/src/ghostnote.js +50 -0
- package/build/esm/src/glyph.js +331 -0
- package/build/esm/src/glyphnote.js +55 -0
- package/build/esm/src/gracenote.js +133 -0
- package/build/esm/src/gracenotegroup.js +128 -0
- package/build/esm/src/gracetabnote.js +12 -0
- package/build/esm/src/index.js +91 -0
- package/build/esm/src/keymanager.js +99 -0
- package/build/esm/src/keysignature.js +250 -0
- package/build/esm/src/keysignote.js +28 -0
- package/build/esm/src/modifier.js +128 -0
- package/build/esm/src/modifiercontext.js +110 -0
- package/build/esm/src/multimeasurerest.js +173 -0
- package/build/esm/src/music.js +322 -0
- package/build/esm/src/note.js +371 -0
- package/build/esm/src/notehead.js +169 -0
- package/build/esm/src/notesubgroup.js +59 -0
- package/build/esm/src/ornament.js +206 -0
- package/build/esm/src/parenthesis.js +76 -0
- package/build/esm/src/parser.js +164 -0
- package/build/esm/src/pedalmarking.js +192 -0
- package/build/esm/src/registry.js +81 -0
- package/build/esm/src/rendercontext.js +24 -0
- package/build/esm/src/renderer.js +112 -0
- package/build/esm/src/repeatnote.js +22 -0
- package/build/esm/src/stave.js +547 -0
- package/build/esm/src/stavebarline.js +182 -0
- package/build/esm/src/staveconnector.js +196 -0
- package/build/esm/src/stavehairpin.js +120 -0
- package/build/esm/src/staveline.js +218 -0
- package/build/esm/src/stavemodifier.js +77 -0
- package/build/esm/src/stavenote.js +855 -0
- package/build/esm/src/staverepetition.js +155 -0
- package/build/esm/src/stavesection.js +58 -0
- package/build/esm/src/stavetempo.js +91 -0
- package/build/esm/src/stavetext.js +82 -0
- package/build/esm/src/stavetie.js +141 -0
- package/build/esm/src/stavevolta.js +67 -0
- package/build/esm/src/stem.js +131 -0
- package/build/esm/src/stemmablenote.js +193 -0
- package/build/esm/src/stringnumber.js +231 -0
- package/build/esm/src/strokes.js +200 -0
- package/build/esm/src/svgcontext.js +414 -0
- package/build/esm/src/system.js +116 -0
- package/build/esm/src/tables.js +1102 -0
- package/build/esm/src/tabnote.js +299 -0
- package/build/esm/src/tabslide.js +76 -0
- package/build/esm/src/tabstave.js +17 -0
- package/build/esm/src/tabtie.js +19 -0
- package/build/esm/src/textbracket.js +144 -0
- package/build/esm/src/textdynamics.js +81 -0
- package/build/esm/src/textformatter.js +177 -0
- package/build/esm/src/textnote.js +176 -0
- package/build/esm/src/tickable.js +214 -0
- package/build/esm/src/tickcontext.js +170 -0
- package/build/esm/src/timesigglyph.js +85 -0
- package/build/esm/src/timesignature.js +89 -0
- package/build/esm/src/timesignote.js +32 -0
- package/build/esm/src/tremolo.js +47 -0
- package/build/esm/src/tuning.js +54 -0
- package/build/esm/src/tuplet.js +240 -0
- package/build/esm/src/typeguard.js +30 -0
- package/build/esm/src/util.js +58 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vex.js +51 -0
- package/build/esm/src/vibrato.js +100 -0
- package/build/esm/src/vibratobracket.js +50 -0
- package/build/esm/src/voice.js +187 -0
- package/build/esm/src/web.js +15 -0
- package/build/esm/tests/accidental_tests.js +974 -0
- package/build/esm/tests/annotation_tests.js +377 -0
- package/build/esm/tests/articulation_tests.js +365 -0
- package/build/esm/tests/auto_beam_formatting_tests.js +548 -0
- package/build/esm/tests/bach_tests.js +335 -0
- package/build/esm/tests/barline_tests.js +52 -0
- package/build/esm/tests/beam_tests.js +595 -0
- package/build/esm/tests/bend_tests.js +215 -0
- package/build/esm/tests/boundingbox_tests.js +53 -0
- package/build/esm/tests/boundingboxcomputation_tests.js +183 -0
- package/build/esm/tests/chordsymbol_tests.js +320 -0
- package/build/esm/tests/clef_tests.js +131 -0
- package/build/esm/tests/curve_tests.js +118 -0
- package/build/esm/tests/dot_tests.js +123 -0
- package/build/esm/tests/easyscore_tests.js +459 -0
- package/build/esm/tests/factory_tests.js +44 -0
- package/build/esm/tests/font_tests.js +135 -0
- package/build/esm/tests/formatter/framestack.js +61 -0
- package/build/esm/tests/formatter/tests.js +203 -0
- package/build/esm/tests/formatter_tests.js +669 -0
- package/build/esm/tests/fraction_tests.js +72 -0
- package/build/esm/tests/ghostnote_tests.js +77 -0
- package/build/esm/tests/glyphnote_tests.js +113 -0
- package/build/esm/tests/gracenote_tests.js +413 -0
- package/build/esm/tests/gracetabnote_tests.js +79 -0
- package/build/esm/tests/index.js +68 -0
- package/build/esm/tests/key_clef_tests.js +103 -0
- package/build/esm/tests/keymanager_tests.js +68 -0
- package/build/esm/tests/keysignature_tests.js +308 -0
- package/build/esm/tests/mocks.js +71 -0
- package/build/esm/tests/modifier_tests.js +24 -0
- package/build/esm/tests/multimeasurerest_tests.js +141 -0
- package/build/esm/tests/music_tests.js +161 -0
- package/build/esm/tests/notehead_tests.js +137 -0
- package/build/esm/tests/notesubgroup_tests.js +149 -0
- package/build/esm/tests/offscreencanvas_tests.js +47 -0
- package/build/esm/tests/ornament_tests.js +298 -0
- package/build/esm/tests/parser_tests.js +122 -0
- package/build/esm/tests/pedalmarking_tests.js +64 -0
- package/build/esm/tests/percussion_tests.js +180 -0
- package/build/esm/tests/registry_tests.js +64 -0
- package/build/esm/tests/renderer_tests.js +113 -0
- package/build/esm/tests/rests_tests.js +248 -0
- package/build/esm/tests/rhythm_tests.js +357 -0
- package/build/esm/tests/stave_tests.js +560 -0
- package/build/esm/tests/staveconnector_tests.js +402 -0
- package/build/esm/tests/stavehairpin_tests.js +90 -0
- package/build/esm/tests/staveline_tests.js +122 -0
- package/build/esm/tests/stavemodifier_tests.js +51 -0
- package/build/esm/tests/stavenote_tests.js +867 -0
- package/build/esm/tests/stavetie_tests.js +108 -0
- package/build/esm/tests/stringnumber_tests.js +259 -0
- package/build/esm/tests/strokes_tests.js +275 -0
- package/build/esm/tests/style_tests.js +98 -0
- package/build/esm/tests/support/qunit.js +2765 -0
- package/build/esm/tests/tabnote_tests.js +474 -0
- package/build/esm/tests/tabslide_tests.js +135 -0
- package/build/esm/tests/tabstave_tests.js +23 -0
- package/build/esm/tests/tabtie_tests.js +173 -0
- package/build/esm/tests/textbracket_tests.js +100 -0
- package/build/esm/tests/textformatter_tests.js +24 -0
- package/build/esm/tests/textnote_tests.js +215 -0
- package/build/esm/tests/threevoice_tests.js +132 -0
- package/build/esm/tests/tickcontext_tests.js +36 -0
- package/build/esm/tests/timesignature_tests.js +134 -0
- package/build/esm/tests/tremolo_tests.js +75 -0
- package/build/esm/tests/tuning_tests.js +56 -0
- package/build/esm/tests/tuplet_tests.js +450 -0
- package/build/esm/tests/typeguard_tests.js +82 -0
- package/build/esm/tests/vexflow_test_helpers.js +266 -0
- package/build/esm/tests/vf_prefix_tests.js +115 -0
- package/build/esm/tests/vibrato_tests.js +92 -0
- package/build/esm/tests/vibratobracket_tests.js +45 -0
- package/build/esm/tests/voice_tests.js +69 -0
- package/build/types/entry/vexflow-bravura.d.ts +3 -0
- package/build/types/entry/vexflow-core.d.ts +3 -0
- package/build/types/entry/vexflow-debug.d.ts +3 -0
- package/build/types/entry/vexflow-font-bravura.d.ts +3771 -0
- package/build/types/entry/vexflow-font-custom.d.ts +86 -0
- package/build/types/entry/vexflow-font-gonville.d.ts +1267 -0
- package/build/types/entry/vexflow-font-petaluma.d.ts +1896 -0
- package/build/types/entry/vexflow-gonville.d.ts +3 -0
- package/build/types/entry/vexflow-petaluma.d.ts +3 -0
- package/build/types/entry/vexflow.d.ts +3 -0
- package/build/types/src/accidental.d.ts +66 -0
- package/build/types/src/annotation.d.ts +60 -0
- package/build/types/src/articulation.d.ts +62 -0
- package/build/types/src/barnote.d.ts +29 -0
- package/build/types/src/beam.d.ts +124 -0
- package/build/types/src/bend.d.ts +73 -0
- package/build/types/src/boundingbox.d.ts +42 -0
- package/build/types/src/boundingboxcomputation.d.ts +33 -0
- package/build/types/src/canvascontext.d.ts +89 -0
- package/build/types/src/chordsymbol.d.ts +149 -0
- package/build/types/src/clef.d.ts +48 -0
- package/build/types/src/clefnote.d.ts +25 -0
- package/build/types/src/crescendo.d.ts +27 -0
- package/build/types/src/curve.d.ts +41 -0
- package/build/types/src/dot.d.ts +20 -0
- package/build/types/src/easyscore.d.ts +148 -0
- package/build/types/src/element.d.ts +202 -0
- package/build/types/src/factory.d.ts +271 -0
- package/build/types/src/flow.d.ts +245 -0
- package/build/types/src/font.d.ts +181 -0
- package/build/types/src/fonts/bravura_glyphs.d.ts +3239 -0
- package/build/types/src/fonts/bravura_metrics.d.ts +533 -0
- package/build/types/src/fonts/custom_glyphs.d.ts +78 -0
- package/build/types/src/fonts/custom_metrics.d.ts +5 -0
- package/build/types/src/fonts/gonville_glyphs.d.ts +828 -0
- package/build/types/src/fonts/gonville_metrics.d.ts +440 -0
- package/build/types/src/fonts/load_all.d.ts +1 -0
- package/build/types/src/fonts/load_bravura.d.ts +1 -0
- package/build/types/src/fonts/load_custom.d.ts +1 -0
- package/build/types/src/fonts/load_gonville.d.ts +1 -0
- package/build/types/src/fonts/load_petaluma.d.ts +1 -0
- package/build/types/src/fonts/petaluma_glyphs.d.ts +1335 -0
- package/build/types/src/fonts/petaluma_metrics.d.ts +562 -0
- package/build/types/src/fonts/petalumascript_glyphs.d.ts +863 -0
- package/build/types/src/fonts/robotoslab_glyphs.d.ts +863 -0
- package/build/types/src/fonts/textfonts.d.ts +1 -0
- package/build/types/src/formatter.d.ts +203 -0
- package/build/types/src/fraction.d.ts +62 -0
- package/build/types/src/frethandfinger.d.ts +22 -0
- package/build/types/src/ghostnote.d.ts +16 -0
- package/build/types/src/glyph.d.ts +139 -0
- package/build/types/src/glyphnote.d.ts +17 -0
- package/build/types/src/gracenote.d.ts +19 -0
- package/build/types/src/gracenotegroup.d.ts +33 -0
- package/build/types/src/gracetabnote.d.ts +5 -0
- package/build/types/src/index.d.ts +91 -0
- package/build/types/src/keymanager.d.ts +25 -0
- package/build/types/src/keysignature.d.ts +50 -0
- package/build/types/src/keysignote.d.ts +11 -0
- package/build/types/src/modifier.d.ts +97 -0
- package/build/types/src/modifiercontext.d.ts +45 -0
- package/build/types/src/multimeasurerest.d.ts +61 -0
- package/build/types/src/music.d.ts +91 -0
- package/build/types/src/note.d.ts +231 -0
- package/build/types/src/notehead.d.ts +70 -0
- package/build/types/src/notesubgroup.d.ts +18 -0
- package/build/types/src/ornament.d.ts +76 -0
- package/build/types/src/parenthesis.d.ts +22 -0
- package/build/types/src/parser.d.ts +45 -0
- package/build/types/src/pedalmarking.d.ts +69 -0
- package/build/types/src/registry.d.ts +40 -0
- package/build/types/src/rendercontext.d.ts +64 -0
- package/build/types/src/renderer.d.ts +35 -0
- package/build/types/src/repeatnote.d.ts +6 -0
- package/build/types/src/stave.d.ts +186 -0
- package/build/types/src/stavebarline.d.ts +28 -0
- package/build/types/src/staveconnector.d.ts +67 -0
- package/build/types/src/stavehairpin.d.ts +56 -0
- package/build/types/src/staveline.d.ts +57 -0
- package/build/types/src/stavemodifier.d.ts +44 -0
- package/build/types/src/stavenote.d.ts +154 -0
- package/build/types/src/staverepetition.d.ts +32 -0
- package/build/types/src/stavesection.d.ts +15 -0
- package/build/types/src/stavetempo.d.ts +25 -0
- package/build/types/src/stavetext.d.ts +25 -0
- package/build/types/src/stavetie.d.ts +59 -0
- package/build/types/src/stavevolta.d.ts +21 -0
- package/build/types/src/stem.d.ts +58 -0
- package/build/types/src/stemmablenote.d.ts +39 -0
- package/build/types/src/stringnumber.d.ts +27 -0
- package/build/types/src/strokes.d.ts +33 -0
- package/build/types/src/svgcontext.d.ts +131 -0
- package/build/types/src/system.d.ts +92 -0
- package/build/types/src/tables.d.ts +96 -0
- package/build/types/src/tabnote.d.ts +44 -0
- package/build/types/src/tabslide.d.ts +34 -0
- package/build/types/src/tabstave.d.ts +7 -0
- package/build/types/src/tabtie.d.ts +18 -0
- package/build/types/src/textbracket.d.ts +55 -0
- package/build/types/src/textdynamics.d.ts +39 -0
- package/build/types/src/textformatter.d.ts +109 -0
- package/build/types/src/textnote.d.ts +49 -0
- package/build/types/src/tickable.d.ts +140 -0
- package/build/types/src/tickcontext.d.ts +82 -0
- package/build/types/src/timesigglyph.d.ts +14 -0
- package/build/types/src/timesignature.d.ts +26 -0
- package/build/types/src/timesignote.d.ts +11 -0
- package/build/types/src/tremolo.d.ts +17 -0
- package/build/types/src/tuning.d.ts +23 -0
- package/build/types/src/tuplet.d.ts +105 -0
- package/build/types/src/typeguard.d.ts +99 -0
- package/build/types/src/util.d.ts +27 -0
- package/build/types/src/version.d.ts +3 -0
- package/build/types/src/vex.d.ts +18 -0
- package/build/types/src/vibrato.d.ts +29 -0
- package/build/types/src/vibratobracket.d.ts +33 -0
- package/build/types/src/voice.d.ts +108 -0
- package/build/types/src/web.d.ts +2 -0
- package/package.json +1 -1
- package/src/annotation.ts +27 -6
- package/src/articulation.ts +8 -2
- package/src/fonts/gonville_glyphs.ts +4 -4
|
@@ -0,0 +1,867 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
import { Accidental } from '../src/accidental.js';
|
|
3
|
+
import { Annotation, AnnotationVerticalJustify } from '../src/annotation.js';
|
|
4
|
+
import { Articulation } from '../src/articulation.js';
|
|
5
|
+
import { Beam } from '../src/beam.js';
|
|
6
|
+
import { Dot } from '../src/dot.js';
|
|
7
|
+
import { Flow } from '../src/flow.js';
|
|
8
|
+
import { Formatter } from '../src/formatter.js';
|
|
9
|
+
import { Fraction } from '../src/fraction.js';
|
|
10
|
+
import { FretHandFinger } from '../src/frethandfinger.js';
|
|
11
|
+
import { Modifier } from '../src/modifier.js';
|
|
12
|
+
import { ModifierContext } from '../src/modifiercontext.js';
|
|
13
|
+
import { Stave } from '../src/stave.js';
|
|
14
|
+
import { StaveNote } from '../src/stavenote.js';
|
|
15
|
+
import { Stem } from '../src/stem.js';
|
|
16
|
+
import { StringNumber } from '../src/stringnumber.js';
|
|
17
|
+
import { Stroke } from '../src/strokes.js';
|
|
18
|
+
import { TickContext } from '../src/tickcontext.js';
|
|
19
|
+
const StaveNoteTests = {
|
|
20
|
+
Start() {
|
|
21
|
+
QUnit.module('StaveNote');
|
|
22
|
+
test('Tick', ticks);
|
|
23
|
+
test('Tick - New API', ticksNewAPI);
|
|
24
|
+
test('Stem', stem);
|
|
25
|
+
test('Automatic Stem Direction', autoStem);
|
|
26
|
+
test('Stem Extension Pitch', stemExtensionPitch);
|
|
27
|
+
test('Displacement after calling setStemDirection', setStemDirectionDisplacement);
|
|
28
|
+
test('StaveLine', staveLine);
|
|
29
|
+
test('Width', width);
|
|
30
|
+
test('TickContext', tickContext);
|
|
31
|
+
const run = VexFlowTests.runTests;
|
|
32
|
+
run('StaveNote Draw - Treble', drawBasic, { clef: 'treble', octaveShift: 0, restKey: 'r/4' });
|
|
33
|
+
run('StaveNote BoundingBoxes - Treble', drawBoundingBoxes, { clef: 'treble', octaveShift: 0, restKey: 'r/4' });
|
|
34
|
+
run('StaveNote Draw - Alto', drawBasic, { clef: 'alto', octaveShift: -1, restKey: 'r/4' });
|
|
35
|
+
run('StaveNote Draw - Tenor', drawBasic, { clef: 'tenor', octaveShift: -1, restKey: 'r/3' });
|
|
36
|
+
run('StaveNote Draw - Bass', drawBasic, { clef: 'bass', octaveShift: -2, restKey: 'r/3' });
|
|
37
|
+
run('StaveNote Draw - Harmonic And Muted', drawHarmonicAndMuted);
|
|
38
|
+
run('StaveNote Draw - Slash', drawSlash);
|
|
39
|
+
run('Displacements', displacements);
|
|
40
|
+
run('StaveNote Draw - Bass 2', drawBass);
|
|
41
|
+
run('StaveNote Draw - Key Styles', drawKeyStyles);
|
|
42
|
+
run('StaveNote Draw - StaveNote Stem Styles', drawNoteStemStyles);
|
|
43
|
+
run('StaveNote Draw - StaveNote Stem Lengths', drawNoteStemLengths);
|
|
44
|
+
run('StaveNote Draw - StaveNote Flag Styles', drawNoteStylesWithFlag);
|
|
45
|
+
run('StaveNote Draw - StaveNote Styles', drawNoteStyles);
|
|
46
|
+
run('Stave, Ledger Line, Beam, Stem and Flag Styles', drawBeamStyles);
|
|
47
|
+
run('Flag and Dot Placement - Stem Up', dotsAndFlagsStemUp);
|
|
48
|
+
run('Flag and Dots Placement - Stem Down', dotsAndFlagsStemDown);
|
|
49
|
+
run('Beam and Dot Placement - Stem Up', dotsAndBeamsUp);
|
|
50
|
+
run('Beam and Dot Placement - Stem Down', dotsAndBeamsDown);
|
|
51
|
+
run('Note Heads Placement - Simple', noteHeadsSimple);
|
|
52
|
+
run('Center Aligned Note', centerAlignedRest);
|
|
53
|
+
run('Center Aligned Note with Articulation', centerAlignedRestFermata);
|
|
54
|
+
run('Center Aligned Note with Annotation', centerAlignedRestAnnotation);
|
|
55
|
+
run('Center Aligned Note - Multi Voice', centerAlignedMultiVoice);
|
|
56
|
+
run('Center Aligned Note with Multiple Modifiers', centerAlignedNoteMultiModifiers);
|
|
57
|
+
VexFlowTests.runSVGTest('Interactive Mouseover StaveNote', drawBasic, {
|
|
58
|
+
clef: 'treble',
|
|
59
|
+
octaveShift: 0,
|
|
60
|
+
restKey: 'r/4',
|
|
61
|
+
ui: true,
|
|
62
|
+
});
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
const staveNote = (struct) => new StaveNote(struct);
|
|
66
|
+
function draw(note, stave, context, x, drawBoundingBox = false, addModifierContext = true) {
|
|
67
|
+
note.setStave(stave);
|
|
68
|
+
if (addModifierContext) {
|
|
69
|
+
note.addToModifierContext(new ModifierContext());
|
|
70
|
+
}
|
|
71
|
+
new TickContext().addTickable(note).preFormat().setX(x);
|
|
72
|
+
note.setContext(context).draw();
|
|
73
|
+
if (drawBoundingBox) {
|
|
74
|
+
const bb = note.getBoundingBox();
|
|
75
|
+
context.rect(bb.getX(), bb.getY(), bb.getW(), bb.getH());
|
|
76
|
+
context.stroke();
|
|
77
|
+
}
|
|
78
|
+
return note;
|
|
79
|
+
}
|
|
80
|
+
function ticks() {
|
|
81
|
+
const BEAT = (1 * Flow.RESOLUTION) / 4;
|
|
82
|
+
const tickTests = {
|
|
83
|
+
'Breve note': ['1/2', 8.0, 'n'],
|
|
84
|
+
'Whole note': ['w', 4.0, 'n'],
|
|
85
|
+
'Quarter note': ['q', 1.0, 'n'],
|
|
86
|
+
'Dotted half note': ['hd', 3.0, 'n'],
|
|
87
|
+
'Doubled-dotted half note': ['hdd', 3.5, 'n'],
|
|
88
|
+
'Triple-dotted half note': ['hddd', 3.75, 'n'],
|
|
89
|
+
'Dotted half rest': ['hdr', 3.0, 'r'],
|
|
90
|
+
'Double-dotted half rest': ['hddr', 3.5, 'r'],
|
|
91
|
+
'Triple-dotted half rest': ['hdddr', 3.75, 'r'],
|
|
92
|
+
'Dotted harmonic quarter note': ['qdh', 1.5, 'h'],
|
|
93
|
+
'Double-dotted harmonic quarter note': ['qddh', 1.75, 'h'],
|
|
94
|
+
'Triple-dotted harmonic quarter note': ['qdddh', 1.875, 'h'],
|
|
95
|
+
'Dotted muted 8th note': ['8dm', 0.75, 'm'],
|
|
96
|
+
'Double-dotted muted 8th note': ['8ddm', 0.875, 'm'],
|
|
97
|
+
'Triple-dotted muted 8th note': ['8dddm', 0.9375, 'm'],
|
|
98
|
+
};
|
|
99
|
+
Object.keys(tickTests).forEach((testName) => {
|
|
100
|
+
const testData = tickTests[testName];
|
|
101
|
+
const durationString = testData[0];
|
|
102
|
+
const expectedBeats = testData[1];
|
|
103
|
+
const expectedNoteType = testData[2];
|
|
104
|
+
const note = new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: durationString });
|
|
105
|
+
equal(note.getTicks().value(), BEAT * expectedBeats, testName + ' must have ' + expectedBeats + ' beats');
|
|
106
|
+
equal(note.getNoteType(), expectedNoteType, 'Note type must be ' + expectedNoteType);
|
|
107
|
+
});
|
|
108
|
+
throws(() => new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: '8.7dddm' }), /BadArguments/, "Invalid note duration '8.7' throws BadArguments exception");
|
|
109
|
+
throws(() => new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: '2Z' }), /BadArguments/, "Invalid note type 'Z' throws BadArguments exception");
|
|
110
|
+
throws(() => new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: '2dddZ' }), /BadArguments/, "Invalid note type 'Z' throws BadArguments exception");
|
|
111
|
+
}
|
|
112
|
+
function ticksNewAPI() {
|
|
113
|
+
const BEAT = (1 * Flow.RESOLUTION) / 4;
|
|
114
|
+
const tickTests = {
|
|
115
|
+
'Breve note': [{ duration: '1/2' }, 8.0, 'n'],
|
|
116
|
+
'Whole note': [{ duration: 'w' }, 4.0, 'n'],
|
|
117
|
+
'Quarter note': [{ duration: 'q' }, 1.0, 'n'],
|
|
118
|
+
'Dotted half note': [{ duration: 'h', dots: 1 }, 3.0, 'n'],
|
|
119
|
+
'Doubled-dotted half note': [{ duration: 'h', dots: 2 }, 3.5, 'n'],
|
|
120
|
+
'Triple-dotted half note': [{ duration: 'h', dots: 3 }, 3.75, 'n'],
|
|
121
|
+
'Dotted half rest': [{ duration: 'h', dots: 1, type: 'r' }, 3.0, 'r'],
|
|
122
|
+
'Double-dotted half rest': [{ duration: 'h', dots: 2, type: 'r' }, 3.5, 'r'],
|
|
123
|
+
'Triple-dotted half rest': [{ duration: 'h', dots: 3, type: 'r' }, 3.75, 'r'],
|
|
124
|
+
'Dotted harmonic quarter note': [{ duration: 'q', dots: 1, type: 'h' }, 1.5, 'h'],
|
|
125
|
+
'Double-dotted harmonic quarter note': [{ duration: 'q', dots: 2, type: 'h' }, 1.75, 'h'],
|
|
126
|
+
'Triple-dotted harmonic quarter note': [{ duration: 'q', dots: 3, type: 'h' }, 1.875, 'h'],
|
|
127
|
+
'Dotted muted 8th note': [{ duration: '8', dots: 1, type: 'm' }, 0.75, 'm'],
|
|
128
|
+
'Double-dotted muted 8th note': [{ duration: '8', dots: 2, type: 'm' }, 0.875, 'm'],
|
|
129
|
+
'Triple-dotted muted 8th note': [{ duration: '8', dots: 3, type: 'm' }, 0.9375, 'm'],
|
|
130
|
+
};
|
|
131
|
+
Object.keys(tickTests).forEach(function (testName) {
|
|
132
|
+
const testData = tickTests[testName];
|
|
133
|
+
const noteData = testData[0];
|
|
134
|
+
const expectedBeats = testData[1];
|
|
135
|
+
const expectedNoteType = testData[2];
|
|
136
|
+
noteData.keys = ['c/4', 'e/4', 'g/4'];
|
|
137
|
+
const note = new StaveNote(noteData);
|
|
138
|
+
equal(note.getTicks().value(), BEAT * expectedBeats, testName + ' must have ' + expectedBeats + ' beats');
|
|
139
|
+
equal(note.getNoteType(), expectedNoteType, 'Note type must be ' + expectedNoteType);
|
|
140
|
+
});
|
|
141
|
+
throws(() => new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: '8.7dddm' }), /BadArguments/, "Invalid note duration '8.7' throws BadArguments exception");
|
|
142
|
+
throws(() => new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: '2Z' }), /BadArguments/, "Invalid note type 'Z' throws BadArguments exception");
|
|
143
|
+
throws(() => new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: '2dddZ' }), /BadArguments/, "Invalid note type 'Z' throws BadArguments exception");
|
|
144
|
+
}
|
|
145
|
+
function stem() {
|
|
146
|
+
const note = new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: 'w' });
|
|
147
|
+
equal(note.getStemDirection(), Stem.UP, 'Default note has UP stem');
|
|
148
|
+
}
|
|
149
|
+
function autoStem() {
|
|
150
|
+
const testData = [
|
|
151
|
+
[['c/5', 'e/5', 'g/5'], Stem.DOWN],
|
|
152
|
+
[['e/4', 'g/4', 'c/5'], Stem.UP],
|
|
153
|
+
[['c/5'], Stem.DOWN],
|
|
154
|
+
[['a/4', 'e/5', 'g/5'], Stem.DOWN],
|
|
155
|
+
[['b/4'], Stem.DOWN],
|
|
156
|
+
];
|
|
157
|
+
testData.forEach((td) => {
|
|
158
|
+
const keys = td[0];
|
|
159
|
+
const expectedStemDirection = td[1];
|
|
160
|
+
const note = new StaveNote({ keys: keys, auto_stem: true, duration: '8' });
|
|
161
|
+
equal(note.getStemDirection(), expectedStemDirection, 'Stem must be ' + (expectedStemDirection === Stem.UP ? 'up' : 'down'));
|
|
162
|
+
});
|
|
163
|
+
}
|
|
164
|
+
function stemExtensionPitch() {
|
|
165
|
+
const testData = [
|
|
166
|
+
[['c/5', 'e/5', 'g/5'], 0, 0],
|
|
167
|
+
[['e/4', 'g/4', 'c/5'], 0, 0],
|
|
168
|
+
[['c/5'], 0, 0],
|
|
169
|
+
[['f/3'], 15, 0],
|
|
170
|
+
[['f/3'], 15, Stem.UP],
|
|
171
|
+
[['f/3'], 0, Stem.DOWN],
|
|
172
|
+
[['f/3', 'e/5'], 0, 0],
|
|
173
|
+
[['g/6'], 25, 0],
|
|
174
|
+
[['g/6'], 25, Stem.DOWN],
|
|
175
|
+
[['g/6'], 0, Stem.UP],
|
|
176
|
+
];
|
|
177
|
+
testData.forEach((td) => {
|
|
178
|
+
const keys = td[0];
|
|
179
|
+
const expectedStemExtension = td[1];
|
|
180
|
+
const overrideStemDirection = td[2];
|
|
181
|
+
let note;
|
|
182
|
+
if (overrideStemDirection === 0) {
|
|
183
|
+
note = new StaveNote({ keys: keys, auto_stem: true, duration: '4' });
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
note = new StaveNote({ keys: keys, duration: '4', stem_direction: overrideStemDirection });
|
|
187
|
+
}
|
|
188
|
+
equal(note.getStemExtension(), expectedStemExtension, 'For ' + keys.toString() + ' StemExtension must be ' + expectedStemExtension);
|
|
189
|
+
const stave = new Stave(10, 10, 300, { spacing_between_lines_px: 20 });
|
|
190
|
+
note.setStave(stave);
|
|
191
|
+
equal(note.getStemExtension(), expectedStemExtension * 2, 'For wide staff ' + keys.toString() + ' StemExtension must be ' + expectedStemExtension * 2);
|
|
192
|
+
});
|
|
193
|
+
}
|
|
194
|
+
function setStemDirectionDisplacement() {
|
|
195
|
+
function getDisplacements(note) {
|
|
196
|
+
return note.noteHeads.map((noteHead) => noteHead.isDisplaced());
|
|
197
|
+
}
|
|
198
|
+
const stemUpDisplacements = [false, true, false];
|
|
199
|
+
const stemDownDisplacements = [true, false, false];
|
|
200
|
+
const note = new StaveNote({ keys: ['c/5', 'd/5', 'g/5'], stem_direction: Stem.UP, duration: '4' });
|
|
201
|
+
deepEqual(getDisplacements(note), stemUpDisplacements);
|
|
202
|
+
note.setStemDirection(Stem.DOWN);
|
|
203
|
+
deepEqual(getDisplacements(note), stemDownDisplacements);
|
|
204
|
+
note.setStemDirection(Stem.UP);
|
|
205
|
+
deepEqual(getDisplacements(note), stemUpDisplacements);
|
|
206
|
+
}
|
|
207
|
+
function staveLine() {
|
|
208
|
+
const stave = new Stave(10, 10, 300);
|
|
209
|
+
const note = new StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: 'w' });
|
|
210
|
+
note.setStave(stave);
|
|
211
|
+
const props = note.getKeyProps();
|
|
212
|
+
equal(props[0].line, 0, 'C/4 on line 0');
|
|
213
|
+
equal(props[1].line, 1, 'E/4 on line 1');
|
|
214
|
+
equal(props[2].line, 2.5, 'A/4 on line 2.5');
|
|
215
|
+
const ys = note.getYs();
|
|
216
|
+
equal(ys.length, 3, 'Chord should be rendered on three lines');
|
|
217
|
+
equal(ys[0], 100, 'Line for C/4');
|
|
218
|
+
equal(ys[1], 90, 'Line for E/4');
|
|
219
|
+
equal(ys[2], 75, 'Line for A/4');
|
|
220
|
+
}
|
|
221
|
+
function width() {
|
|
222
|
+
const note = new StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: 'w' });
|
|
223
|
+
throws(() => note.getWidth(), /UnformattedNote/, 'Unformatted note should have no width');
|
|
224
|
+
}
|
|
225
|
+
function tickContext() {
|
|
226
|
+
const stave = new Stave(10, 10, 400);
|
|
227
|
+
const note = new StaveNote({ keys: ['c/4', 'e/4', 'a/4'], duration: 'w' }).setStave(stave);
|
|
228
|
+
new TickContext().addTickable(note).preFormat().setX(10).setPadding(0);
|
|
229
|
+
expect(0);
|
|
230
|
+
}
|
|
231
|
+
function drawBasic(options, contextBuilder) {
|
|
232
|
+
const clef = options.params.clef;
|
|
233
|
+
const octaveShift = options.params.octaveShift;
|
|
234
|
+
const restKey = options.params.restKey;
|
|
235
|
+
const ctx = contextBuilder(options.elementId, 700, 180);
|
|
236
|
+
const stave = new Stave(10, 30, 750);
|
|
237
|
+
stave.setContext(ctx);
|
|
238
|
+
stave.addClef(clef);
|
|
239
|
+
stave.draw();
|
|
240
|
+
const lowerKeys = ['c/', 'e/', 'a/'];
|
|
241
|
+
const higherKeys = ['c/', 'e/', 'a/'];
|
|
242
|
+
for (let k = 0; k < lowerKeys.length; k++) {
|
|
243
|
+
lowerKeys[k] = lowerKeys[k] + (4 + octaveShift);
|
|
244
|
+
higherKeys[k] = higherKeys[k] + (5 + octaveShift);
|
|
245
|
+
}
|
|
246
|
+
const restKeys = [restKey];
|
|
247
|
+
const noteStructs = [
|
|
248
|
+
{ clef: clef, keys: higherKeys, duration: '1/2' },
|
|
249
|
+
{ clef: clef, keys: lowerKeys, duration: 'w' },
|
|
250
|
+
{ clef: clef, keys: higherKeys, duration: 'h' },
|
|
251
|
+
{ clef: clef, keys: lowerKeys, duration: 'q' },
|
|
252
|
+
{ clef: clef, keys: higherKeys, duration: '8' },
|
|
253
|
+
{ clef: clef, keys: lowerKeys, duration: '16' },
|
|
254
|
+
{ clef: clef, keys: higherKeys, duration: '32' },
|
|
255
|
+
{ clef: clef, keys: higherKeys, duration: '64' },
|
|
256
|
+
{ clef: clef, keys: higherKeys, duration: '128' },
|
|
257
|
+
{ clef: clef, keys: lowerKeys, duration: '1/2', stem_direction: Stem.DOWN },
|
|
258
|
+
{ clef: clef, keys: lowerKeys, duration: 'w', stem_direction: Stem.DOWN },
|
|
259
|
+
{ clef: clef, keys: lowerKeys, duration: 'h', stem_direction: Stem.DOWN },
|
|
260
|
+
{ clef: clef, keys: lowerKeys, duration: 'q', stem_direction: Stem.DOWN },
|
|
261
|
+
{ clef: clef, keys: lowerKeys, duration: '8', stem_direction: Stem.DOWN },
|
|
262
|
+
{ clef: clef, keys: lowerKeys, duration: '16', stem_direction: Stem.DOWN },
|
|
263
|
+
{ clef: clef, keys: lowerKeys, duration: '32', stem_direction: Stem.DOWN },
|
|
264
|
+
{ clef: clef, keys: lowerKeys, duration: '64', stem_direction: Stem.DOWN },
|
|
265
|
+
{ clef: clef, keys: lowerKeys, duration: '128', stem_direction: Stem.DOWN },
|
|
266
|
+
{ clef: clef, keys: restKeys, duration: '1/2r' },
|
|
267
|
+
{ clef: clef, keys: restKeys, duration: 'wr' },
|
|
268
|
+
{ clef: clef, keys: restKeys, duration: 'hr' },
|
|
269
|
+
{ clef: clef, keys: restKeys, duration: 'qr' },
|
|
270
|
+
{ clef: clef, keys: restKeys, duration: '8r' },
|
|
271
|
+
{ clef: clef, keys: restKeys, duration: '16r' },
|
|
272
|
+
{ clef: clef, keys: restKeys, duration: '32r' },
|
|
273
|
+
{ clef: clef, keys: restKeys, duration: '64r' },
|
|
274
|
+
{ clef: clef, keys: restKeys, duration: '128r' },
|
|
275
|
+
{ keys: ['x/4'], duration: 'h' },
|
|
276
|
+
];
|
|
277
|
+
expect(noteStructs.length * 2);
|
|
278
|
+
const colorDescendants = (parentItem, color) => () => parentItem.querySelectorAll('*').forEach((child) => {
|
|
279
|
+
child.setAttribute('fill', color);
|
|
280
|
+
child.setAttribute('stroke', color);
|
|
281
|
+
});
|
|
282
|
+
for (let i = 0; i < noteStructs.length; ++i) {
|
|
283
|
+
const note = draw(staveNote(noteStructs[i]), stave, ctx, (i + 1) * 25);
|
|
284
|
+
if (options.params.ui) {
|
|
285
|
+
const item = note.getAttribute('el');
|
|
286
|
+
item.addEventListener('mouseover', colorDescendants(item, 'green'), false);
|
|
287
|
+
item.addEventListener('mouseout', colorDescendants(item, 'black'), false);
|
|
288
|
+
}
|
|
289
|
+
ok(note.getX() > 0, 'Note ' + i + ' has X value');
|
|
290
|
+
ok(note.getYs().length > 0, 'Note ' + i + ' has Y values');
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
function drawBoundingBoxes(options, contextBuilder) {
|
|
294
|
+
const clef = options.params.clef;
|
|
295
|
+
const octaveShift = options.params.octaveShift;
|
|
296
|
+
const restKey = options.params.restKey;
|
|
297
|
+
const ctx = contextBuilder(options.elementId, 700, 180);
|
|
298
|
+
const stave = new Stave(10, 30, 750);
|
|
299
|
+
stave.setContext(ctx);
|
|
300
|
+
stave.addClef(clef);
|
|
301
|
+
stave.draw();
|
|
302
|
+
const lowerKeys = ['c/', 'e/', 'a/'];
|
|
303
|
+
const higherKeys = ['c/', 'e/', 'a/'];
|
|
304
|
+
for (let k = 0; k < lowerKeys.length; k++) {
|
|
305
|
+
lowerKeys[k] = lowerKeys[k] + (4 + octaveShift);
|
|
306
|
+
higherKeys[k] = higherKeys[k] + (5 + octaveShift);
|
|
307
|
+
}
|
|
308
|
+
const restKeys = [restKey];
|
|
309
|
+
const noteStructs = [
|
|
310
|
+
{ clef: clef, keys: higherKeys, duration: '1/2' },
|
|
311
|
+
{ clef: clef, keys: lowerKeys, duration: 'w' },
|
|
312
|
+
{ clef: clef, keys: higherKeys, duration: 'h' },
|
|
313
|
+
{ clef: clef, keys: lowerKeys, duration: 'q' },
|
|
314
|
+
{ clef: clef, keys: higherKeys, duration: '8' },
|
|
315
|
+
{ clef: clef, keys: lowerKeys, duration: '16' },
|
|
316
|
+
{ clef: clef, keys: higherKeys, duration: '32' },
|
|
317
|
+
{ clef: clef, keys: higherKeys, duration: '64' },
|
|
318
|
+
{ clef: clef, keys: higherKeys, duration: '128' },
|
|
319
|
+
{ clef: clef, keys: lowerKeys, duration: '1/2', stem_direction: Stem.DOWN },
|
|
320
|
+
{ clef: clef, keys: lowerKeys, duration: 'w', stem_direction: Stem.DOWN },
|
|
321
|
+
{ clef: clef, keys: lowerKeys, duration: 'h', stem_direction: Stem.DOWN },
|
|
322
|
+
{ clef: clef, keys: lowerKeys, duration: 'q', stem_direction: Stem.DOWN },
|
|
323
|
+
{ clef: clef, keys: lowerKeys, duration: '8', stem_direction: Stem.DOWN },
|
|
324
|
+
{ clef: clef, keys: lowerKeys, duration: '16', stem_direction: Stem.DOWN },
|
|
325
|
+
{ clef: clef, keys: lowerKeys, duration: '32', stem_direction: Stem.DOWN },
|
|
326
|
+
{ clef: clef, keys: lowerKeys, duration: '64', stem_direction: Stem.DOWN },
|
|
327
|
+
{ clef: clef, keys: lowerKeys, duration: '128' },
|
|
328
|
+
{ clef: clef, keys: restKeys, duration: '1/2r' },
|
|
329
|
+
{ clef: clef, keys: restKeys, duration: 'wr' },
|
|
330
|
+
{ clef: clef, keys: restKeys, duration: 'hr' },
|
|
331
|
+
{ clef: clef, keys: restKeys, duration: 'qr' },
|
|
332
|
+
{ clef: clef, keys: restKeys, duration: '8r' },
|
|
333
|
+
{ clef: clef, keys: restKeys, duration: '16r' },
|
|
334
|
+
{ clef: clef, keys: restKeys, duration: '32r' },
|
|
335
|
+
{ clef: clef, keys: restKeys, duration: '64r' },
|
|
336
|
+
{ clef: clef, keys: restKeys, duration: '128r' },
|
|
337
|
+
{ keys: ['x/4'], duration: 'h' },
|
|
338
|
+
];
|
|
339
|
+
expect(noteStructs.length * 2);
|
|
340
|
+
for (let i = 0; i < noteStructs.length; ++i) {
|
|
341
|
+
const note = draw(staveNote(noteStructs[i]), stave, ctx, (i + 1) * 25, true, false);
|
|
342
|
+
ok(note.getX() > 0, 'Note ' + i + ' has X value');
|
|
343
|
+
ok(note.getYs().length > 0, 'Note ' + i + ' has Y values');
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
function drawBass(options, contextBuilder) {
|
|
347
|
+
expect(40);
|
|
348
|
+
const ctx = contextBuilder(options.elementId, 600, 280);
|
|
349
|
+
const stave = new Stave(10, 10, 650);
|
|
350
|
+
stave.setContext(ctx);
|
|
351
|
+
stave.addClef('bass');
|
|
352
|
+
stave.draw();
|
|
353
|
+
const noteStructs = [
|
|
354
|
+
{ clef: 'bass', keys: ['c/3', 'e/3', 'a/3'], duration: '1/2' },
|
|
355
|
+
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: 'w' },
|
|
356
|
+
{ clef: 'bass', keys: ['c/3', 'e/3', 'a/3'], duration: 'h' },
|
|
357
|
+
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: 'q' },
|
|
358
|
+
{ clef: 'bass', keys: ['c/3', 'e/3', 'a/3'], duration: '8' },
|
|
359
|
+
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: '16' },
|
|
360
|
+
{ clef: 'bass', keys: ['c/3', 'e/3', 'a/3'], duration: '32' },
|
|
361
|
+
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: 'h', stem_direction: Stem.DOWN },
|
|
362
|
+
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: 'q', stem_direction: Stem.DOWN },
|
|
363
|
+
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: '8', stem_direction: Stem.DOWN },
|
|
364
|
+
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: '16', stem_direction: Stem.DOWN },
|
|
365
|
+
{ clef: 'bass', keys: ['c/2', 'e/2', 'a/2'], duration: '32', stem_direction: Stem.DOWN },
|
|
366
|
+
{ keys: ['r/4'], duration: '1/2r' },
|
|
367
|
+
{ keys: ['r/4'], duration: 'wr' },
|
|
368
|
+
{ keys: ['r/4'], duration: 'hr' },
|
|
369
|
+
{ keys: ['r/4'], duration: 'qr' },
|
|
370
|
+
{ keys: ['r/4'], duration: '8r' },
|
|
371
|
+
{ keys: ['r/4'], duration: '16r' },
|
|
372
|
+
{ keys: ['r/4'], duration: '32r' },
|
|
373
|
+
{ keys: ['x/4'], duration: 'h' },
|
|
374
|
+
];
|
|
375
|
+
for (let i = 0; i < noteStructs.length; ++i) {
|
|
376
|
+
const note = draw(staveNote(noteStructs[i]), stave, ctx, (i + 1) * 25);
|
|
377
|
+
ok(note.getX() > 0, 'Note ' + i + ' has X value');
|
|
378
|
+
ok(note.getYs().length > 0, 'Note ' + i + ' has Y values');
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
function displacements(options, contextBuilder) {
|
|
382
|
+
const ctx = contextBuilder(options.elementId, 700, 155);
|
|
383
|
+
ctx.scale(0.9, 0.9);
|
|
384
|
+
ctx.fillStyle = '#221';
|
|
385
|
+
ctx.strokeStyle = '#221';
|
|
386
|
+
const stave = new Stave(10, 10, 675);
|
|
387
|
+
stave.setContext(ctx);
|
|
388
|
+
stave.draw();
|
|
389
|
+
const noteStructs = [
|
|
390
|
+
{ keys: ['g/3', 'a/3', 'c/4', 'd/4', 'e/4'], duration: '1/2' },
|
|
391
|
+
{ keys: ['g/3', 'a/3', 'c/4', 'd/4', 'e/4'], duration: 'w' },
|
|
392
|
+
{ keys: ['d/4', 'e/4', 'f/4'], duration: 'h' },
|
|
393
|
+
{ keys: ['f/4', 'g/4', 'a/4', 'b/4'], duration: 'q' },
|
|
394
|
+
{ keys: ['e/3', 'b/3', 'c/4', 'e/4', 'f/4', 'g/5', 'a/5'], duration: '8' },
|
|
395
|
+
{ keys: ['a/3', 'c/4', 'e/4', 'g/4', 'a/4', 'b/4'], duration: '16' },
|
|
396
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '32' },
|
|
397
|
+
{ keys: ['c/4', 'e/4', 'a/4', 'a/4'], duration: '64' },
|
|
398
|
+
{ keys: ['g/3', 'c/4', 'd/4', 'e/4'], duration: 'h', stem_direction: Stem.DOWN },
|
|
399
|
+
{ keys: ['d/4', 'e/4', 'f/4'], duration: 'q', stem_direction: Stem.DOWN },
|
|
400
|
+
{ keys: ['f/4', 'g/4', 'a/4', 'b/4'], duration: '8', stem_direction: Stem.DOWN },
|
|
401
|
+
{ keys: ['c/4', 'd/4', 'e/4', 'f/4', 'g/4', 'a/4'], duration: '16', stem_direction: Stem.DOWN },
|
|
402
|
+
{ keys: ['b/3', 'c/4', 'e/4', 'a/4', 'b/5', 'c/6', 'e/6'], duration: '32', stem_direction: Stem.DOWN },
|
|
403
|
+
{
|
|
404
|
+
keys: ['b/3', 'c/4', 'e/4', 'a/4', 'b/5', 'c/6', 'e/6', 'e/6'],
|
|
405
|
+
duration: '64',
|
|
406
|
+
stem_direction: Stem.DOWN,
|
|
407
|
+
},
|
|
408
|
+
];
|
|
409
|
+
expect(noteStructs.length * 2);
|
|
410
|
+
for (let i = 0; i < noteStructs.length; ++i) {
|
|
411
|
+
const note = draw(staveNote(noteStructs[i]), stave, ctx, (i + 1) * 45);
|
|
412
|
+
ok(note.getX() > 0, 'Note ' + i + ' has X value');
|
|
413
|
+
ok(note.getYs().length > 0, 'Note ' + i + ' has Y values');
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
function drawHarmonicAndMuted(options, contextBuilder) {
|
|
417
|
+
const ctx = contextBuilder(options.elementId, 1000, 180);
|
|
418
|
+
const stave = new Stave(10, 10, 950);
|
|
419
|
+
stave.setContext(ctx);
|
|
420
|
+
stave.draw();
|
|
421
|
+
const noteStructs = [
|
|
422
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '1/2h' },
|
|
423
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'wh' },
|
|
424
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'hh' },
|
|
425
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'qh' },
|
|
426
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '8h' },
|
|
427
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '16h' },
|
|
428
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '32h' },
|
|
429
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '64h' },
|
|
430
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '128h' },
|
|
431
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '1/2h', stem_direction: Stem.DOWN },
|
|
432
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'wh', stem_direction: Stem.DOWN },
|
|
433
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'hh', stem_direction: Stem.DOWN },
|
|
434
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'qh', stem_direction: Stem.DOWN },
|
|
435
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '8h', stem_direction: Stem.DOWN },
|
|
436
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '16h', stem_direction: Stem.DOWN },
|
|
437
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '32h', stem_direction: Stem.DOWN },
|
|
438
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '64h', stem_direction: Stem.DOWN },
|
|
439
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '128h', stem_direction: Stem.DOWN },
|
|
440
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '1/2m' },
|
|
441
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'wm' },
|
|
442
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'hm' },
|
|
443
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'qm' },
|
|
444
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '8m' },
|
|
445
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '16m' },
|
|
446
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '32m' },
|
|
447
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '64m' },
|
|
448
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '128m' },
|
|
449
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '1/2m', stem_direction: Stem.DOWN },
|
|
450
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'wm', stem_direction: Stem.DOWN },
|
|
451
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'hm', stem_direction: Stem.DOWN },
|
|
452
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: 'qm', stem_direction: Stem.DOWN },
|
|
453
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '8m', stem_direction: Stem.DOWN },
|
|
454
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '16m', stem_direction: Stem.DOWN },
|
|
455
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '32m', stem_direction: Stem.DOWN },
|
|
456
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '64m', stem_direction: Stem.DOWN },
|
|
457
|
+
{ keys: ['c/4', 'e/4', 'a/4'], duration: '128m', stem_direction: Stem.DOWN },
|
|
458
|
+
];
|
|
459
|
+
expect(noteStructs.length * 2);
|
|
460
|
+
for (let i = 0; i < noteStructs.length; ++i) {
|
|
461
|
+
const note = draw(staveNote(noteStructs[i]), stave, ctx, i * 25 + 5);
|
|
462
|
+
ok(note.getX() > 0, 'Note ' + i + ' has X value');
|
|
463
|
+
ok(note.getYs().length > 0, 'Note ' + i + ' has Y values');
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
function drawSlash(options, contextBuilder) {
|
|
467
|
+
const ctx = contextBuilder(options.elementId, 700, 180);
|
|
468
|
+
const stave = new Stave(10, 10, 650);
|
|
469
|
+
stave.setContext(ctx);
|
|
470
|
+
stave.draw();
|
|
471
|
+
const notes = [
|
|
472
|
+
{ keys: ['b/4'], duration: '1/2s', stem_direction: Stem.DOWN },
|
|
473
|
+
{ keys: ['b/4'], duration: 'ws', stem_direction: Stem.DOWN },
|
|
474
|
+
{ keys: ['b/4'], duration: 'hs', stem_direction: Stem.DOWN },
|
|
475
|
+
{ keys: ['b/4'], duration: 'qs', stem_direction: Stem.DOWN },
|
|
476
|
+
{ keys: ['b/4'], duration: '8s', stem_direction: Stem.DOWN },
|
|
477
|
+
{ keys: ['b/4'], duration: '16s', stem_direction: Stem.DOWN },
|
|
478
|
+
{ keys: ['b/4'], duration: '32s', stem_direction: Stem.DOWN },
|
|
479
|
+
{ keys: ['b/4'], duration: '64s', stem_direction: Stem.DOWN },
|
|
480
|
+
{ keys: ['b/4'], duration: '128s', stem_direction: Stem.DOWN },
|
|
481
|
+
{ keys: ['b/4'], duration: '1/2s', stem_direction: Stem.UP },
|
|
482
|
+
{ keys: ['b/4'], duration: 'ws', stem_direction: Stem.UP },
|
|
483
|
+
{ keys: ['b/4'], duration: 'hs', stem_direction: Stem.UP },
|
|
484
|
+
{ keys: ['b/4'], duration: 'qs', stem_direction: Stem.UP },
|
|
485
|
+
{ keys: ['b/4'], duration: '8s', stem_direction: Stem.UP },
|
|
486
|
+
{ keys: ['b/4'], duration: '16s', stem_direction: Stem.UP },
|
|
487
|
+
{ keys: ['b/4'], duration: '32s', stem_direction: Stem.UP },
|
|
488
|
+
{ keys: ['b/4'], duration: '64s', stem_direction: Stem.UP },
|
|
489
|
+
{ keys: ['b/4'], duration: '128s', stem_direction: Stem.UP },
|
|
490
|
+
{ keys: ['b/4'], duration: '8s', stem_direction: Stem.DOWN },
|
|
491
|
+
{ keys: ['b/4'], duration: '8s', stem_direction: Stem.DOWN },
|
|
492
|
+
{ keys: ['b/4'], duration: '8s', stem_direction: Stem.UP },
|
|
493
|
+
{ keys: ['b/4'], duration: '8s', stem_direction: Stem.UP },
|
|
494
|
+
];
|
|
495
|
+
const stave_notes = notes.map((struct) => new StaveNote(struct));
|
|
496
|
+
const beam1 = new Beam([stave_notes[16], stave_notes[17]]);
|
|
497
|
+
const beam2 = new Beam([stave_notes[18], stave_notes[19]]);
|
|
498
|
+
Formatter.FormatAndDraw(ctx, stave, stave_notes, false);
|
|
499
|
+
beam1.setContext(ctx).draw();
|
|
500
|
+
beam2.setContext(ctx).draw();
|
|
501
|
+
ok('Slash Note Heads');
|
|
502
|
+
}
|
|
503
|
+
function drawKeyStyles(options, contextBuilder) {
|
|
504
|
+
const ctx = contextBuilder(options.elementId, 300, 280);
|
|
505
|
+
ctx.scale(3, 3);
|
|
506
|
+
const stave = new Stave(10, 0, 100);
|
|
507
|
+
const note = new StaveNote({ keys: ['g/4', 'bb/4', 'd/5'], duration: 'q' })
|
|
508
|
+
.setStave(stave)
|
|
509
|
+
.addModifier(new Accidental('b'), 1)
|
|
510
|
+
.setKeyStyle(1, { shadowBlur: 2, shadowColor: 'blue', fillStyle: 'blue' });
|
|
511
|
+
new TickContext().addTickable(note).preFormat().setX(25);
|
|
512
|
+
stave.setContext(ctx).draw();
|
|
513
|
+
note.setContext(ctx).draw();
|
|
514
|
+
ok(note.getX() > 0, 'Note has X value');
|
|
515
|
+
ok(note.getYs().length > 0, 'Note has Y values');
|
|
516
|
+
}
|
|
517
|
+
function drawNoteStyles(options, contextBuilder) {
|
|
518
|
+
const ctx = contextBuilder(options.elementId, 300, 280);
|
|
519
|
+
const stave = new Stave(10, 0, 100);
|
|
520
|
+
ctx.scale(3, 3);
|
|
521
|
+
const note = new StaveNote({ keys: ['g/4', 'bb/4', 'd/5'], duration: '8' })
|
|
522
|
+
.setStave(stave)
|
|
523
|
+
.addModifier(new Accidental('b'), 1);
|
|
524
|
+
note.setStyle({ shadowBlur: 2, shadowColor: 'blue', fillStyle: 'blue', strokeStyle: 'blue' });
|
|
525
|
+
new TickContext().addTickable(note).preFormat().setX(25);
|
|
526
|
+
stave.setContext(ctx).draw();
|
|
527
|
+
note.setContext(ctx).draw();
|
|
528
|
+
ok(note.getX() > 0, 'Note has X value');
|
|
529
|
+
ok(note.getYs().length > 0, 'Note has Y values');
|
|
530
|
+
}
|
|
531
|
+
function drawNoteStemStyles(options, contextBuilder) {
|
|
532
|
+
const ctx = contextBuilder(options.elementId, 300, 280);
|
|
533
|
+
const stave = new Stave(10, 0, 100);
|
|
534
|
+
ctx.scale(3, 3);
|
|
535
|
+
const note = new StaveNote({ keys: ['g/4', 'bb/4', 'd/5'], duration: 'q' })
|
|
536
|
+
.setStave(stave)
|
|
537
|
+
.addModifier(new Accidental('b'), 1);
|
|
538
|
+
note.setStemStyle({ shadowBlur: 2, shadowColor: 'blue', fillStyle: 'blue', strokeStyle: 'blue' });
|
|
539
|
+
new TickContext().addTickable(note).preFormat().setX(25);
|
|
540
|
+
stave.setContext(ctx).draw();
|
|
541
|
+
note.setContext(ctx).draw();
|
|
542
|
+
ok('Note Stem Style');
|
|
543
|
+
}
|
|
544
|
+
function drawNoteStemLengths(options, contextBuilder) {
|
|
545
|
+
const ctx = contextBuilder(options.elementId, 975, 150);
|
|
546
|
+
const stave = new Stave(10, 10, 975);
|
|
547
|
+
stave.setContext(ctx).draw();
|
|
548
|
+
const keys = [
|
|
549
|
+
'e/3',
|
|
550
|
+
'f/3',
|
|
551
|
+
'g/3',
|
|
552
|
+
'a/3',
|
|
553
|
+
'b/3',
|
|
554
|
+
'c/4',
|
|
555
|
+
'd/4',
|
|
556
|
+
'e/4',
|
|
557
|
+
'f/4',
|
|
558
|
+
'g/4',
|
|
559
|
+
'f/5',
|
|
560
|
+
'g/5',
|
|
561
|
+
'a/5',
|
|
562
|
+
'b/5',
|
|
563
|
+
'c/6',
|
|
564
|
+
'd/6',
|
|
565
|
+
'e/6',
|
|
566
|
+
'f/6',
|
|
567
|
+
'g/6',
|
|
568
|
+
'a/6',
|
|
569
|
+
];
|
|
570
|
+
const notes = [];
|
|
571
|
+
let note;
|
|
572
|
+
let i;
|
|
573
|
+
for (i = 0; i < keys.length; i++) {
|
|
574
|
+
let duration = 'q';
|
|
575
|
+
if (i % 2 === 1) {
|
|
576
|
+
duration = '8';
|
|
577
|
+
}
|
|
578
|
+
note = new StaveNote({ keys: [keys[i]], duration, auto_stem: true }).setStave(stave);
|
|
579
|
+
new TickContext().addTickable(note);
|
|
580
|
+
note.setContext(ctx);
|
|
581
|
+
notes.push(note);
|
|
582
|
+
}
|
|
583
|
+
const whole_keys = ['e/3', 'a/3', 'f/5', 'a/5', 'd/6', 'a/6'];
|
|
584
|
+
for (i = 0; i < whole_keys.length; i++) {
|
|
585
|
+
note = new StaveNote({ keys: [whole_keys[i]], duration: 'w' }).setStave(stave);
|
|
586
|
+
new TickContext().addTickable(note);
|
|
587
|
+
note.setContext(ctx);
|
|
588
|
+
notes.push(note);
|
|
589
|
+
}
|
|
590
|
+
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
591
|
+
ok('Note Stem Length');
|
|
592
|
+
}
|
|
593
|
+
function drawNoteStylesWithFlag(options, contextBuilder) {
|
|
594
|
+
const ctx = contextBuilder(options.elementId, 300, 280);
|
|
595
|
+
const stave = new Stave(10, 0, 100);
|
|
596
|
+
ctx.scale(3, 3);
|
|
597
|
+
const note = new StaveNote({ keys: ['g/4', 'bb/4', 'd/5'], duration: '8' })
|
|
598
|
+
.setStave(stave)
|
|
599
|
+
.addModifier(new Accidental('b'), 1);
|
|
600
|
+
note.setFlagStyle({ shadowBlur: 2, shadowColor: 'blue', fillStyle: 'blue', strokeStyle: 'blue' });
|
|
601
|
+
new TickContext().addTickable(note).preFormat().setX(25);
|
|
602
|
+
stave.setContext(ctx).draw();
|
|
603
|
+
note.setContext(ctx).draw();
|
|
604
|
+
ok(note.getX() > 0, 'Note has X value');
|
|
605
|
+
ok(note.getYs().length > 0, 'Note has Y values');
|
|
606
|
+
}
|
|
607
|
+
function drawBeamStyles(options, contextBuilder) {
|
|
608
|
+
const ctx = contextBuilder(options.elementId, 400, 160);
|
|
609
|
+
const stave = new Stave(10, 10, 380);
|
|
610
|
+
stave.setStyle({ strokeStyle: '#EEAAEE', lineWidth: 3 });
|
|
611
|
+
stave.setContext(ctx);
|
|
612
|
+
stave.draw();
|
|
613
|
+
const notes = [
|
|
614
|
+
{ keys: ['b/4'], duration: '8', stem_direction: Stem.DOWN },
|
|
615
|
+
{ keys: ['b/4'], duration: '8', stem_direction: Stem.DOWN },
|
|
616
|
+
{ keys: ['b/4'], duration: '8', stem_direction: Stem.DOWN },
|
|
617
|
+
{ keys: ['b/4'], duration: '8', stem_direction: Stem.DOWN },
|
|
618
|
+
{ keys: ['b/4'], duration: '8', stem_direction: Stem.DOWN },
|
|
619
|
+
{ keys: ['b/4'], duration: '8', stem_direction: Stem.UP },
|
|
620
|
+
{ keys: ['b/4'], duration: '8', stem_direction: Stem.UP },
|
|
621
|
+
{ keys: ['d/6'], duration: '8', stem_direction: Stem.DOWN },
|
|
622
|
+
{ keys: ['c/6', 'd/6'], duration: '8', stem_direction: Stem.DOWN },
|
|
623
|
+
{ keys: ['d/6', 'e/6'], duration: '8', stem_direction: Stem.DOWN },
|
|
624
|
+
{ keys: ['e/6', 'f/6'], duration: '8', stem_direction: Stem.DOWN },
|
|
625
|
+
];
|
|
626
|
+
const staveNotes = notes.map((note) => new StaveNote(note));
|
|
627
|
+
const beam1 = new Beam(staveNotes.slice(0, 2));
|
|
628
|
+
const beam2 = new Beam(staveNotes.slice(3, 5));
|
|
629
|
+
const beam3 = new Beam(staveNotes.slice(5, 7));
|
|
630
|
+
const beam4 = new Beam(staveNotes.slice(7, 9));
|
|
631
|
+
beam1.setStyle({ fillStyle: 'blue', strokeStyle: 'blue' });
|
|
632
|
+
staveNotes[0].setKeyStyle(0, { fillStyle: 'purple' });
|
|
633
|
+
staveNotes[0].setStemStyle({ strokeStyle: 'green' });
|
|
634
|
+
staveNotes[1].setStemStyle({ strokeStyle: 'orange' });
|
|
635
|
+
staveNotes[1].setKeyStyle(0, { fillStyle: 'darkturquoise' });
|
|
636
|
+
staveNotes[5].setStyle({ fillStyle: 'tomato', strokeStyle: 'tomato' });
|
|
637
|
+
beam3.setStyle({ shadowBlur: 4, shadowColor: 'blue' });
|
|
638
|
+
staveNotes[9].setLedgerLineStyle({ fillStyle: 'lawngreen', strokeStyle: 'lawngreen', lineWidth: 1 });
|
|
639
|
+
staveNotes[9].setFlagStyle({ fillStyle: 'orange', strokeStyle: 'orange' });
|
|
640
|
+
Formatter.FormatAndDraw(ctx, stave, staveNotes, false);
|
|
641
|
+
beam1.setContext(ctx).draw();
|
|
642
|
+
beam2.setContext(ctx).draw();
|
|
643
|
+
beam3.setContext(ctx).draw();
|
|
644
|
+
beam4.setContext(ctx).draw();
|
|
645
|
+
ok('draw beam styles');
|
|
646
|
+
}
|
|
647
|
+
function dotsAndFlagsStemUp(options, contextBuilder) {
|
|
648
|
+
const ctx = contextBuilder(options.elementId, 800, 150);
|
|
649
|
+
ctx.scale(1.0, 1.0);
|
|
650
|
+
ctx.setFillStyle('#221');
|
|
651
|
+
ctx.setStrokeStyle('#221');
|
|
652
|
+
const stave = new Stave(10, 10, 975);
|
|
653
|
+
const notes = [
|
|
654
|
+
staveNote({ keys: ['f/4'], duration: '4', stem_direction: Stem.UP }),
|
|
655
|
+
staveNote({ keys: ['f/4'], duration: '8', stem_direction: Stem.UP }),
|
|
656
|
+
staveNote({ keys: ['f/4'], duration: '16', stem_direction: Stem.UP }),
|
|
657
|
+
staveNote({ keys: ['f/4'], duration: '32', stem_direction: Stem.UP }),
|
|
658
|
+
staveNote({ keys: ['f/4'], duration: '64', stem_direction: Stem.UP }),
|
|
659
|
+
staveNote({ keys: ['f/4'], duration: '128', stem_direction: Stem.UP }),
|
|
660
|
+
staveNote({ keys: ['g/4'], duration: '4', stem_direction: Stem.UP }),
|
|
661
|
+
staveNote({ keys: ['g/4'], duration: '8', stem_direction: Stem.UP }),
|
|
662
|
+
staveNote({ keys: ['g/4'], duration: '16', stem_direction: Stem.UP }),
|
|
663
|
+
staveNote({ keys: ['g/4'], duration: '32' }),
|
|
664
|
+
staveNote({ keys: ['g/4'], duration: '64', stem_direction: Stem.UP }),
|
|
665
|
+
staveNote({ keys: ['g/4'], duration: '128', stem_direction: Stem.UP }),
|
|
666
|
+
];
|
|
667
|
+
Dot.buildAndAttach(notes, { all: true });
|
|
668
|
+
Dot.buildAndAttach([notes[5], notes[11]], { all: true });
|
|
669
|
+
stave.setContext(ctx).draw();
|
|
670
|
+
for (let i = 0; i < notes.length; ++i) {
|
|
671
|
+
draw(notes[i], stave, ctx, i * 65);
|
|
672
|
+
}
|
|
673
|
+
ok(true, 'Full Dot');
|
|
674
|
+
}
|
|
675
|
+
function dotsAndFlagsStemDown(options, contextBuilder) {
|
|
676
|
+
const ctx = contextBuilder(options.elementId, 800, 160);
|
|
677
|
+
ctx.scale(1.0, 1.0);
|
|
678
|
+
ctx.setFillStyle('#221');
|
|
679
|
+
ctx.setStrokeStyle('#221');
|
|
680
|
+
const stave = new Stave(10, 10, 975);
|
|
681
|
+
const staveNotes = [
|
|
682
|
+
staveNote({ keys: ['e/5'], duration: '4', stem_direction: Stem.DOWN }),
|
|
683
|
+
staveNote({ keys: ['e/5'], duration: '8', stem_direction: Stem.DOWN }),
|
|
684
|
+
staveNote({ keys: ['e/5'], duration: '16', stem_direction: Stem.DOWN }),
|
|
685
|
+
staveNote({ keys: ['e/5'], duration: '32', stem_direction: Stem.DOWN }),
|
|
686
|
+
staveNote({ keys: ['e/5'], duration: '64', stem_direction: Stem.DOWN }),
|
|
687
|
+
staveNote({ keys: ['e/5'], duration: '128', stem_direction: Stem.DOWN }),
|
|
688
|
+
staveNote({ keys: ['d/5'], duration: '4', stem_direction: Stem.DOWN }),
|
|
689
|
+
staveNote({ keys: ['d/5'], duration: '8', stem_direction: Stem.DOWN }),
|
|
690
|
+
staveNote({ keys: ['d/5'], duration: '16', stem_direction: Stem.DOWN }),
|
|
691
|
+
staveNote({ keys: ['d/5'], duration: '32', stem_direction: Stem.DOWN }),
|
|
692
|
+
staveNote({ keys: ['d/5'], duration: '64', stem_direction: Stem.DOWN }),
|
|
693
|
+
staveNote({ keys: ['d/5'], duration: '128', stem_direction: Stem.DOWN }),
|
|
694
|
+
];
|
|
695
|
+
Dot.buildAndAttach(staveNotes, { all: true });
|
|
696
|
+
stave.setContext(ctx).draw();
|
|
697
|
+
for (let i = 0; i < staveNotes.length; ++i) {
|
|
698
|
+
draw(staveNotes[i], stave, ctx, i * 65);
|
|
699
|
+
}
|
|
700
|
+
ok(true, 'Full Dot');
|
|
701
|
+
}
|
|
702
|
+
function dotsAndBeamsUp(options, contextBuilder) {
|
|
703
|
+
const ctx = contextBuilder(options.elementId, 800, 150);
|
|
704
|
+
ctx.scale(1.0, 1.0);
|
|
705
|
+
ctx.setFillStyle('#221');
|
|
706
|
+
ctx.setStrokeStyle('#221');
|
|
707
|
+
const stave = new Stave(10, 10, 975);
|
|
708
|
+
const staveNotes = [
|
|
709
|
+
staveNote({ keys: ['f/4'], duration: '8', stem_direction: Stem.UP }),
|
|
710
|
+
staveNote({ keys: ['f/4'], duration: '16', stem_direction: Stem.UP }),
|
|
711
|
+
staveNote({ keys: ['f/4'], duration: '32', stem_direction: Stem.UP }),
|
|
712
|
+
staveNote({ keys: ['f/4'], duration: '64', stem_direction: Stem.UP }),
|
|
713
|
+
staveNote({ keys: ['f/4'], duration: '128', stem_direction: Stem.UP }),
|
|
714
|
+
staveNote({ keys: ['g/4'], duration: '8', stem_direction: Stem.UP }),
|
|
715
|
+
staveNote({ keys: ['g/4'], duration: '16', stem_direction: Stem.UP }),
|
|
716
|
+
staveNote({ keys: ['g/4'], duration: '32' }),
|
|
717
|
+
staveNote({ keys: ['g/4'], duration: '64', stem_direction: Stem.UP }),
|
|
718
|
+
staveNote({ keys: ['g/4'], duration: '128', stem_direction: Stem.UP }),
|
|
719
|
+
];
|
|
720
|
+
Dot.buildAndAttach(staveNotes, { all: true });
|
|
721
|
+
Dot.buildAndAttach([staveNotes[4], staveNotes[9]], { all: true });
|
|
722
|
+
const beam = new Beam(staveNotes);
|
|
723
|
+
stave.setContext(ctx).draw();
|
|
724
|
+
for (let i = 0; i < staveNotes.length; ++i) {
|
|
725
|
+
draw(staveNotes[i], stave, ctx, i * 65);
|
|
726
|
+
}
|
|
727
|
+
beam.setContext(ctx).draw();
|
|
728
|
+
ok(true, 'Full Dot');
|
|
729
|
+
}
|
|
730
|
+
function dotsAndBeamsDown(options, contextBuilder) {
|
|
731
|
+
const ctx = contextBuilder(options.elementId, 800, 160);
|
|
732
|
+
ctx.scale(1.0, 1.0);
|
|
733
|
+
ctx.setFillStyle('#221');
|
|
734
|
+
ctx.setStrokeStyle('#221');
|
|
735
|
+
const stave = new Stave(10, 10, 975);
|
|
736
|
+
const staveNotes = [
|
|
737
|
+
staveNote({ keys: ['e/5'], duration: '8', stem_direction: Stem.DOWN }),
|
|
738
|
+
staveNote({ keys: ['e/5'], duration: '16', stem_direction: Stem.DOWN }),
|
|
739
|
+
staveNote({ keys: ['e/5'], duration: '32', stem_direction: Stem.DOWN }),
|
|
740
|
+
staveNote({ keys: ['e/5'], duration: '64', stem_direction: Stem.DOWN }),
|
|
741
|
+
staveNote({ keys: ['e/5'], duration: '128', stem_direction: Stem.DOWN }),
|
|
742
|
+
staveNote({ keys: ['d/5'], duration: '8', stem_direction: Stem.DOWN }),
|
|
743
|
+
staveNote({ keys: ['d/5'], duration: '16', stem_direction: Stem.DOWN }),
|
|
744
|
+
staveNote({ keys: ['d/5'], duration: '32', stem_direction: Stem.DOWN }),
|
|
745
|
+
staveNote({ keys: ['d/5'], duration: '64', stem_direction: Stem.DOWN }),
|
|
746
|
+
staveNote({ keys: ['d/5'], duration: '128', stem_direction: Stem.DOWN }),
|
|
747
|
+
];
|
|
748
|
+
Dot.buildAndAttach(staveNotes, { all: true });
|
|
749
|
+
const beam = new Beam(staveNotes);
|
|
750
|
+
stave.setContext(ctx).draw();
|
|
751
|
+
for (let i = 0; i < staveNotes.length; ++i) {
|
|
752
|
+
draw(staveNotes[i], stave, ctx, i * 65);
|
|
753
|
+
}
|
|
754
|
+
beam.setContext(ctx).draw();
|
|
755
|
+
ok(true, 'Full Dot');
|
|
756
|
+
}
|
|
757
|
+
function noteHeadsSimple(options) {
|
|
758
|
+
const vf = VexFlowTests.makeFactory(options, 800, 250);
|
|
759
|
+
const score = vf.EasyScore();
|
|
760
|
+
const system1 = vf.System({ y: 100, x: 50, width: 200 });
|
|
761
|
+
system1
|
|
762
|
+
.addStave({
|
|
763
|
+
voices: [
|
|
764
|
+
score.voice([...score.beam(score.notes('a4/8, b4/8', { stem: 'up' })), ...score.notes('a4/q/r, a4/h/r')]),
|
|
765
|
+
score.voice(score.notes('g4/w')),
|
|
766
|
+
],
|
|
767
|
+
})
|
|
768
|
+
.addClef('treble')
|
|
769
|
+
.addTimeSignature('4/4');
|
|
770
|
+
const system2 = vf.System({ y: 100, x: 250, width: 150 });
|
|
771
|
+
system2.addStave({
|
|
772
|
+
voices: [score.voice(score.notes('b4/h, b4/h/r')), score.voice(score.notes('b4/w'))],
|
|
773
|
+
});
|
|
774
|
+
const system3 = vf.System({ y: 100, x: 400, width: 150 });
|
|
775
|
+
system3.addStave({
|
|
776
|
+
voices: [score.voice(score.notes('d5/h, d5/h/r')), score.voice(score.notes('e4/w'))],
|
|
777
|
+
});
|
|
778
|
+
const system4 = vf.System({ y: 100, x: 550, width: 150 });
|
|
779
|
+
system4.addStave({
|
|
780
|
+
voices: [
|
|
781
|
+
score.voice(score.notes('e4/q, e4/q/r, e4/h/r')),
|
|
782
|
+
score.voice(score.notes('e4/8, e4/8/r, e4/q/r, e4/h/r')),
|
|
783
|
+
],
|
|
784
|
+
});
|
|
785
|
+
vf.draw();
|
|
786
|
+
expect(0);
|
|
787
|
+
}
|
|
788
|
+
function centerAlignedRest(options) {
|
|
789
|
+
const f = VexFlowTests.makeFactory(options, 400, 160);
|
|
790
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addClef('treble').addTimeSignature('4/4');
|
|
791
|
+
const note = f.StaveNote({ keys: ['b/4'], duration: '1r', align_center: true });
|
|
792
|
+
const voice = f.Voice().setStrict(false).addTickables([note]);
|
|
793
|
+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
794
|
+
f.draw();
|
|
795
|
+
ok(true);
|
|
796
|
+
}
|
|
797
|
+
function centerAlignedRestFermata(options) {
|
|
798
|
+
const f = VexFlowTests.makeFactory(options, 400, 160);
|
|
799
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addClef('treble').addTimeSignature('4/4');
|
|
800
|
+
const note = f
|
|
801
|
+
.StaveNote({ keys: ['b/4'], duration: '1r', align_center: true })
|
|
802
|
+
.addModifier(new Articulation('a@a').setPosition(3), 0);
|
|
803
|
+
const voice = f.Voice().setStrict(false).addTickables([note]);
|
|
804
|
+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
805
|
+
f.draw();
|
|
806
|
+
ok(true);
|
|
807
|
+
}
|
|
808
|
+
function centerAlignedRestAnnotation(options) {
|
|
809
|
+
const f = VexFlowTests.makeFactory(options, 400, 160);
|
|
810
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addClef('treble').addTimeSignature('4/4');
|
|
811
|
+
const note = f
|
|
812
|
+
.StaveNote({ keys: ['b/4'], duration: '1r', align_center: true })
|
|
813
|
+
.addModifier(new Annotation('Whole measure rest').setVerticalJustification(AnnotationVerticalJustify.TOP), 0);
|
|
814
|
+
const voice = f.Voice().setStrict(false).addTickables([note]);
|
|
815
|
+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
816
|
+
f.draw();
|
|
817
|
+
ok(true);
|
|
818
|
+
}
|
|
819
|
+
function centerAlignedNoteMultiModifiers(options) {
|
|
820
|
+
const f = VexFlowTests.makeFactory(options, 400, 160);
|
|
821
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addClef('treble').addTimeSignature('4/4');
|
|
822
|
+
function newFinger(num, pos) {
|
|
823
|
+
return new FretHandFinger(num).setPosition(pos);
|
|
824
|
+
}
|
|
825
|
+
const note = f
|
|
826
|
+
.StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: '4', align_center: true })
|
|
827
|
+
.addModifier(new Annotation('Test').setPosition(3), 0)
|
|
828
|
+
.addStroke(0, new Stroke(2))
|
|
829
|
+
.addModifier(new Accidental('#'), 1)
|
|
830
|
+
.addModifier(newFinger('3', Modifier.Position.LEFT), 0)
|
|
831
|
+
.addModifier(newFinger('2', Modifier.Position.LEFT), 2)
|
|
832
|
+
.addModifier(newFinger('1', Modifier.Position.RIGHT), 1)
|
|
833
|
+
.addModifier(new StringNumber('4').setPosition(Modifier.Position.BELOW), 2);
|
|
834
|
+
Dot.buildAndAttach([note], { all: true });
|
|
835
|
+
const voice = f.Voice().setStrict(false).addTickables([note]);
|
|
836
|
+
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
837
|
+
f.draw();
|
|
838
|
+
ok(true);
|
|
839
|
+
}
|
|
840
|
+
function centerAlignedMultiVoice(options) {
|
|
841
|
+
const f = VexFlowTests.makeFactory(options, 400, 160);
|
|
842
|
+
const stave = f.Stave({ x: 10, y: 10, width: 350 }).addClef('treble').addTimeSignature('3/8');
|
|
843
|
+
const custom_duration = new Fraction(3, 8);
|
|
844
|
+
const notes0 = [
|
|
845
|
+
f.StaveNote({
|
|
846
|
+
keys: ['c/4'],
|
|
847
|
+
duration: '1r',
|
|
848
|
+
align_center: true,
|
|
849
|
+
duration_override: custom_duration,
|
|
850
|
+
}),
|
|
851
|
+
];
|
|
852
|
+
const createStaveNote = (struct) => f.StaveNote(struct);
|
|
853
|
+
const notes1 = [
|
|
854
|
+
{ keys: ['b/4'], duration: '8' },
|
|
855
|
+
{ keys: ['b/4'], duration: '8' },
|
|
856
|
+
{ keys: ['b/4'], duration: '8' },
|
|
857
|
+
].map(createStaveNote);
|
|
858
|
+
notes1[1].addModifier(f.Accidental({ type: '#' }), 0);
|
|
859
|
+
f.Beam({ notes: notes1 });
|
|
860
|
+
const voice0 = f.Voice({ time: '3/8' }).setStrict(false).addTickables(notes0);
|
|
861
|
+
const voice1 = f.Voice({ time: '3/8' }).setStrict(false).addTickables(notes1);
|
|
862
|
+
f.Formatter().joinVoices([voice0, voice1]).formatToStave([voice0, voice1], stave);
|
|
863
|
+
f.draw();
|
|
864
|
+
ok(true);
|
|
865
|
+
}
|
|
866
|
+
VexFlowTests.register(StaveNoteTests);
|
|
867
|
+
export { StaveNoteTests };
|