vexflow 4.0.1-beta.1 → 4.0.1-beta.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/cjs/vexflow-bravura.js +2 -2
- package/build/cjs/vexflow-bravura.js.map +1 -1
- package/build/cjs/vexflow-core.js +2 -2
- package/build/cjs/vexflow-core.js.map +1 -1
- package/build/cjs/vexflow-debug-with-tests.js +92 -24
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +38 -16
- package/build/cjs/vexflow-debug.js.map +1 -1
- package/build/cjs/vexflow-font-gonville.js +1 -1
- package/build/cjs/vexflow-font-gonville.js.map +1 -1
- package/build/cjs/vexflow-gonville.js +2 -2
- package/build/cjs/vexflow-gonville.js.map +1 -1
- package/build/cjs/vexflow-petaluma.js +2 -2
- package/build/cjs/vexflow-petaluma.js.map +1 -1
- package/build/cjs/vexflow.js +2 -2
- package/build/cjs/vexflow.js.map +1 -1
- package/build/esm/entry/vexflow-bravura.js +11 -0
- package/build/esm/entry/vexflow-core.js +54 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +4 -0
- package/build/esm/entry/vexflow-debug.js +3 -0
- package/build/esm/entry/vexflow-font-bravura.js +7 -0
- package/build/esm/entry/vexflow-font-custom.js +7 -0
- package/build/esm/entry/vexflow-font-gonville.js +7 -0
- package/build/esm/entry/vexflow-font-petaluma.js +7 -0
- package/build/esm/entry/vexflow-gonville.js +11 -0
- package/build/esm/entry/vexflow-petaluma.js +11 -0
- package/build/esm/entry/vexflow.js +9 -0
- package/build/esm/src/accidental.js +348 -0
- package/build/esm/src/annotation.js +232 -0
- package/build/esm/src/articulation.js +267 -0
- package/build/esm/src/barnote.js +58 -0
- package/build/esm/src/beam.js +632 -0
- package/build/esm/src/bend.js +202 -0
- package/build/esm/src/boundingbox.js +59 -0
- package/build/esm/src/boundingboxcomputation.js +107 -0
- package/build/esm/src/canvascontext.js +202 -0
- package/build/esm/src/chordsymbol.js +578 -0
- package/build/esm/src/clef.js +153 -0
- package/build/esm/src/clefnote.js +65 -0
- package/build/esm/src/crescendo.js +77 -0
- package/build/esm/src/curve.js +118 -0
- package/build/esm/src/dot.js +137 -0
- package/build/esm/src/easyscore.js +374 -0
- package/build/esm/src/element.js +216 -0
- package/build/esm/src/factory.js +440 -0
- package/build/esm/src/flow.js +275 -0
- package/build/esm/src/font.js +264 -0
- package/build/esm/src/fonts/bravura_glyphs.js +3239 -0
- package/build/esm/src/fonts/bravura_metrics.js +507 -0
- package/build/esm/src/fonts/custom_glyphs.js +78 -0
- package/build/esm/src/fonts/custom_metrics.js +5 -0
- package/build/esm/src/fonts/gonville_glyphs.js +828 -0
- package/build/esm/src/fonts/gonville_metrics.js +421 -0
- package/build/esm/src/fonts/load_all.js +10 -0
- package/build/esm/src/fonts/load_bravura.js +6 -0
- package/build/esm/src/fonts/load_custom.js +6 -0
- package/build/esm/src/fonts/load_gonville.js +6 -0
- package/build/esm/src/fonts/load_petaluma.js +6 -0
- package/build/esm/src/fonts/petaluma_glyphs.js +1335 -0
- package/build/esm/src/fonts/petaluma_metrics.js +536 -0
- package/build/esm/src/fonts/petalumascript_glyphs.js +863 -0
- package/build/esm/src/fonts/robotoslab_glyphs.js +863 -0
- package/build/esm/src/fonts/textfonts.js +44 -0
- package/build/esm/src/formatter.js +568 -0
- package/build/esm/src/fraction.js +171 -0
- package/build/esm/src/frethandfinger.js +156 -0
- package/build/esm/src/ghostnote.js +50 -0
- package/build/esm/src/glyph.js +331 -0
- package/build/esm/src/glyphnote.js +55 -0
- package/build/esm/src/gracenote.js +133 -0
- package/build/esm/src/gracenotegroup.js +128 -0
- package/build/esm/src/gracetabnote.js +12 -0
- package/build/esm/src/index.js +91 -0
- package/build/esm/src/keymanager.js +99 -0
- package/build/esm/src/keysignature.js +250 -0
- package/build/esm/src/keysignote.js +28 -0
- package/build/esm/src/modifier.js +128 -0
- package/build/esm/src/modifiercontext.js +110 -0
- package/build/esm/src/multimeasurerest.js +173 -0
- package/build/esm/src/music.js +322 -0
- package/build/esm/src/note.js +371 -0
- package/build/esm/src/notehead.js +169 -0
- package/build/esm/src/notesubgroup.js +59 -0
- package/build/esm/src/ornament.js +206 -0
- package/build/esm/src/parenthesis.js +76 -0
- package/build/esm/src/parser.js +164 -0
- package/build/esm/src/pedalmarking.js +192 -0
- package/build/esm/src/registry.js +81 -0
- package/build/esm/src/rendercontext.js +24 -0
- package/build/esm/src/renderer.js +112 -0
- package/build/esm/src/repeatnote.js +22 -0
- package/build/esm/src/stave.js +547 -0
- package/build/esm/src/stavebarline.js +182 -0
- package/build/esm/src/staveconnector.js +196 -0
- package/build/esm/src/stavehairpin.js +120 -0
- package/build/esm/src/staveline.js +218 -0
- package/build/esm/src/stavemodifier.js +77 -0
- package/build/esm/src/stavenote.js +855 -0
- package/build/esm/src/staverepetition.js +155 -0
- package/build/esm/src/stavesection.js +58 -0
- package/build/esm/src/stavetempo.js +91 -0
- package/build/esm/src/stavetext.js +82 -0
- package/build/esm/src/stavetie.js +141 -0
- package/build/esm/src/stavevolta.js +67 -0
- package/build/esm/src/stem.js +131 -0
- package/build/esm/src/stemmablenote.js +193 -0
- package/build/esm/src/stringnumber.js +231 -0
- package/build/esm/src/strokes.js +200 -0
- package/build/esm/src/svgcontext.js +414 -0
- package/build/esm/src/system.js +116 -0
- package/build/esm/src/tables.js +1102 -0
- package/build/esm/src/tabnote.js +299 -0
- package/build/esm/src/tabslide.js +76 -0
- package/build/esm/src/tabstave.js +17 -0
- package/build/esm/src/tabtie.js +19 -0
- package/build/esm/src/textbracket.js +144 -0
- package/build/esm/src/textdynamics.js +81 -0
- package/build/esm/src/textformatter.js +177 -0
- package/build/esm/src/textnote.js +176 -0
- package/build/esm/src/tickable.js +214 -0
- package/build/esm/src/tickcontext.js +170 -0
- package/build/esm/src/timesigglyph.js +85 -0
- package/build/esm/src/timesignature.js +89 -0
- package/build/esm/src/timesignote.js +32 -0
- package/build/esm/src/tremolo.js +47 -0
- package/build/esm/src/tuning.js +54 -0
- package/build/esm/src/tuplet.js +240 -0
- package/build/esm/src/typeguard.js +30 -0
- package/build/esm/src/util.js +58 -0
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vex.js +51 -0
- package/build/esm/src/vibrato.js +100 -0
- package/build/esm/src/vibratobracket.js +50 -0
- package/build/esm/src/voice.js +187 -0
- package/build/esm/src/web.js +15 -0
- package/build/esm/tests/accidental_tests.js +974 -0
- package/build/esm/tests/annotation_tests.js +377 -0
- package/build/esm/tests/articulation_tests.js +365 -0
- package/build/esm/tests/auto_beam_formatting_tests.js +548 -0
- package/build/esm/tests/bach_tests.js +335 -0
- package/build/esm/tests/barline_tests.js +52 -0
- package/build/esm/tests/beam_tests.js +595 -0
- package/build/esm/tests/bend_tests.js +215 -0
- package/build/esm/tests/boundingbox_tests.js +53 -0
- package/build/esm/tests/boundingboxcomputation_tests.js +183 -0
- package/build/esm/tests/chordsymbol_tests.js +320 -0
- package/build/esm/tests/clef_tests.js +131 -0
- package/build/esm/tests/curve_tests.js +118 -0
- package/build/esm/tests/dot_tests.js +123 -0
- package/build/esm/tests/easyscore_tests.js +459 -0
- package/build/esm/tests/factory_tests.js +44 -0
- package/build/esm/tests/font_tests.js +135 -0
- package/build/esm/tests/formatter/framestack.js +61 -0
- package/build/esm/tests/formatter/tests.js +203 -0
- package/build/esm/tests/formatter_tests.js +669 -0
- package/build/esm/tests/fraction_tests.js +72 -0
- package/build/esm/tests/ghostnote_tests.js +77 -0
- package/build/esm/tests/glyphnote_tests.js +113 -0
- package/build/esm/tests/gracenote_tests.js +413 -0
- package/build/esm/tests/gracetabnote_tests.js +79 -0
- package/build/esm/tests/index.js +68 -0
- package/build/esm/tests/key_clef_tests.js +103 -0
- package/build/esm/tests/keymanager_tests.js +68 -0
- package/build/esm/tests/keysignature_tests.js +308 -0
- package/build/esm/tests/mocks.js +71 -0
- package/build/esm/tests/modifier_tests.js +24 -0
- package/build/esm/tests/multimeasurerest_tests.js +141 -0
- package/build/esm/tests/music_tests.js +161 -0
- package/build/esm/tests/notehead_tests.js +137 -0
- package/build/esm/tests/notesubgroup_tests.js +149 -0
- package/build/esm/tests/offscreencanvas_tests.js +47 -0
- package/build/esm/tests/ornament_tests.js +298 -0
- package/build/esm/tests/parser_tests.js +122 -0
- package/build/esm/tests/pedalmarking_tests.js +64 -0
- package/build/esm/tests/percussion_tests.js +180 -0
- package/build/esm/tests/registry_tests.js +64 -0
- package/build/esm/tests/renderer_tests.js +113 -0
- package/build/esm/tests/rests_tests.js +248 -0
- package/build/esm/tests/rhythm_tests.js +357 -0
- package/build/esm/tests/stave_tests.js +560 -0
- package/build/esm/tests/staveconnector_tests.js +402 -0
- package/build/esm/tests/stavehairpin_tests.js +90 -0
- package/build/esm/tests/staveline_tests.js +122 -0
- package/build/esm/tests/stavemodifier_tests.js +51 -0
- package/build/esm/tests/stavenote_tests.js +867 -0
- package/build/esm/tests/stavetie_tests.js +108 -0
- package/build/esm/tests/stringnumber_tests.js +259 -0
- package/build/esm/tests/strokes_tests.js +275 -0
- package/build/esm/tests/style_tests.js +98 -0
- package/build/esm/tests/support/qunit.js +2765 -0
- package/build/esm/tests/tabnote_tests.js +474 -0
- package/build/esm/tests/tabslide_tests.js +135 -0
- package/build/esm/tests/tabstave_tests.js +23 -0
- package/build/esm/tests/tabtie_tests.js +173 -0
- package/build/esm/tests/textbracket_tests.js +100 -0
- package/build/esm/tests/textformatter_tests.js +24 -0
- package/build/esm/tests/textnote_tests.js +215 -0
- package/build/esm/tests/threevoice_tests.js +132 -0
- package/build/esm/tests/tickcontext_tests.js +36 -0
- package/build/esm/tests/timesignature_tests.js +134 -0
- package/build/esm/tests/tremolo_tests.js +75 -0
- package/build/esm/tests/tuning_tests.js +56 -0
- package/build/esm/tests/tuplet_tests.js +450 -0
- package/build/esm/tests/typeguard_tests.js +82 -0
- package/build/esm/tests/vexflow_test_helpers.js +266 -0
- package/build/esm/tests/vf_prefix_tests.js +115 -0
- package/build/esm/tests/vibrato_tests.js +92 -0
- package/build/esm/tests/vibratobracket_tests.js +45 -0
- package/build/esm/tests/voice_tests.js +69 -0
- package/build/types/entry/vexflow-bravura.d.ts +3 -0
- package/build/types/entry/vexflow-core.d.ts +3 -0
- package/build/types/entry/vexflow-debug.d.ts +3 -0
- package/build/types/entry/vexflow-font-bravura.d.ts +3771 -0
- package/build/types/entry/vexflow-font-custom.d.ts +86 -0
- package/build/types/entry/vexflow-font-gonville.d.ts +1267 -0
- package/build/types/entry/vexflow-font-petaluma.d.ts +1896 -0
- package/build/types/entry/vexflow-gonville.d.ts +3 -0
- package/build/types/entry/vexflow-petaluma.d.ts +3 -0
- package/build/types/entry/vexflow.d.ts +3 -0
- package/build/types/src/accidental.d.ts +66 -0
- package/build/types/src/annotation.d.ts +60 -0
- package/build/types/src/articulation.d.ts +62 -0
- package/build/types/src/barnote.d.ts +29 -0
- package/build/types/src/beam.d.ts +124 -0
- package/build/types/src/bend.d.ts +73 -0
- package/build/types/src/boundingbox.d.ts +42 -0
- package/build/types/src/boundingboxcomputation.d.ts +33 -0
- package/build/types/src/canvascontext.d.ts +89 -0
- package/build/types/src/chordsymbol.d.ts +149 -0
- package/build/types/src/clef.d.ts +48 -0
- package/build/types/src/clefnote.d.ts +25 -0
- package/build/types/src/crescendo.d.ts +27 -0
- package/build/types/src/curve.d.ts +41 -0
- package/build/types/src/dot.d.ts +20 -0
- package/build/types/src/easyscore.d.ts +148 -0
- package/build/types/src/element.d.ts +202 -0
- package/build/types/src/factory.d.ts +271 -0
- package/build/types/src/flow.d.ts +245 -0
- package/build/types/src/font.d.ts +181 -0
- package/build/types/src/fonts/bravura_glyphs.d.ts +3239 -0
- package/build/types/src/fonts/bravura_metrics.d.ts +533 -0
- package/build/types/src/fonts/custom_glyphs.d.ts +78 -0
- package/build/types/src/fonts/custom_metrics.d.ts +5 -0
- package/build/types/src/fonts/gonville_glyphs.d.ts +828 -0
- package/build/types/src/fonts/gonville_metrics.d.ts +440 -0
- package/build/types/src/fonts/load_all.d.ts +1 -0
- package/build/types/src/fonts/load_bravura.d.ts +1 -0
- package/build/types/src/fonts/load_custom.d.ts +1 -0
- package/build/types/src/fonts/load_gonville.d.ts +1 -0
- package/build/types/src/fonts/load_petaluma.d.ts +1 -0
- package/build/types/src/fonts/petaluma_glyphs.d.ts +1335 -0
- package/build/types/src/fonts/petaluma_metrics.d.ts +562 -0
- package/build/types/src/fonts/petalumascript_glyphs.d.ts +863 -0
- package/build/types/src/fonts/robotoslab_glyphs.d.ts +863 -0
- package/build/types/src/fonts/textfonts.d.ts +1 -0
- package/build/types/src/formatter.d.ts +203 -0
- package/build/types/src/fraction.d.ts +62 -0
- package/build/types/src/frethandfinger.d.ts +22 -0
- package/build/types/src/ghostnote.d.ts +16 -0
- package/build/types/src/glyph.d.ts +139 -0
- package/build/types/src/glyphnote.d.ts +17 -0
- package/build/types/src/gracenote.d.ts +19 -0
- package/build/types/src/gracenotegroup.d.ts +33 -0
- package/build/types/src/gracetabnote.d.ts +5 -0
- package/build/types/src/index.d.ts +91 -0
- package/build/types/src/keymanager.d.ts +25 -0
- package/build/types/src/keysignature.d.ts +50 -0
- package/build/types/src/keysignote.d.ts +11 -0
- package/build/types/src/modifier.d.ts +97 -0
- package/build/types/src/modifiercontext.d.ts +45 -0
- package/build/types/src/multimeasurerest.d.ts +61 -0
- package/build/types/src/music.d.ts +91 -0
- package/build/types/src/note.d.ts +231 -0
- package/build/types/src/notehead.d.ts +70 -0
- package/build/types/src/notesubgroup.d.ts +18 -0
- package/build/types/src/ornament.d.ts +76 -0
- package/build/types/src/parenthesis.d.ts +22 -0
- package/build/types/src/parser.d.ts +45 -0
- package/build/types/src/pedalmarking.d.ts +69 -0
- package/build/types/src/registry.d.ts +40 -0
- package/build/types/src/rendercontext.d.ts +64 -0
- package/build/types/src/renderer.d.ts +35 -0
- package/build/types/src/repeatnote.d.ts +6 -0
- package/build/types/src/stave.d.ts +186 -0
- package/build/types/src/stavebarline.d.ts +28 -0
- package/build/types/src/staveconnector.d.ts +67 -0
- package/build/types/src/stavehairpin.d.ts +56 -0
- package/build/types/src/staveline.d.ts +57 -0
- package/build/types/src/stavemodifier.d.ts +44 -0
- package/build/types/src/stavenote.d.ts +154 -0
- package/build/types/src/staverepetition.d.ts +32 -0
- package/build/types/src/stavesection.d.ts +15 -0
- package/build/types/src/stavetempo.d.ts +25 -0
- package/build/types/src/stavetext.d.ts +25 -0
- package/build/types/src/stavetie.d.ts +59 -0
- package/build/types/src/stavevolta.d.ts +21 -0
- package/build/types/src/stem.d.ts +58 -0
- package/build/types/src/stemmablenote.d.ts +39 -0
- package/build/types/src/stringnumber.d.ts +27 -0
- package/build/types/src/strokes.d.ts +33 -0
- package/build/types/src/svgcontext.d.ts +131 -0
- package/build/types/src/system.d.ts +92 -0
- package/build/types/src/tables.d.ts +96 -0
- package/build/types/src/tabnote.d.ts +44 -0
- package/build/types/src/tabslide.d.ts +34 -0
- package/build/types/src/tabstave.d.ts +7 -0
- package/build/types/src/tabtie.d.ts +18 -0
- package/build/types/src/textbracket.d.ts +55 -0
- package/build/types/src/textdynamics.d.ts +39 -0
- package/build/types/src/textformatter.d.ts +109 -0
- package/build/types/src/textnote.d.ts +49 -0
- package/build/types/src/tickable.d.ts +140 -0
- package/build/types/src/tickcontext.d.ts +82 -0
- package/build/types/src/timesigglyph.d.ts +14 -0
- package/build/types/src/timesignature.d.ts +26 -0
- package/build/types/src/timesignote.d.ts +11 -0
- package/build/types/src/tremolo.d.ts +17 -0
- package/build/types/src/tuning.d.ts +23 -0
- package/build/types/src/tuplet.d.ts +105 -0
- package/build/types/src/typeguard.d.ts +99 -0
- package/build/types/src/util.d.ts +27 -0
- package/build/types/src/version.d.ts +3 -0
- package/build/types/src/vex.d.ts +18 -0
- package/build/types/src/vibrato.d.ts +29 -0
- package/build/types/src/vibratobracket.d.ts +33 -0
- package/build/types/src/voice.d.ts +108 -0
- package/build/types/src/web.d.ts +2 -0
- package/package.json +1 -1
- package/src/annotation.ts +27 -6
- package/src/articulation.ts +8 -2
- package/src/fonts/gonville_glyphs.ts +4 -4
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Note } from './note.js';
|
|
2
|
+
export class GlyphNote extends Note {
|
|
3
|
+
constructor(glyph, noteStruct, options) {
|
|
4
|
+
super(noteStruct);
|
|
5
|
+
this.options = Object.assign({ ignoreTicks: false, line: 2 }, options);
|
|
6
|
+
this.ignore_ticks = this.options.ignoreTicks;
|
|
7
|
+
if (glyph) {
|
|
8
|
+
this.setGlyph(glyph);
|
|
9
|
+
}
|
|
10
|
+
}
|
|
11
|
+
static get CATEGORY() {
|
|
12
|
+
return "GlyphNote";
|
|
13
|
+
}
|
|
14
|
+
setGlyph(glyph) {
|
|
15
|
+
this.glyph = glyph;
|
|
16
|
+
this.setWidth(this.glyph.getMetrics().width);
|
|
17
|
+
return this;
|
|
18
|
+
}
|
|
19
|
+
getBoundingBox() {
|
|
20
|
+
return this.glyph.getBoundingBox();
|
|
21
|
+
}
|
|
22
|
+
preFormat() {
|
|
23
|
+
if (!this.preFormatted && this.modifierContext) {
|
|
24
|
+
this.modifierContext.preFormat();
|
|
25
|
+
}
|
|
26
|
+
this.preFormatted = true;
|
|
27
|
+
return this;
|
|
28
|
+
}
|
|
29
|
+
drawModifiers() {
|
|
30
|
+
const ctx = this.checkContext();
|
|
31
|
+
ctx.openGroup('modifiers');
|
|
32
|
+
for (let i = 0; i < this.modifiers.length; i++) {
|
|
33
|
+
const modifier = this.modifiers[i];
|
|
34
|
+
modifier.setContext(ctx);
|
|
35
|
+
modifier.drawWithStyle();
|
|
36
|
+
}
|
|
37
|
+
ctx.closeGroup();
|
|
38
|
+
}
|
|
39
|
+
draw() {
|
|
40
|
+
const stave = this.checkStave();
|
|
41
|
+
const ctx = stave.checkContext();
|
|
42
|
+
this.setRendered();
|
|
43
|
+
ctx.openGroup('glyphNote', this.getAttribute('id'));
|
|
44
|
+
const glyph = this.glyph;
|
|
45
|
+
if (!glyph.getContext()) {
|
|
46
|
+
glyph.setContext(ctx);
|
|
47
|
+
}
|
|
48
|
+
glyph.setStave(stave);
|
|
49
|
+
glyph.setYShift(stave.getYForLine(this.options.line) - stave.getYForGlyphs());
|
|
50
|
+
const x = this.isCenterAligned() ? this.getAbsoluteX() - this.getWidth() / 2 : this.getAbsoluteX();
|
|
51
|
+
glyph.renderToStave(x);
|
|
52
|
+
this.drawModifiers();
|
|
53
|
+
ctx.closeGroup();
|
|
54
|
+
}
|
|
55
|
+
}
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
import { StaveNote } from './stavenote.js';
|
|
2
|
+
import { Stem } from './stem.js';
|
|
3
|
+
import { Tables } from './tables.js';
|
|
4
|
+
import { RuntimeError } from './util.js';
|
|
5
|
+
export class GraceNote extends StaveNote {
|
|
6
|
+
constructor(noteStruct) {
|
|
7
|
+
super(Object.assign({ glyph_font_scale: Tables.NOTATION_FONT_SCALE * GraceNote.SCALE, stroke_px: GraceNote.LEDGER_LINE_OFFSET }, noteStruct));
|
|
8
|
+
this.slash = noteStruct.slash || false;
|
|
9
|
+
this.slur = true;
|
|
10
|
+
this.buildNoteHeads();
|
|
11
|
+
this.width = 3;
|
|
12
|
+
}
|
|
13
|
+
static get CATEGORY() {
|
|
14
|
+
return "GraceNote";
|
|
15
|
+
}
|
|
16
|
+
static get LEDGER_LINE_OFFSET() {
|
|
17
|
+
return 2;
|
|
18
|
+
}
|
|
19
|
+
static get SCALE() {
|
|
20
|
+
return 0.66;
|
|
21
|
+
}
|
|
22
|
+
getStemExtension() {
|
|
23
|
+
if (this.stem_extension_override) {
|
|
24
|
+
return this.stem_extension_override;
|
|
25
|
+
}
|
|
26
|
+
const glyph = this.getGlyph();
|
|
27
|
+
if (glyph) {
|
|
28
|
+
let ret = super.getStemExtension();
|
|
29
|
+
if (glyph.stem) {
|
|
30
|
+
const staveNoteScale = this.getStaveNoteScale();
|
|
31
|
+
ret = (Stem.HEIGHT + ret) * staveNoteScale - Stem.HEIGHT;
|
|
32
|
+
}
|
|
33
|
+
return ret;
|
|
34
|
+
}
|
|
35
|
+
return 0;
|
|
36
|
+
}
|
|
37
|
+
getStaveNoteScale() {
|
|
38
|
+
return this.render_options.glyph_font_scale / Tables.NOTATION_FONT_SCALE;
|
|
39
|
+
}
|
|
40
|
+
draw() {
|
|
41
|
+
super.draw();
|
|
42
|
+
this.setRendered();
|
|
43
|
+
const stem = this.stem;
|
|
44
|
+
if (this.slash && stem) {
|
|
45
|
+
const staveNoteScale = this.getStaveNoteScale();
|
|
46
|
+
const offsetScale = staveNoteScale / 0.66;
|
|
47
|
+
let slashBBox = undefined;
|
|
48
|
+
const beam = this.beam;
|
|
49
|
+
if (beam) {
|
|
50
|
+
if (!beam.postFormatted) {
|
|
51
|
+
beam.postFormat();
|
|
52
|
+
}
|
|
53
|
+
slashBBox = this.calcBeamedNotesSlashBBox(8 * offsetScale, 8 * offsetScale, {
|
|
54
|
+
stem: 6 * offsetScale,
|
|
55
|
+
beam: 5 * offsetScale,
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
const stem_direction = this.getStemDirection();
|
|
60
|
+
const noteHeadBounds = this.getNoteHeadBounds();
|
|
61
|
+
const noteStemHeight = stem.getHeight();
|
|
62
|
+
let x = this.getAbsoluteX();
|
|
63
|
+
let y = stem_direction === Stem.DOWN
|
|
64
|
+
? noteHeadBounds.y_top - noteStemHeight
|
|
65
|
+
: noteHeadBounds.y_bottom - noteStemHeight;
|
|
66
|
+
const defaultStemExtention = stem_direction === Stem.DOWN ? this.glyph.stem_down_extension : this.glyph.stem_up_extension;
|
|
67
|
+
let defaultOffsetY = Tables.STEM_HEIGHT;
|
|
68
|
+
defaultOffsetY -= defaultOffsetY / 2.8;
|
|
69
|
+
defaultOffsetY += defaultStemExtention;
|
|
70
|
+
y += defaultOffsetY * staveNoteScale * stem_direction;
|
|
71
|
+
const offsets = stem_direction === Stem.UP
|
|
72
|
+
? {
|
|
73
|
+
x1: 1,
|
|
74
|
+
y1: 0,
|
|
75
|
+
x2: 13,
|
|
76
|
+
y2: -9,
|
|
77
|
+
}
|
|
78
|
+
: {
|
|
79
|
+
x1: -4,
|
|
80
|
+
y1: 1,
|
|
81
|
+
x2: 13,
|
|
82
|
+
y2: 9,
|
|
83
|
+
};
|
|
84
|
+
x += offsets.x1 * offsetScale;
|
|
85
|
+
y += offsets.y1 * offsetScale;
|
|
86
|
+
slashBBox = {
|
|
87
|
+
x1: x,
|
|
88
|
+
y1: y,
|
|
89
|
+
x2: x + offsets.x2 * offsetScale,
|
|
90
|
+
y2: y + offsets.y2 * offsetScale,
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
const ctx = this.checkContext();
|
|
94
|
+
ctx.save();
|
|
95
|
+
ctx.setLineWidth(1 * offsetScale);
|
|
96
|
+
ctx.beginPath();
|
|
97
|
+
ctx.moveTo(slashBBox.x1, slashBBox.y1);
|
|
98
|
+
ctx.lineTo(slashBBox.x2, slashBBox.y2);
|
|
99
|
+
ctx.closePath();
|
|
100
|
+
ctx.stroke();
|
|
101
|
+
ctx.restore();
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
calcBeamedNotesSlashBBox(slashStemOffset, slashBeamOffset, protrusions) {
|
|
105
|
+
const beam = this.beam;
|
|
106
|
+
if (!beam)
|
|
107
|
+
throw new RuntimeError('NoBeam', "Can't calculate without a beam.");
|
|
108
|
+
const beam_slope = beam.slope;
|
|
109
|
+
const isBeamEndNote = beam.notes[beam.notes.length - 1] === this;
|
|
110
|
+
const scaleX = isBeamEndNote ? -1 : 1;
|
|
111
|
+
const beam_angle = Math.atan(beam_slope * scaleX);
|
|
112
|
+
const iPointOnBeam = {
|
|
113
|
+
dx: Math.cos(beam_angle) * slashBeamOffset,
|
|
114
|
+
dy: Math.sin(beam_angle) * slashBeamOffset,
|
|
115
|
+
};
|
|
116
|
+
slashStemOffset *= this.getStemDirection();
|
|
117
|
+
const slash_angle = Math.atan((iPointOnBeam.dy - slashStemOffset) / iPointOnBeam.dx);
|
|
118
|
+
const protrusion_stem_dx = Math.cos(slash_angle) * protrusions.stem * scaleX;
|
|
119
|
+
const protrusion_stem_dy = Math.sin(slash_angle) * protrusions.stem;
|
|
120
|
+
const protrusion_beam_dx = Math.cos(slash_angle) * protrusions.beam * scaleX;
|
|
121
|
+
const protrusion_beam_dy = Math.sin(slash_angle) * protrusions.beam;
|
|
122
|
+
const stemX = this.getStemX();
|
|
123
|
+
const stem0X = beam.notes[0].getStemX();
|
|
124
|
+
const stemY = beam.getBeamYToDraw() + (stemX - stem0X) * beam_slope;
|
|
125
|
+
const ret = {
|
|
126
|
+
x1: stemX - protrusion_stem_dx,
|
|
127
|
+
y1: stemY + slashStemOffset - protrusion_stem_dy,
|
|
128
|
+
x2: stemX + iPointOnBeam.dx * scaleX + protrusion_beam_dx,
|
|
129
|
+
y2: stemY + iPointOnBeam.dy + protrusion_beam_dy,
|
|
130
|
+
};
|
|
131
|
+
return ret;
|
|
132
|
+
}
|
|
133
|
+
}
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Beam } from './beam.js';
|
|
2
|
+
import { Formatter } from './formatter.js';
|
|
3
|
+
import { Modifier } from './modifier.js';
|
|
4
|
+
import { StaveTie } from './stavetie.js';
|
|
5
|
+
import { Tables } from './tables.js';
|
|
6
|
+
import { TabTie } from './tabtie.js';
|
|
7
|
+
import { isStaveNote } from './typeguard.js';
|
|
8
|
+
import { log } from './util.js';
|
|
9
|
+
import { Voice } from './voice.js';
|
|
10
|
+
function L(...args) {
|
|
11
|
+
if (GraceNoteGroup.DEBUG)
|
|
12
|
+
log('Vex.Flow.GraceNoteGroup', args);
|
|
13
|
+
}
|
|
14
|
+
export class GraceNoteGroup extends Modifier {
|
|
15
|
+
constructor(grace_notes, show_slur) {
|
|
16
|
+
super();
|
|
17
|
+
this.preFormatted = false;
|
|
18
|
+
this.position = Modifier.Position.LEFT;
|
|
19
|
+
this.grace_notes = grace_notes;
|
|
20
|
+
this.width = 0;
|
|
21
|
+
this.show_slur = show_slur;
|
|
22
|
+
this.slur = undefined;
|
|
23
|
+
this.voice = new Voice({
|
|
24
|
+
num_beats: 4,
|
|
25
|
+
beat_value: 4,
|
|
26
|
+
resolution: Tables.RESOLUTION,
|
|
27
|
+
}).setStrict(false);
|
|
28
|
+
this.render_options = {
|
|
29
|
+
slur_y_shift: 0,
|
|
30
|
+
};
|
|
31
|
+
this.beams = [];
|
|
32
|
+
this.voice.addTickables(this.grace_notes);
|
|
33
|
+
return this;
|
|
34
|
+
}
|
|
35
|
+
static get CATEGORY() {
|
|
36
|
+
return "GraceNoteGroup";
|
|
37
|
+
}
|
|
38
|
+
static format(gracenote_groups, state) {
|
|
39
|
+
const group_spacing_stave = 4;
|
|
40
|
+
const group_spacing_tab = 0;
|
|
41
|
+
if (!gracenote_groups || gracenote_groups.length === 0)
|
|
42
|
+
return false;
|
|
43
|
+
const group_list = [];
|
|
44
|
+
let prev_note = null;
|
|
45
|
+
let shiftL = 0;
|
|
46
|
+
for (let i = 0; i < gracenote_groups.length; ++i) {
|
|
47
|
+
const gracenote_group = gracenote_groups[i];
|
|
48
|
+
const note = gracenote_group.getNote();
|
|
49
|
+
const is_stavenote = isStaveNote(note);
|
|
50
|
+
const spacing = is_stavenote ? group_spacing_stave : group_spacing_tab;
|
|
51
|
+
if (is_stavenote && note !== prev_note) {
|
|
52
|
+
for (let n = 0; n < note.keys.length; ++n) {
|
|
53
|
+
shiftL = Math.max(note.getLeftDisplacedHeadPx(), shiftL);
|
|
54
|
+
}
|
|
55
|
+
prev_note = note;
|
|
56
|
+
}
|
|
57
|
+
group_list.push({ shift: shiftL, gracenote_group, spacing });
|
|
58
|
+
}
|
|
59
|
+
let group_shift = group_list[0].shift;
|
|
60
|
+
let formatWidth;
|
|
61
|
+
for (let i = 0; i < group_list.length; ++i) {
|
|
62
|
+
const gracenote_group = group_list[i].gracenote_group;
|
|
63
|
+
gracenote_group.preFormat();
|
|
64
|
+
formatWidth = gracenote_group.getWidth() + group_list[i].spacing;
|
|
65
|
+
group_shift = Math.max(formatWidth, group_shift);
|
|
66
|
+
}
|
|
67
|
+
for (let i = 0; i < group_list.length; ++i) {
|
|
68
|
+
const gracenote_group = group_list[i].gracenote_group;
|
|
69
|
+
formatWidth = gracenote_group.getWidth() + group_list[i].spacing;
|
|
70
|
+
gracenote_group.setSpacingFromNextModifier(group_shift - Math.min(formatWidth, group_shift));
|
|
71
|
+
}
|
|
72
|
+
state.left_shift += group_shift;
|
|
73
|
+
return true;
|
|
74
|
+
}
|
|
75
|
+
preFormat() {
|
|
76
|
+
if (this.preFormatted)
|
|
77
|
+
return;
|
|
78
|
+
if (!this.formatter) {
|
|
79
|
+
this.formatter = new Formatter();
|
|
80
|
+
}
|
|
81
|
+
this.formatter.joinVoices([this.voice]).format([this.voice], 0, {});
|
|
82
|
+
this.setWidth(this.formatter.getMinTotalWidth());
|
|
83
|
+
this.preFormatted = true;
|
|
84
|
+
}
|
|
85
|
+
beamNotes(grace_notes) {
|
|
86
|
+
grace_notes = grace_notes || this.grace_notes;
|
|
87
|
+
if (grace_notes.length > 1) {
|
|
88
|
+
const beam = new Beam(grace_notes);
|
|
89
|
+
beam.render_options.beam_width = 3;
|
|
90
|
+
beam.render_options.partial_beam_length = 4;
|
|
91
|
+
this.beams.push(beam);
|
|
92
|
+
}
|
|
93
|
+
return this;
|
|
94
|
+
}
|
|
95
|
+
setWidth(width) {
|
|
96
|
+
this.width = width;
|
|
97
|
+
return this;
|
|
98
|
+
}
|
|
99
|
+
getWidth() {
|
|
100
|
+
return this.width;
|
|
101
|
+
}
|
|
102
|
+
getGraceNotes() {
|
|
103
|
+
return this.grace_notes;
|
|
104
|
+
}
|
|
105
|
+
draw() {
|
|
106
|
+
const ctx = this.checkContext();
|
|
107
|
+
const note = this.checkAttachedNote();
|
|
108
|
+
this.setRendered();
|
|
109
|
+
L('Drawing grace note group for:', note);
|
|
110
|
+
this.alignSubNotesWithNote(this.getGraceNotes(), note);
|
|
111
|
+
this.grace_notes.forEach((graceNote) => graceNote.setContext(ctx).draw());
|
|
112
|
+
this.beams.forEach((beam) => beam.setContext(ctx).draw());
|
|
113
|
+
if (this.show_slur) {
|
|
114
|
+
const is_stavenote = isStaveNote(note);
|
|
115
|
+
const TieClass = is_stavenote ? StaveTie : TabTie;
|
|
116
|
+
this.slur = new TieClass({
|
|
117
|
+
last_note: this.grace_notes[0],
|
|
118
|
+
first_note: note,
|
|
119
|
+
first_indices: [0],
|
|
120
|
+
last_indices: [0],
|
|
121
|
+
});
|
|
122
|
+
this.slur.render_options.cp2 = 12;
|
|
123
|
+
this.slur.render_options.y_shift = (is_stavenote ? 7 : 5) + this.render_options.slur_y_shift;
|
|
124
|
+
this.slur.setContext(ctx).draw();
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
GraceNoteGroup.DEBUG = false;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Font } from './font.js';
|
|
2
|
+
import { TabNote } from './tabnote.js';
|
|
3
|
+
export class GraceTabNote extends TabNote {
|
|
4
|
+
static get CATEGORY() {
|
|
5
|
+
return "GraceTabNote";
|
|
6
|
+
}
|
|
7
|
+
constructor(noteStruct) {
|
|
8
|
+
super(noteStruct, false);
|
|
9
|
+
this.render_options = Object.assign(Object.assign({}, this.render_options), { y_shift: 0.3, scale: 0.6, font: `7.5pt ${Font.SANS_SERIF}` });
|
|
10
|
+
this.updateWidth();
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { Vex } from './vex.js';
|
|
2
|
+
export * from './accidental.js';
|
|
3
|
+
export * from './annotation.js';
|
|
4
|
+
export * from './articulation.js';
|
|
5
|
+
export * from './barnote.js';
|
|
6
|
+
export * from './beam.js';
|
|
7
|
+
export * from './bend.js';
|
|
8
|
+
export * from './boundingbox.js';
|
|
9
|
+
export * from './boundingboxcomputation.js';
|
|
10
|
+
export * from './canvascontext.js';
|
|
11
|
+
export * from './chordsymbol.js';
|
|
12
|
+
export * from './clef.js';
|
|
13
|
+
export * from './clefnote.js';
|
|
14
|
+
export * from './crescendo.js';
|
|
15
|
+
export * from './curve.js';
|
|
16
|
+
export * from './dot.js';
|
|
17
|
+
export * from './easyscore.js';
|
|
18
|
+
export * from './element.js';
|
|
19
|
+
export * from './factory.js';
|
|
20
|
+
export * from './flow.js';
|
|
21
|
+
export * from './font.js';
|
|
22
|
+
export * from './formatter.js';
|
|
23
|
+
export * from './fraction.js';
|
|
24
|
+
export * from './frethandfinger.js';
|
|
25
|
+
export * from './ghostnote.js';
|
|
26
|
+
export * from './glyph.js';
|
|
27
|
+
export * from './glyphnote.js';
|
|
28
|
+
export * from './gracenote.js';
|
|
29
|
+
export * from './gracenotegroup.js';
|
|
30
|
+
export * from './gracetabnote.js';
|
|
31
|
+
export * from './keymanager.js';
|
|
32
|
+
export * from './keysignature.js';
|
|
33
|
+
export * from './keysignote.js';
|
|
34
|
+
export * from './modifier.js';
|
|
35
|
+
export * from './modifiercontext.js';
|
|
36
|
+
export * from './multimeasurerest.js';
|
|
37
|
+
export * from './music.js';
|
|
38
|
+
export * from './note.js';
|
|
39
|
+
export * from './notehead.js';
|
|
40
|
+
export * from './notesubgroup.js';
|
|
41
|
+
export * from './ornament.js';
|
|
42
|
+
export * from './parenthesis.js';
|
|
43
|
+
export * from './parser.js';
|
|
44
|
+
export * from './pedalmarking.js';
|
|
45
|
+
export * from './registry.js';
|
|
46
|
+
export * from './rendercontext.js';
|
|
47
|
+
export * from './renderer.js';
|
|
48
|
+
export * from './repeatnote.js';
|
|
49
|
+
export * from './stave.js';
|
|
50
|
+
export * from './stavebarline.js';
|
|
51
|
+
export * from './staveconnector.js';
|
|
52
|
+
export * from './stavehairpin.js';
|
|
53
|
+
export * from './staveline.js';
|
|
54
|
+
export * from './stavemodifier.js';
|
|
55
|
+
export * from './stavenote.js';
|
|
56
|
+
export * from './staverepetition.js';
|
|
57
|
+
export * from './stavesection.js';
|
|
58
|
+
export * from './stavetempo.js';
|
|
59
|
+
export * from './stavetext.js';
|
|
60
|
+
export * from './stavetie.js';
|
|
61
|
+
export * from './stavevolta.js';
|
|
62
|
+
export * from './stem.js';
|
|
63
|
+
export * from './stemmablenote.js';
|
|
64
|
+
export * from './stringnumber.js';
|
|
65
|
+
export * from './strokes.js';
|
|
66
|
+
export * from './svgcontext.js';
|
|
67
|
+
export * from './system.js';
|
|
68
|
+
export * from './tabnote.js';
|
|
69
|
+
export * from './tabslide.js';
|
|
70
|
+
export * from './tabstave.js';
|
|
71
|
+
export * from './tabtie.js';
|
|
72
|
+
export * from './textbracket.js';
|
|
73
|
+
export * from './textdynamics.js';
|
|
74
|
+
export * from './textformatter.js';
|
|
75
|
+
export * from './textnote.js';
|
|
76
|
+
export * from './tickable.js';
|
|
77
|
+
export * from './tickcontext.js';
|
|
78
|
+
export * from './timesigglyph.js';
|
|
79
|
+
export * from './timesignature.js';
|
|
80
|
+
export * from './timesignote.js';
|
|
81
|
+
export * from './tremolo.js';
|
|
82
|
+
export * from './tuning.js';
|
|
83
|
+
export * from './tuplet.js';
|
|
84
|
+
export * from './typeguard.js';
|
|
85
|
+
export * from './util.js';
|
|
86
|
+
export * from './vibrato.js';
|
|
87
|
+
export * from './vibratobracket.js';
|
|
88
|
+
export * from './voice.js';
|
|
89
|
+
export * from './web.js';
|
|
90
|
+
export { Vex };
|
|
91
|
+
export default Vex;
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Music } from './music.js';
|
|
2
|
+
import { RuntimeError } from './util.js';
|
|
3
|
+
export class KeyManager {
|
|
4
|
+
constructor(key) {
|
|
5
|
+
this.music = new Music();
|
|
6
|
+
this.setKey(key);
|
|
7
|
+
}
|
|
8
|
+
setKey(key) {
|
|
9
|
+
this.key = key;
|
|
10
|
+
this.reset();
|
|
11
|
+
return this;
|
|
12
|
+
}
|
|
13
|
+
getKey() {
|
|
14
|
+
return this.key;
|
|
15
|
+
}
|
|
16
|
+
reset() {
|
|
17
|
+
this.keyParts = this.music.getKeyParts(this.key);
|
|
18
|
+
this.keyString = this.keyParts.root;
|
|
19
|
+
if (this.keyParts.accidental)
|
|
20
|
+
this.keyString += this.keyParts.accidental;
|
|
21
|
+
const is_supported_type = Music.scaleTypes[this.keyParts.type];
|
|
22
|
+
if (!is_supported_type) {
|
|
23
|
+
throw new RuntimeError('BadArguments', `Unsupported key type: ${this.key}`);
|
|
24
|
+
}
|
|
25
|
+
this.scale = this.music.getScaleTones(this.music.getNoteValue(this.keyString), Music.scaleTypes[this.keyParts.type]);
|
|
26
|
+
this.scaleMap = {};
|
|
27
|
+
this.scaleMapByValue = {};
|
|
28
|
+
this.originalScaleMapByValue = {};
|
|
29
|
+
const noteLocation = Music.root_indices[this.keyParts.root];
|
|
30
|
+
for (let i = 0; i < Music.roots.length; ++i) {
|
|
31
|
+
const index = (noteLocation + i) % Music.roots.length;
|
|
32
|
+
const rootName = Music.roots[index];
|
|
33
|
+
const noteName = this.music.getRelativeNoteName(rootName, this.scale[i]);
|
|
34
|
+
this.scaleMap[rootName] = noteName;
|
|
35
|
+
this.scaleMapByValue[this.scale[i]] = noteName;
|
|
36
|
+
this.originalScaleMapByValue[this.scale[i]] = noteName;
|
|
37
|
+
}
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
getAccidental(key) {
|
|
41
|
+
const root = this.music.getKeyParts(key).root;
|
|
42
|
+
const parts = this.music.getNoteParts(this.scaleMap[root]);
|
|
43
|
+
return {
|
|
44
|
+
note: this.scaleMap[root],
|
|
45
|
+
accidental: parts.accidental,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
selectNote(note) {
|
|
49
|
+
note = note.toLowerCase();
|
|
50
|
+
const parts = this.music.getNoteParts(note);
|
|
51
|
+
const scaleNote = this.scaleMap[parts.root];
|
|
52
|
+
const modparts = this.music.getNoteParts(scaleNote);
|
|
53
|
+
if (scaleNote === note) {
|
|
54
|
+
return {
|
|
55
|
+
note: scaleNote,
|
|
56
|
+
accidental: parts.accidental,
|
|
57
|
+
change: false,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
const valueNote = this.scaleMapByValue[this.music.getNoteValue(note)];
|
|
61
|
+
if (valueNote != null) {
|
|
62
|
+
return {
|
|
63
|
+
note: valueNote,
|
|
64
|
+
accidental: this.music.getNoteParts(valueNote).accidental,
|
|
65
|
+
change: false,
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
const originalValueNote = this.originalScaleMapByValue[this.music.getNoteValue(note)];
|
|
69
|
+
if (originalValueNote != null) {
|
|
70
|
+
this.scaleMap[modparts.root] = originalValueNote;
|
|
71
|
+
delete this.scaleMapByValue[this.music.getNoteValue(scaleNote)];
|
|
72
|
+
this.scaleMapByValue[this.music.getNoteValue(note)] = originalValueNote;
|
|
73
|
+
return {
|
|
74
|
+
note: originalValueNote,
|
|
75
|
+
accidental: this.music.getNoteParts(originalValueNote).accidental,
|
|
76
|
+
change: true,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
if (modparts.root === note) {
|
|
80
|
+
delete this.scaleMapByValue[this.music.getNoteValue(this.scaleMap[parts.root])];
|
|
81
|
+
this.scaleMapByValue[this.music.getNoteValue(modparts.root)] = modparts.root;
|
|
82
|
+
this.scaleMap[modparts.root] = modparts.root;
|
|
83
|
+
return {
|
|
84
|
+
note: modparts.root,
|
|
85
|
+
accidental: undefined,
|
|
86
|
+
change: true,
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
delete this.scaleMapByValue[this.music.getNoteValue(this.scaleMap[parts.root])];
|
|
90
|
+
this.scaleMapByValue[this.music.getNoteValue(note)] = note;
|
|
91
|
+
delete this.scaleMap[modparts.root];
|
|
92
|
+
this.scaleMap[modparts.root] = note;
|
|
93
|
+
return {
|
|
94
|
+
note,
|
|
95
|
+
accidental: parts.accidental,
|
|
96
|
+
change: true,
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
}
|