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
package/build/esm/src/voice.js
DELETED
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import { Element } from './element.js';
|
|
2
|
-
import { Fraction } from './fraction.js';
|
|
3
|
-
import { Tables } from './tables.js';
|
|
4
|
-
import { defined, RuntimeError } from './util.js';
|
|
5
|
-
export var VoiceMode;
|
|
6
|
-
(function (VoiceMode) {
|
|
7
|
-
VoiceMode[VoiceMode["STRICT"] = 1] = "STRICT";
|
|
8
|
-
VoiceMode[VoiceMode["SOFT"] = 2] = "SOFT";
|
|
9
|
-
VoiceMode[VoiceMode["FULL"] = 3] = "FULL";
|
|
10
|
-
})(VoiceMode || (VoiceMode = {}));
|
|
11
|
-
export class Voice extends Element {
|
|
12
|
-
constructor(time, options) {
|
|
13
|
-
super();
|
|
14
|
-
this.resolutionMultiplier = 1;
|
|
15
|
-
this.mode = VoiceMode.STRICT;
|
|
16
|
-
this.preFormatted = false;
|
|
17
|
-
this.ticksUsed = new Fraction(0, 1);
|
|
18
|
-
this.largestTickWidth = 0;
|
|
19
|
-
this.tickables = [];
|
|
20
|
-
this.options = Object.assign({ softmaxFactor: 100 }, options);
|
|
21
|
-
let voiceTime;
|
|
22
|
-
if (typeof time === 'string') {
|
|
23
|
-
const match = time.match(/(\d+)\/(\d+)/);
|
|
24
|
-
if (match) {
|
|
25
|
-
voiceTime = {
|
|
26
|
-
num_beats: parseInt(match[1]),
|
|
27
|
-
beat_value: parseInt(match[2]),
|
|
28
|
-
};
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
voiceTime = time;
|
|
33
|
-
}
|
|
34
|
-
this.time = Object.assign({ num_beats: 4, beat_value: 4, resolution: Tables.RESOLUTION }, voiceTime);
|
|
35
|
-
this.totalTicks = new Fraction(this.time.num_beats * (this.time.resolution / this.time.beat_value), 1);
|
|
36
|
-
this.smallestTickCount = this.totalTicks.clone();
|
|
37
|
-
}
|
|
38
|
-
static get CATEGORY() {
|
|
39
|
-
return "Voice";
|
|
40
|
-
}
|
|
41
|
-
static get Mode() {
|
|
42
|
-
return VoiceMode;
|
|
43
|
-
}
|
|
44
|
-
getTotalTicks() {
|
|
45
|
-
return this.totalTicks;
|
|
46
|
-
}
|
|
47
|
-
getTicksUsed() {
|
|
48
|
-
return this.ticksUsed;
|
|
49
|
-
}
|
|
50
|
-
getLargestTickWidth() {
|
|
51
|
-
return this.largestTickWidth;
|
|
52
|
-
}
|
|
53
|
-
getSmallestTickCount() {
|
|
54
|
-
return this.smallestTickCount;
|
|
55
|
-
}
|
|
56
|
-
getTickables() {
|
|
57
|
-
return this.tickables;
|
|
58
|
-
}
|
|
59
|
-
getMode() {
|
|
60
|
-
return this.mode;
|
|
61
|
-
}
|
|
62
|
-
setMode(mode) {
|
|
63
|
-
this.mode = mode;
|
|
64
|
-
return this;
|
|
65
|
-
}
|
|
66
|
-
getResolutionMultiplier() {
|
|
67
|
-
return this.resolutionMultiplier;
|
|
68
|
-
}
|
|
69
|
-
getActualResolution() {
|
|
70
|
-
return this.resolutionMultiplier * this.time.resolution;
|
|
71
|
-
}
|
|
72
|
-
setStave(stave) {
|
|
73
|
-
this.stave = stave;
|
|
74
|
-
this.boundingBox = undefined;
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
|
-
getStave() {
|
|
78
|
-
return this.stave;
|
|
79
|
-
}
|
|
80
|
-
getBoundingBox() {
|
|
81
|
-
if (!this.boundingBox) {
|
|
82
|
-
const stave = this.checkStave();
|
|
83
|
-
let boundingBox = undefined;
|
|
84
|
-
for (let i = 0; i < this.tickables.length; ++i) {
|
|
85
|
-
const tickable = this.tickables[i];
|
|
86
|
-
tickable.setStave(stave);
|
|
87
|
-
const bb = tickable.getBoundingBox();
|
|
88
|
-
if (bb) {
|
|
89
|
-
boundingBox = boundingBox ? boundingBox.mergeWith(bb) : bb;
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
this.boundingBox = boundingBox;
|
|
93
|
-
}
|
|
94
|
-
return this.boundingBox;
|
|
95
|
-
}
|
|
96
|
-
setStrict(strict) {
|
|
97
|
-
this.mode = strict ? VoiceMode.STRICT : VoiceMode.SOFT;
|
|
98
|
-
return this;
|
|
99
|
-
}
|
|
100
|
-
isComplete() {
|
|
101
|
-
if (this.mode === VoiceMode.STRICT || this.mode === VoiceMode.FULL) {
|
|
102
|
-
return this.ticksUsed.equals(this.totalTicks);
|
|
103
|
-
}
|
|
104
|
-
else {
|
|
105
|
-
return true;
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
setSoftmaxFactor(factor) {
|
|
109
|
-
this.options.softmaxFactor = factor;
|
|
110
|
-
return this;
|
|
111
|
-
}
|
|
112
|
-
reCalculateExpTicksUsed() {
|
|
113
|
-
const totalTicks = this.ticksUsed.value();
|
|
114
|
-
const exp = (tickable) => Math.pow(this.options.softmaxFactor, tickable.getTicks().value() / totalTicks);
|
|
115
|
-
this.expTicksUsed = this.tickables.map(exp).reduce((a, b) => a + b, 0);
|
|
116
|
-
return this.expTicksUsed;
|
|
117
|
-
}
|
|
118
|
-
softmax(tickValue) {
|
|
119
|
-
if (!this.expTicksUsed) {
|
|
120
|
-
this.expTicksUsed = this.reCalculateExpTicksUsed();
|
|
121
|
-
}
|
|
122
|
-
const totalTicks = this.ticksUsed.value();
|
|
123
|
-
const exp = (v) => Math.pow(this.options.softmaxFactor, v / totalTicks);
|
|
124
|
-
const sm = exp(tickValue) / this.expTicksUsed;
|
|
125
|
-
return sm;
|
|
126
|
-
}
|
|
127
|
-
addTickable(tickable) {
|
|
128
|
-
if (!tickable.shouldIgnoreTicks()) {
|
|
129
|
-
const ticks = tickable.getTicks();
|
|
130
|
-
this.ticksUsed.add(ticks);
|
|
131
|
-
this.expTicksUsed = 0;
|
|
132
|
-
if ((this.mode === VoiceMode.STRICT || this.mode === VoiceMode.FULL) &&
|
|
133
|
-
this.ticksUsed.greaterThan(this.totalTicks)) {
|
|
134
|
-
this.ticksUsed.subtract(ticks);
|
|
135
|
-
throw new RuntimeError('BadArgument', 'Too many ticks.');
|
|
136
|
-
}
|
|
137
|
-
if (ticks.lessThan(this.smallestTickCount)) {
|
|
138
|
-
this.smallestTickCount = ticks.clone();
|
|
139
|
-
}
|
|
140
|
-
this.resolutionMultiplier = this.ticksUsed.denominator;
|
|
141
|
-
this.totalTicks.add(0, this.ticksUsed.denominator);
|
|
142
|
-
}
|
|
143
|
-
this.tickables.push(tickable);
|
|
144
|
-
tickable.setVoice(this);
|
|
145
|
-
return this;
|
|
146
|
-
}
|
|
147
|
-
addTickables(tickables) {
|
|
148
|
-
for (let i = 0; i < tickables.length; ++i) {
|
|
149
|
-
this.addTickable(tickables[i]);
|
|
150
|
-
}
|
|
151
|
-
return this;
|
|
152
|
-
}
|
|
153
|
-
preFormat() {
|
|
154
|
-
if (this.preFormatted)
|
|
155
|
-
return this;
|
|
156
|
-
const stave = this.checkStave();
|
|
157
|
-
this.tickables.forEach((tickable) => {
|
|
158
|
-
if (!tickable.getStave()) {
|
|
159
|
-
tickable.setStave(stave);
|
|
160
|
-
}
|
|
161
|
-
});
|
|
162
|
-
this.preFormatted = true;
|
|
163
|
-
return this;
|
|
164
|
-
}
|
|
165
|
-
checkStave() {
|
|
166
|
-
return defined(this.stave, 'NoStave', 'No stave attached to instance.');
|
|
167
|
-
}
|
|
168
|
-
draw(context = this.checkContext(), stave) {
|
|
169
|
-
stave = stave !== null && stave !== void 0 ? stave : this.stave;
|
|
170
|
-
this.setRendered();
|
|
171
|
-
let boundingBox = undefined;
|
|
172
|
-
for (let i = 0; i < this.tickables.length; ++i) {
|
|
173
|
-
const tickable = this.tickables[i];
|
|
174
|
-
if (stave) {
|
|
175
|
-
tickable.setStave(stave);
|
|
176
|
-
}
|
|
177
|
-
defined(tickable.getStave(), 'MissingStave', 'The voice cannot draw tickables without staves.');
|
|
178
|
-
const bb = tickable.getBoundingBox();
|
|
179
|
-
if (bb) {
|
|
180
|
-
boundingBox = boundingBox ? boundingBox.mergeWith(bb) : bb;
|
|
181
|
-
}
|
|
182
|
-
tickable.setContext(context);
|
|
183
|
-
tickable.drawWithStyle();
|
|
184
|
-
}
|
|
185
|
-
this.boundingBox = boundingBox;
|
|
186
|
-
}
|
|
187
|
-
}
|
package/build/esm/src/web.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { globalObject } from './util.js';
|
|
2
|
-
export function isHTMLCanvas(element) {
|
|
3
|
-
if (!element)
|
|
4
|
-
return false;
|
|
5
|
-
const global = globalObject();
|
|
6
|
-
return ((typeof global.HTMLCanvasElement === 'function' && element instanceof global.HTMLCanvasElement) ||
|
|
7
|
-
(typeof element.getContext === 'function' && typeof element.toDataURL === 'function'));
|
|
8
|
-
}
|
|
9
|
-
export function isHTMLDiv(element) {
|
|
10
|
-
if (!element)
|
|
11
|
-
return false;
|
|
12
|
-
const global = globalObject();
|
|
13
|
-
return ((typeof global.HTMLDivElement === 'function' && element instanceof global.HTMLDivElement) ||
|
|
14
|
-
(typeof element.appendChild === 'function' && typeof element.style === 'object'));
|
|
15
|
-
}
|