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,149 +0,0 @@
|
|
|
1
|
-
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
-
import { BarNote } from '../src/barnote.js';
|
|
3
|
-
import { Note } from '../src/note.js';
|
|
4
|
-
import { BarlineType } from '../src/stavebarline.js';
|
|
5
|
-
const NoteSubGroupTests = {
|
|
6
|
-
Start() {
|
|
7
|
-
QUnit.module('NoteSubGroup');
|
|
8
|
-
const run = VexFlowTests.runTests;
|
|
9
|
-
run('Basic - ClefNote, TimeSigNote and BarNote', basic);
|
|
10
|
-
run('Multi Voice', multiVoiceSingleDraw);
|
|
11
|
-
run('Multi Voice Multiple Draws', multiVoiceDoubleDraw);
|
|
12
|
-
run('Multi Staff', multiStaff);
|
|
13
|
-
},
|
|
14
|
-
};
|
|
15
|
-
function createShortcuts(f) {
|
|
16
|
-
return {
|
|
17
|
-
createStaveNote: (noteStruct) => f.StaveNote(noteStruct),
|
|
18
|
-
addAccidental: (note, accid) => note.addModifier(f.Accidental({ type: accid }), 0),
|
|
19
|
-
addSubGroup: (note, subNotes) => note.addModifier(f.NoteSubGroup({ notes: subNotes }), 0),
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
function basic(options) {
|
|
23
|
-
const f = VexFlowTests.makeFactory(options, 750, 200);
|
|
24
|
-
const ctx = f.getContext();
|
|
25
|
-
const stave = f.Stave({ width: 600 }).addClef('treble');
|
|
26
|
-
const { createStaveNote, addAccidental, addSubGroup } = createShortcuts(f);
|
|
27
|
-
const notes = [
|
|
28
|
-
{ keys: ['f/5'], stem_direction: -1, duration: '4' },
|
|
29
|
-
{ keys: ['d/4'], stem_direction: -1, duration: '4', clef: 'bass' },
|
|
30
|
-
{ keys: ['g/4'], stem_direction: -1, duration: '4', clef: 'alto' },
|
|
31
|
-
{ keys: ['a/4'], stem_direction: -1, duration: '4', clef: 'alto' },
|
|
32
|
-
{ keys: ['c/4'], stem_direction: -1, duration: '4', clef: 'tenor' },
|
|
33
|
-
{ keys: ['c/3'], stem_direction: +1, duration: '4', clef: 'tenor' },
|
|
34
|
-
{ keys: ['d/4'], stem_direction: -1, duration: '4', clef: 'tenor' },
|
|
35
|
-
{ keys: ['f/4'], stem_direction: -1, duration: '4', clef: 'tenor' },
|
|
36
|
-
].map(createStaveNote);
|
|
37
|
-
addAccidental(notes[1], '#');
|
|
38
|
-
addAccidental(notes[2], 'n');
|
|
39
|
-
addSubGroup(notes[1], [f.ClefNote({ type: 'bass', options: { size: 'small' } })]);
|
|
40
|
-
addSubGroup(notes[2], [f.ClefNote({ type: 'alto', options: { size: 'small' } })]);
|
|
41
|
-
addSubGroup(notes[4], [f.ClefNote({ type: 'tenor', options: { size: 'small' } }), new BarNote()]);
|
|
42
|
-
addSubGroup(notes[5], [f.TimeSigNote({ time: '6/8' })]);
|
|
43
|
-
addSubGroup(notes[6], [new BarNote(BarlineType.REPEAT_BEGIN)]);
|
|
44
|
-
addAccidental(notes[4], 'b');
|
|
45
|
-
addAccidental(notes[6], 'bb');
|
|
46
|
-
const voice = f.Voice().setStrict(false).addTickables(notes);
|
|
47
|
-
f.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
48
|
-
f.draw();
|
|
49
|
-
notes.forEach((note) => Note.plotMetrics(ctx, note, 150));
|
|
50
|
-
VexFlowTests.plotLegendForNoteWidth(ctx, 620, 120);
|
|
51
|
-
ok(true, 'all pass');
|
|
52
|
-
}
|
|
53
|
-
function multiVoiceSingleDraw(options) {
|
|
54
|
-
multiVoiceHelper(options, 1);
|
|
55
|
-
}
|
|
56
|
-
function multiVoiceDoubleDraw(options) {
|
|
57
|
-
multiVoiceHelper(options, 2);
|
|
58
|
-
}
|
|
59
|
-
function multiVoiceHelper(options, numDraws) {
|
|
60
|
-
const f = VexFlowTests.makeFactory(options, 550, 200);
|
|
61
|
-
const ctx = f.getContext();
|
|
62
|
-
const stave = f.Stave().addClef('treble');
|
|
63
|
-
const { createStaveNote, addAccidental, addSubGroup } = createShortcuts(f);
|
|
64
|
-
const notes1 = [
|
|
65
|
-
{ keys: ['f/5'], stem_direction: 1, duration: '4' },
|
|
66
|
-
{ keys: ['d/4'], stem_direction: 1, duration: '4', clef: 'bass' },
|
|
67
|
-
{ keys: ['c/5'], stem_direction: 1, duration: '4', clef: 'alto' },
|
|
68
|
-
{ keys: ['c/5'], stem_direction: 1, duration: '4', clef: 'soprano' },
|
|
69
|
-
].map(createStaveNote);
|
|
70
|
-
const notes2 = [
|
|
71
|
-
{ keys: ['c/4'], stem_direction: -1, duration: '4' },
|
|
72
|
-
{ keys: ['c/3'], stem_direction: -1, duration: '4', clef: 'bass' },
|
|
73
|
-
{ keys: ['d/4'], stem_direction: -1, duration: '4', clef: 'alto' },
|
|
74
|
-
{ keys: ['f/4'], stem_direction: -1, duration: '4', clef: 'soprano' },
|
|
75
|
-
].map(createStaveNote);
|
|
76
|
-
addAccidental(notes1[1], '#');
|
|
77
|
-
addSubGroup(notes1[1], [
|
|
78
|
-
f.ClefNote({ type: 'bass', options: { size: 'small' } }),
|
|
79
|
-
new BarNote(BarlineType.REPEAT_BEGIN),
|
|
80
|
-
f.TimeSigNote({ time: '3/4' }),
|
|
81
|
-
]);
|
|
82
|
-
addSubGroup(notes2[2], [
|
|
83
|
-
f.ClefNote({ type: 'alto', options: { size: 'small' } }),
|
|
84
|
-
f.TimeSigNote({ time: '9/8' }),
|
|
85
|
-
new BarNote(BarlineType.DOUBLE),
|
|
86
|
-
]);
|
|
87
|
-
addSubGroup(notes1[3], [f.ClefNote({ type: 'soprano', options: { size: 'small' } })]);
|
|
88
|
-
addAccidental(notes1[2], 'b');
|
|
89
|
-
addAccidental(notes2[3], '#');
|
|
90
|
-
const voices = [f.Voice().addTickables(notes1), f.Voice().addTickables(notes2)];
|
|
91
|
-
f.Formatter().joinVoices(voices).formatToStave(voices, stave);
|
|
92
|
-
for (let i = 0; i < numDraws; i++) {
|
|
93
|
-
f.draw();
|
|
94
|
-
}
|
|
95
|
-
notes1.forEach((note) => Note.plotMetrics(ctx, note, 150));
|
|
96
|
-
ok(true, 'all pass');
|
|
97
|
-
}
|
|
98
|
-
function multiStaff(options) {
|
|
99
|
-
const f = VexFlowTests.makeFactory(options, 550, 400);
|
|
100
|
-
const { createStaveNote, addAccidental, addSubGroup } = createShortcuts(f);
|
|
101
|
-
const stave1 = f.Stave({ x: 15, y: 30, width: 500 }).setClef('treble');
|
|
102
|
-
const notes1 = [
|
|
103
|
-
{ keys: ['f/5'], stem_direction: 1, duration: '4' },
|
|
104
|
-
{ keys: ['d/4'], stem_direction: 1, duration: '4', clef: 'bass' },
|
|
105
|
-
{ keys: ['c/5'], stem_direction: 1, duration: '4', clef: 'alto' },
|
|
106
|
-
{ keys: ['c/5'], stem_direction: 1, duration: '4', clef: 'soprano' },
|
|
107
|
-
].map(createStaveNote);
|
|
108
|
-
const notes2 = [
|
|
109
|
-
{ keys: ['c/4'], stem_direction: -1, duration: '4' },
|
|
110
|
-
{ keys: ['c/3'], stem_direction: -1, duration: '4', clef: 'bass' },
|
|
111
|
-
{ keys: ['d/4'], stem_direction: -1, duration: '4', clef: 'alto' },
|
|
112
|
-
{ keys: ['f/4'], stem_direction: -1, duration: '4', clef: 'soprano' },
|
|
113
|
-
].map(createStaveNote);
|
|
114
|
-
const stave2 = f.Stave({ x: 15, y: 150, width: 500 }).setClef('bass');
|
|
115
|
-
const notes3 = [
|
|
116
|
-
{ keys: ['e/3'], duration: '8', stem_direction: -1, clef: 'bass' },
|
|
117
|
-
{ keys: ['g/4'], duration: '8', stem_direction: 1, clef: 'treble' },
|
|
118
|
-
{ keys: ['d/4'], duration: '8', stem_direction: 1, clef: 'treble' },
|
|
119
|
-
{ keys: ['f/4'], duration: '8', stem_direction: 1, clef: 'treble' },
|
|
120
|
-
{ keys: ['c/4'], duration: '8', stem_direction: 1, clef: 'treble' },
|
|
121
|
-
{ keys: ['g/3'], duration: '8', stem_direction: -1, clef: 'bass' },
|
|
122
|
-
{ keys: ['d/3'], duration: '8', stem_direction: -1, clef: 'bass' },
|
|
123
|
-
{ keys: ['f/3'], duration: '8', stem_direction: -1, clef: 'bass' },
|
|
124
|
-
].map(createStaveNote);
|
|
125
|
-
f.StaveConnector({ top_stave: stave1, bottom_stave: stave2, type: 'brace' });
|
|
126
|
-
f.StaveConnector({ top_stave: stave1, bottom_stave: stave2, type: 'singleLeft' });
|
|
127
|
-
f.StaveConnector({ top_stave: stave1, bottom_stave: stave2, type: 'singleRight' });
|
|
128
|
-
f.Beam({ notes: notes3.slice(1, 4) });
|
|
129
|
-
f.Beam({ notes: notes3.slice(5) });
|
|
130
|
-
addAccidental(notes1[1], '#');
|
|
131
|
-
addSubGroup(notes1[1], [f.ClefNote({ type: 'bass', options: { size: 'small' } }), f.TimeSigNote({ time: '3/4' })]);
|
|
132
|
-
addSubGroup(notes2[2], [f.ClefNote({ type: 'alto', options: { size: 'small' } }), f.TimeSigNote({ time: '9/8' })]);
|
|
133
|
-
addSubGroup(notes1[3], [f.ClefNote({ type: 'soprano', options: { size: 'small' } })]);
|
|
134
|
-
addSubGroup(notes3[1], [f.ClefNote({ type: 'treble', options: { size: 'small' } })]);
|
|
135
|
-
addSubGroup(notes3[5], [f.ClefNote({ type: 'bass', options: { size: 'small' } })]);
|
|
136
|
-
addAccidental(notes3[0], '#');
|
|
137
|
-
addAccidental(notes3[3], 'b');
|
|
138
|
-
addAccidental(notes3[5], '#');
|
|
139
|
-
addAccidental(notes1[2], 'b');
|
|
140
|
-
addAccidental(notes2[3], '#');
|
|
141
|
-
const voice1 = f.Voice().addTickables(notes1);
|
|
142
|
-
const voice2 = f.Voice().addTickables(notes2);
|
|
143
|
-
const voice3 = f.Voice().addTickables(notes3);
|
|
144
|
-
f.Formatter().joinVoices([voice1, voice2]).joinVoices([voice3]).formatToStave([voice1, voice2, voice3], stave1);
|
|
145
|
-
f.draw();
|
|
146
|
-
ok(true, 'all pass');
|
|
147
|
-
}
|
|
148
|
-
VexFlowTests.register(NoteSubGroupTests);
|
|
149
|
-
export { NoteSubGroupTests };
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
-
import { CanvasContext } from '../src/canvascontext.js';
|
|
3
|
-
import { Formatter } from '../src/formatter.js';
|
|
4
|
-
import { Stave } from '../src/stave.js';
|
|
5
|
-
import { BarlineType } from '../src/stavebarline.js';
|
|
6
|
-
import { StaveNote } from '../src/stavenote.js';
|
|
7
|
-
import { globalObject } from '../src/util.js';
|
|
8
|
-
const OffscreenCanvasTests = {
|
|
9
|
-
Start() {
|
|
10
|
-
if (globalObject().OffscreenCanvas === undefined) {
|
|
11
|
-
return;
|
|
12
|
-
}
|
|
13
|
-
QUnit.module('OffscreenCanvas');
|
|
14
|
-
test('Simple Test', simpleTest);
|
|
15
|
-
},
|
|
16
|
-
};
|
|
17
|
-
function simpleTest() {
|
|
18
|
-
const offscreenCanvas = new OffscreenCanvas(550, 200);
|
|
19
|
-
const offscreenCtx = offscreenCanvas.getContext('2d');
|
|
20
|
-
if (offscreenCtx == null) {
|
|
21
|
-
throw new Error("Couldn't create offscreen context");
|
|
22
|
-
}
|
|
23
|
-
const ctx = new CanvasContext(offscreenCtx);
|
|
24
|
-
const stave = new Stave(10, 50, 200);
|
|
25
|
-
stave.setEndBarType(BarlineType.END);
|
|
26
|
-
stave.addClef('treble').setContext(ctx).draw();
|
|
27
|
-
const notes = [
|
|
28
|
-
new StaveNote({ keys: ['c/4'], duration: 'q' }),
|
|
29
|
-
new StaveNote({ keys: ['d/4'], duration: 'q' }),
|
|
30
|
-
new StaveNote({ keys: ['b/4'], duration: 'qr' }),
|
|
31
|
-
new StaveNote({ keys: ['c/4', 'e/4', 'g/4'], duration: 'q' }),
|
|
32
|
-
];
|
|
33
|
-
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
34
|
-
const imgBmp = offscreenCanvas.transferToImageBitmap();
|
|
35
|
-
const canvas = document.createElement('canvas');
|
|
36
|
-
canvas.width = offscreenCanvas.width;
|
|
37
|
-
canvas.height = offscreenCanvas.height;
|
|
38
|
-
const canvasCtx = canvas.getContext('2d');
|
|
39
|
-
if (canvasCtx == null) {
|
|
40
|
-
throw new Error("Couldn't create canvas context");
|
|
41
|
-
}
|
|
42
|
-
canvasCtx.drawImage(imgBmp, 0, 0);
|
|
43
|
-
document.body.appendChild(canvas);
|
|
44
|
-
ok(true, 'all pass');
|
|
45
|
-
}
|
|
46
|
-
VexFlowTests.register(OffscreenCanvasTests);
|
|
47
|
-
export { OffscreenCanvasTests };
|
|
@@ -1,298 +0,0 @@
|
|
|
1
|
-
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
-
import { Accidental } from '../src/accidental.js';
|
|
3
|
-
import { Beam } from '../src/beam.js';
|
|
4
|
-
import { Dot } from '../src/dot.js';
|
|
5
|
-
import { Formatter } from '../src/formatter.js';
|
|
6
|
-
import { Glyph } from '../src/glyph.js';
|
|
7
|
-
import { Ornament } from '../src/ornament.js';
|
|
8
|
-
import { Stave } from '../src/stave.js';
|
|
9
|
-
import { StaveNote } from '../src/stavenote.js';
|
|
10
|
-
import { Voice, VoiceMode } from '../src/voice.js';
|
|
11
|
-
const OrnamentTests = {
|
|
12
|
-
Start() {
|
|
13
|
-
QUnit.module('Ornament');
|
|
14
|
-
const run = VexFlowTests.runTests;
|
|
15
|
-
run('Ornaments', drawOrnaments);
|
|
16
|
-
run('Ornaments Vertically Shifted', drawOrnamentsDisplaced);
|
|
17
|
-
run('Ornaments - Delayed turns', drawOrnamentsDelayed);
|
|
18
|
-
run('Ornaments - Delayed turns, Multiple Draws', drawOrnamentsDelayedMultipleDraws);
|
|
19
|
-
run('Stacked', drawOrnamentsStacked);
|
|
20
|
-
run('With Upper/Lower Accidentals', drawOrnamentsWithAccidentals);
|
|
21
|
-
run('Jazz Ornaments', jazzOrnaments);
|
|
22
|
-
},
|
|
23
|
-
};
|
|
24
|
-
function drawOrnaments(options, contextBuilder) {
|
|
25
|
-
expect(0);
|
|
26
|
-
const ctx = contextBuilder(options.elementId, 750, 195);
|
|
27
|
-
const stave = new Stave(10, 30, 700);
|
|
28
|
-
stave.setContext(ctx).draw();
|
|
29
|
-
const notes = [
|
|
30
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
31
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
32
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
33
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
34
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
35
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
36
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
37
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
38
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
39
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
40
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
41
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
42
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
43
|
-
];
|
|
44
|
-
notes[0].addModifier(new Ornament('mordent'), 0);
|
|
45
|
-
notes[1].addModifier(new Ornament('mordent_inverted'), 0);
|
|
46
|
-
notes[2].addModifier(new Ornament('turn'), 0);
|
|
47
|
-
notes[3].addModifier(new Ornament('turn_inverted'), 0);
|
|
48
|
-
notes[4].addModifier(new Ornament('tr'), 0);
|
|
49
|
-
notes[5].addModifier(new Ornament('upprall'), 0);
|
|
50
|
-
notes[6].addModifier(new Ornament('downprall'), 0);
|
|
51
|
-
notes[7].addModifier(new Ornament('prallup'), 0);
|
|
52
|
-
notes[8].addModifier(new Ornament('pralldown'), 0);
|
|
53
|
-
notes[9].addModifier(new Ornament('upmordent'), 0);
|
|
54
|
-
notes[10].addModifier(new Ornament('downmordent'), 0);
|
|
55
|
-
notes[11].addModifier(new Ornament('lineprall'), 0);
|
|
56
|
-
notes[12].addModifier(new Ornament('prallprall'), 0);
|
|
57
|
-
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
58
|
-
}
|
|
59
|
-
function drawOrnamentsDisplaced(options, contextBuilder) {
|
|
60
|
-
expect(0);
|
|
61
|
-
const ctx = contextBuilder(options.elementId, 750, 195);
|
|
62
|
-
const stave = new Stave(10, 30, 700);
|
|
63
|
-
stave.setContext(ctx).draw();
|
|
64
|
-
const notes = [
|
|
65
|
-
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
66
|
-
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
67
|
-
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
68
|
-
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
69
|
-
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
70
|
-
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
71
|
-
new StaveNote({ keys: ['a/5'], duration: '4', stem_direction: -1 }),
|
|
72
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
73
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
74
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
75
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
76
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
77
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
78
|
-
];
|
|
79
|
-
notes[0].addModifier(new Ornament('mordent'), 0);
|
|
80
|
-
notes[1].addModifier(new Ornament('mordent_inverted'), 0);
|
|
81
|
-
notes[1].addModifier(new Ornament('mordent_inverted'), 0);
|
|
82
|
-
notes[2].addModifier(new Ornament('turn'), 0);
|
|
83
|
-
notes[3].addModifier(new Ornament('turn_inverted'), 0);
|
|
84
|
-
notes[4].addModifier(new Ornament('tr'), 0);
|
|
85
|
-
notes[5].addModifier(new Ornament('upprall'), 0);
|
|
86
|
-
notes[6].addModifier(new Ornament('downprall'), 0);
|
|
87
|
-
notes[7].addModifier(new Ornament('prallup'), 0);
|
|
88
|
-
notes[8].addModifier(new Ornament('pralldown'), 0);
|
|
89
|
-
notes[9].addModifier(new Ornament('upmordent'), 0);
|
|
90
|
-
notes[10].addModifier(new Ornament('downmordent'), 0);
|
|
91
|
-
notes[11].addModifier(new Ornament('lineprall'), 0);
|
|
92
|
-
notes[12].addModifier(new Ornament('prallprall'), 0);
|
|
93
|
-
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
94
|
-
}
|
|
95
|
-
const addDelayedTurns = (options, contextBuilder) => {
|
|
96
|
-
const context = contextBuilder(options.elementId, 550, 195);
|
|
97
|
-
const stave = new Stave(10, 30, 500);
|
|
98
|
-
stave.setContext(context).draw();
|
|
99
|
-
const notes = [
|
|
100
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
101
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
102
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
103
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
104
|
-
];
|
|
105
|
-
notes[0].addModifier(new Ornament('turn').setDelayed(true), 0);
|
|
106
|
-
notes[1].addModifier(new Ornament('turn_inverted').setDelayed(true), 0);
|
|
107
|
-
notes[2].addModifier(new Ornament('turn_inverted').setDelayed(true), 0);
|
|
108
|
-
notes[3].addModifier(new Ornament('turn').setDelayed(true), 0);
|
|
109
|
-
return { context, stave, notes };
|
|
110
|
-
};
|
|
111
|
-
function drawOrnamentsDelayed(options, contextBuilder) {
|
|
112
|
-
expect(0);
|
|
113
|
-
const { context, stave, notes } = addDelayedTurns(options, contextBuilder);
|
|
114
|
-
Formatter.FormatAndDraw(context, stave, notes);
|
|
115
|
-
}
|
|
116
|
-
function drawOrnamentsDelayedMultipleDraws(options, contextBuilder) {
|
|
117
|
-
expect(0);
|
|
118
|
-
const { context, stave, notes } = addDelayedTurns(options, contextBuilder);
|
|
119
|
-
Formatter.FormatAndDraw(context, stave, notes);
|
|
120
|
-
Formatter.FormatAndDraw(context, stave, notes);
|
|
121
|
-
}
|
|
122
|
-
function drawOrnamentsStacked(options, contextBuilder) {
|
|
123
|
-
expect(0);
|
|
124
|
-
const ctx = contextBuilder(options.elementId, 550, 195);
|
|
125
|
-
const stave = new Stave(10, 30, 500);
|
|
126
|
-
stave.setContext(ctx).draw();
|
|
127
|
-
const notes = [
|
|
128
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
129
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
130
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
131
|
-
new StaveNote({ keys: ['a/4'], duration: '4', stem_direction: 1 }),
|
|
132
|
-
];
|
|
133
|
-
notes[0].addModifier(new Ornament('mordent'), 0);
|
|
134
|
-
notes[1].addModifier(new Ornament('turn_inverted'), 0);
|
|
135
|
-
notes[2].addModifier(new Ornament('turn'), 0);
|
|
136
|
-
notes[3].addModifier(new Ornament('turn_inverted'), 0);
|
|
137
|
-
notes[0].addModifier(new Ornament('turn'), 0);
|
|
138
|
-
notes[1].addModifier(new Ornament('prallup'), 0);
|
|
139
|
-
notes[2].addModifier(new Ornament('upmordent'), 0);
|
|
140
|
-
notes[3].addModifier(new Ornament('lineprall'), 0);
|
|
141
|
-
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
142
|
-
}
|
|
143
|
-
function drawOrnamentsWithAccidentals(options, contextBuilder) {
|
|
144
|
-
expect(0);
|
|
145
|
-
const ctx = contextBuilder(options.elementId, 650, 250);
|
|
146
|
-
const stave = new Stave(10, 60, 600);
|
|
147
|
-
stave.setContext(ctx).draw();
|
|
148
|
-
const notes = [
|
|
149
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
150
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
151
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
152
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
153
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
154
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
155
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
156
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
157
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
158
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
159
|
-
new StaveNote({ keys: ['f/4'], duration: '4', stem_direction: 1 }),
|
|
160
|
-
];
|
|
161
|
-
notes[0].addModifier(new Ornament('mordent').setUpperAccidental('#').setLowerAccidental('#'), 0);
|
|
162
|
-
notes[1].addModifier(new Ornament('turn_inverted').setLowerAccidental('b').setUpperAccidental('b'), 0);
|
|
163
|
-
notes[2].addModifier(new Ornament('turn').setUpperAccidental('##').setLowerAccidental('##'), 0);
|
|
164
|
-
notes[3].addModifier(new Ornament('mordent_inverted').setLowerAccidental('db').setUpperAccidental('db'), 0);
|
|
165
|
-
notes[4].addModifier(new Ornament('turn_inverted').setUpperAccidental('++').setLowerAccidental('++'), 0);
|
|
166
|
-
notes[5].addModifier(new Ornament('tr').setUpperAccidental('n').setLowerAccidental('n'), 0);
|
|
167
|
-
notes[6].addModifier(new Ornament('prallup').setUpperAccidental('d').setLowerAccidental('d'), 0);
|
|
168
|
-
notes[7].addModifier(new Ornament('lineprall').setUpperAccidental('db').setLowerAccidental('db'), 0);
|
|
169
|
-
notes[8].addModifier(new Ornament('upmordent').setUpperAccidental('bbs').setLowerAccidental('bbs'), 0);
|
|
170
|
-
notes[9].addModifier(new Ornament('prallprall').setUpperAccidental('bb').setLowerAccidental('bb'), 0);
|
|
171
|
-
notes[10].addModifier(new Ornament('turn_inverted').setUpperAccidental('+').setLowerAccidental('+'), 0);
|
|
172
|
-
Formatter.FormatAndDraw(ctx, stave, notes);
|
|
173
|
-
}
|
|
174
|
-
function jazzOrnaments(options) {
|
|
175
|
-
const clefWidth = Glyph.getWidth('gClef', 38);
|
|
176
|
-
function draw(modifiers, keys, x, width, y, stemDirection) {
|
|
177
|
-
const note = (keys, duration, modifier, stemDirection) => {
|
|
178
|
-
const n = new StaveNote({ keys, duration, stem_direction: stemDirection })
|
|
179
|
-
.addModifier(modifier, 0)
|
|
180
|
-
.addModifier(new Accidental('b'), 0);
|
|
181
|
-
const dot = duration.indexOf('d') >= 0;
|
|
182
|
-
if (dot) {
|
|
183
|
-
Dot.buildAndAttach([n], { all: true });
|
|
184
|
-
}
|
|
185
|
-
return n;
|
|
186
|
-
};
|
|
187
|
-
const stave = new Stave(x, y, width).addClef('treble').setContext(ctx).draw();
|
|
188
|
-
const notes = [
|
|
189
|
-
note(keys, '4d', modifiers[0], stemDirection),
|
|
190
|
-
note(keys, '8', modifiers[1], stemDirection),
|
|
191
|
-
note(keys, '4d', modifiers[2], stemDirection),
|
|
192
|
-
note(keys, '8', modifiers[3], stemDirection),
|
|
193
|
-
];
|
|
194
|
-
if (modifiers.length > 4) {
|
|
195
|
-
notes[3].addModifier(modifiers[4], 0);
|
|
196
|
-
}
|
|
197
|
-
Beam.generateBeams(notes);
|
|
198
|
-
const voice = new Voice({
|
|
199
|
-
num_beats: 4,
|
|
200
|
-
beat_value: 4,
|
|
201
|
-
}).setMode(VoiceMode.SOFT);
|
|
202
|
-
voice.addTickables(notes);
|
|
203
|
-
const formatter = new Formatter().joinVoices([voice]);
|
|
204
|
-
formatter.format([voice], width - Stave.defaultPadding - clefWidth);
|
|
205
|
-
stave.setContext(ctx).draw();
|
|
206
|
-
voice.draw(ctx, stave);
|
|
207
|
-
}
|
|
208
|
-
expect(0);
|
|
209
|
-
const f = VexFlowTests.makeFactory(options, 950, 400);
|
|
210
|
-
const ctx = f.getContext();
|
|
211
|
-
ctx.scale(1, 1);
|
|
212
|
-
ctx.fillStyle = '#221';
|
|
213
|
-
ctx.strokeStyle = '#221';
|
|
214
|
-
const xStart = 10;
|
|
215
|
-
const width = 300;
|
|
216
|
-
const yStart = 50;
|
|
217
|
-
const staffHeight = 70;
|
|
218
|
-
let curX = xStart;
|
|
219
|
-
let curY = yStart;
|
|
220
|
-
let mods = [
|
|
221
|
-
new Ornament('scoop'),
|
|
222
|
-
new Ornament('doit'),
|
|
223
|
-
new Ornament('fall'),
|
|
224
|
-
new Ornament('doitLong'),
|
|
225
|
-
];
|
|
226
|
-
draw(mods, ['a/5'], curX, width, curY, -1);
|
|
227
|
-
curX += width;
|
|
228
|
-
mods = [
|
|
229
|
-
new Ornament('fallLong'),
|
|
230
|
-
new Ornament('bend'),
|
|
231
|
-
new Ornament('plungerClosed'),
|
|
232
|
-
new Ornament('plungerOpen'),
|
|
233
|
-
new Ornament('bend'),
|
|
234
|
-
];
|
|
235
|
-
draw(mods, ['a/5'], curX, width, curY, -1);
|
|
236
|
-
curX += width;
|
|
237
|
-
mods = [
|
|
238
|
-
new Ornament('flip'),
|
|
239
|
-
new Ornament('jazzTurn'),
|
|
240
|
-
new Ornament('smear'),
|
|
241
|
-
new Ornament('doit'),
|
|
242
|
-
];
|
|
243
|
-
draw(mods, ['a/5'], curX, width, curY, 1);
|
|
244
|
-
curX = xStart;
|
|
245
|
-
curY += staffHeight;
|
|
246
|
-
mods = [
|
|
247
|
-
new Ornament('scoop'),
|
|
248
|
-
new Ornament('doit'),
|
|
249
|
-
new Ornament('fall'),
|
|
250
|
-
new Ornament('doitLong'),
|
|
251
|
-
];
|
|
252
|
-
draw(mods, ['e/5'], curX, width, curY);
|
|
253
|
-
curX += width;
|
|
254
|
-
mods = [
|
|
255
|
-
new Ornament('fallLong'),
|
|
256
|
-
new Ornament('bend'),
|
|
257
|
-
new Ornament('plungerClosed'),
|
|
258
|
-
new Ornament('plungerOpen'),
|
|
259
|
-
new Ornament('bend'),
|
|
260
|
-
];
|
|
261
|
-
draw(mods, ['e/5'], curX, width, curY);
|
|
262
|
-
curX += width;
|
|
263
|
-
mods = [
|
|
264
|
-
new Ornament('flip'),
|
|
265
|
-
new Ornament('jazzTurn'),
|
|
266
|
-
new Ornament('smear'),
|
|
267
|
-
new Ornament('doit'),
|
|
268
|
-
];
|
|
269
|
-
draw(mods, ['e/5'], curX, width, curY);
|
|
270
|
-
curX = xStart;
|
|
271
|
-
curY += staffHeight;
|
|
272
|
-
mods = [
|
|
273
|
-
new Ornament('scoop'),
|
|
274
|
-
new Ornament('doit'),
|
|
275
|
-
new Ornament('fall'),
|
|
276
|
-
new Ornament('doitLong'),
|
|
277
|
-
];
|
|
278
|
-
draw(mods, ['e/4'], curX, width, curY);
|
|
279
|
-
curX += width;
|
|
280
|
-
mods = [
|
|
281
|
-
new Ornament('fallLong'),
|
|
282
|
-
new Ornament('bend'),
|
|
283
|
-
new Ornament('plungerClosed'),
|
|
284
|
-
new Ornament('plungerOpen'),
|
|
285
|
-
new Ornament('bend'),
|
|
286
|
-
];
|
|
287
|
-
draw(mods, ['e/4'], curX, width, curY);
|
|
288
|
-
curX += width;
|
|
289
|
-
mods = [
|
|
290
|
-
new Ornament('flip'),
|
|
291
|
-
new Ornament('jazzTurn'),
|
|
292
|
-
new Ornament('smear'),
|
|
293
|
-
new Ornament('doit'),
|
|
294
|
-
];
|
|
295
|
-
draw(mods, ['e/4'], curX, width, curY);
|
|
296
|
-
}
|
|
297
|
-
VexFlowTests.register(OrnamentTests);
|
|
298
|
-
export { OrnamentTests };
|
|
@@ -1,122 +0,0 @@
|
|
|
1
|
-
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
-
import { Parser } from '../src/parser.js';
|
|
3
|
-
const ParserTests = {
|
|
4
|
-
Start() {
|
|
5
|
-
QUnit.module('Parser');
|
|
6
|
-
test('Basic', basic);
|
|
7
|
-
test('Advanced', advanced);
|
|
8
|
-
test('Mixed', mixed);
|
|
9
|
-
test('Micro Score', microscore);
|
|
10
|
-
},
|
|
11
|
-
};
|
|
12
|
-
class TestGrammar {
|
|
13
|
-
begin() {
|
|
14
|
-
return () => ({ expect: this.expect });
|
|
15
|
-
}
|
|
16
|
-
BIGORLITTLE() {
|
|
17
|
-
return { expect: [this.BIGLINE, this.LITTLELINE], or: true };
|
|
18
|
-
}
|
|
19
|
-
BIGLINE() {
|
|
20
|
-
return { expect: [this.LBRACE, this.WORD, this.WORDS, this.MAYBEEXCLAIM, this.RBRACE] };
|
|
21
|
-
}
|
|
22
|
-
LITTLELINE() {
|
|
23
|
-
return { expect: [this.WORD, this.WORDS] };
|
|
24
|
-
}
|
|
25
|
-
WORDS() {
|
|
26
|
-
return { expect: [this.COMMA, this.WORD], zeroOrMore: true };
|
|
27
|
-
}
|
|
28
|
-
MAYBEEXCLAIM() {
|
|
29
|
-
return { expect: [this.EXCLAIM], maybe: true };
|
|
30
|
-
}
|
|
31
|
-
LBRACE() {
|
|
32
|
-
return { token: '[{]' };
|
|
33
|
-
}
|
|
34
|
-
RBRACE() {
|
|
35
|
-
return { token: '[}]' };
|
|
36
|
-
}
|
|
37
|
-
WORD() {
|
|
38
|
-
return { token: '[a-zA-Z]+' };
|
|
39
|
-
}
|
|
40
|
-
COMMA() {
|
|
41
|
-
return { token: '[,]' };
|
|
42
|
-
}
|
|
43
|
-
EXCLAIM() {
|
|
44
|
-
return { token: '[!]' };
|
|
45
|
-
}
|
|
46
|
-
EOL() {
|
|
47
|
-
return { token: '$' };
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
class MicroScoreGrammar {
|
|
51
|
-
constructor() {
|
|
52
|
-
this.ITEM = () => ({ expect: [this.PIANO_KEY_NUMBER, this.CHORD], or: true });
|
|
53
|
-
this.MAYBE_MORE_ITEMS = () => ({ expect: [this.ITEM], zeroOrMore: true });
|
|
54
|
-
this.PIANO_KEY_NUMBER = () => ({ expect: [this.NUM], oneOrMore: true });
|
|
55
|
-
this.CHORD = () => ({ expect: [this.LEFT_BRACKET, this.PIANO_KEY_NUMBER, this.MORE_CHORD_PARTS, this.RIGHT_BRACKET] });
|
|
56
|
-
this.MORE_CHORD_PARTS = () => ({ expect: [this.PERIOD, this.PIANO_KEY_NUMBER], oneOrMore: true });
|
|
57
|
-
this.NUM = () => ({ token: '\\d+' });
|
|
58
|
-
this.WHITESPACE = () => ({ token: '\\s+' });
|
|
59
|
-
this.PERIOD = () => ({ token: '\\.' });
|
|
60
|
-
this.LEFT_BRACKET = () => ({ token: '\\[' });
|
|
61
|
-
this.RIGHT_BRACKET = () => ({ token: '\\]' });
|
|
62
|
-
this.EOL = () => ({ token: '$' });
|
|
63
|
-
}
|
|
64
|
-
begin() {
|
|
65
|
-
return () => ({ expect: [this.ITEM, this.MAYBE_MORE_ITEMS, this.EOL] });
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
function fails(result, expectedErrorPos, msg) {
|
|
69
|
-
notOk(result.success, msg);
|
|
70
|
-
equal(result.errorPos, expectedErrorPos, msg);
|
|
71
|
-
}
|
|
72
|
-
function basic() {
|
|
73
|
-
const grammar = new TestGrammar();
|
|
74
|
-
grammar.expect = [grammar.LITTLELINE, grammar.EOL];
|
|
75
|
-
const parser = new Parser(grammar);
|
|
76
|
-
const mustPass = ['first, second', 'first,second', 'first', 'first,second, third'];
|
|
77
|
-
mustPass.forEach((line) => equal(parser.parse(line).success, true, line));
|
|
78
|
-
fails(parser.parse(''), 0);
|
|
79
|
-
fails(parser.parse('first second'), 6);
|
|
80
|
-
fails(parser.parse('first,,'), 5);
|
|
81
|
-
fails(parser.parse('first,'), 5);
|
|
82
|
-
fails(parser.parse(',,'), 0);
|
|
83
|
-
}
|
|
84
|
-
function advanced() {
|
|
85
|
-
const grammar = new TestGrammar();
|
|
86
|
-
grammar.expect = [grammar.BIGLINE, grammar.EOL];
|
|
87
|
-
const parser = new Parser(grammar);
|
|
88
|
-
const mustPass = ['{first}', '{first!}', '{first,second}', '{first,second!}', '{first,second,third!}'];
|
|
89
|
-
mustPass.forEach((line) => equal(parser.parse(line).success, true, line));
|
|
90
|
-
fails(parser.parse('{first,second,third,}'), 19);
|
|
91
|
-
fails(parser.parse('first,second,third'), 0);
|
|
92
|
-
fails(parser.parse('{first,second,third'), 19);
|
|
93
|
-
fails(parser.parse('{!}'), 1);
|
|
94
|
-
}
|
|
95
|
-
function mixed() {
|
|
96
|
-
const grammar = new TestGrammar();
|
|
97
|
-
grammar.expect = [grammar.BIGORLITTLE, grammar.EOL];
|
|
98
|
-
const parser = new Parser(grammar);
|
|
99
|
-
const mustPass = ['{first,second,third!}', 'first, second'];
|
|
100
|
-
mustPass.forEach((line) => equal(parser.parse(line).success, true, line));
|
|
101
|
-
fails(parser.parse('first second'), 6);
|
|
102
|
-
}
|
|
103
|
-
function microscore() {
|
|
104
|
-
const grammar = new MicroScoreGrammar();
|
|
105
|
-
const parser = new Parser(grammar);
|
|
106
|
-
const mustPass = [
|
|
107
|
-
'40 42 44 45 47 49 51 52',
|
|
108
|
-
'[40.44.47] [45.49.52] [47.51.54] [49.52.56]',
|
|
109
|
-
'40 [40.44.47] 45 47 [44.47.51]',
|
|
110
|
-
];
|
|
111
|
-
mustPass.forEach((line) => {
|
|
112
|
-
var _a;
|
|
113
|
-
const result = parser.parse(line);
|
|
114
|
-
equal(result.success, true, line);
|
|
115
|
-
equal((_a = result.matches) === null || _a === void 0 ? void 0 : _a.length, 3, line);
|
|
116
|
-
});
|
|
117
|
-
fails(parser.parse('40 42 44 45 47 49 5A 52'), 19);
|
|
118
|
-
fails(parser.parse('40.44.47] [45.49.52] [47.51.54] [49.52.56]'), 2);
|
|
119
|
-
fails(parser.parse('40 [40] 45 47 [44.47.51]'), 3);
|
|
120
|
-
}
|
|
121
|
-
VexFlowTests.register(ParserTests);
|
|
122
|
-
export { ParserTests };
|