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