@mcqj/vexflow 0.0.1-alpha.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/LICENSE +22 -0
- package/README.md +208 -0
- package/build/cjs/vexflow-bravura.js +2 -0
- package/build/cjs/vexflow-bravura.js.map +1 -0
- package/build/cjs/vexflow-core.js +2 -0
- package/build/cjs/vexflow-core.js.map +1 -0
- package/build/cjs/vexflow-debug-with-tests.js +43475 -0
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -0
- package/build/cjs/vexflow-debug.js +19194 -0
- package/build/cjs/vexflow-debug.js.map +1 -0
- package/build/cjs/vexflow.js +2 -0
- package/build/cjs/vexflow.js.map +1 -0
- package/build/esm/entry/vexflow-bravura.js +17 -0
- package/build/esm/entry/vexflow-core.js +4 -0
- package/build/esm/entry/vexflow-debug-with-tests.js +38 -0
- package/build/esm/entry/vexflow-debug.js +31 -0
- package/build/esm/entry/vexflow.js +31 -0
- package/build/esm/package.json +3 -0
- package/build/esm/src/accidental.js +330 -0
- package/build/esm/src/annotation.js +231 -0
- package/build/esm/src/articulation.js +281 -0
- package/build/esm/src/barnote.js +56 -0
- package/build/esm/src/beam.js +644 -0
- package/build/esm/src/bend.js +186 -0
- package/build/esm/src/boundingbox.js +59 -0
- package/build/esm/src/canvascontext.js +216 -0
- package/build/esm/src/chordsymbol.js +325 -0
- package/build/esm/src/clef.js +120 -0
- package/build/esm/src/clefnote.js +35 -0
- package/build/esm/src/crescendo.js +78 -0
- package/build/esm/src/curve.js +126 -0
- package/build/esm/src/dot.js +129 -0
- package/build/esm/src/easyscore.js +374 -0
- package/build/esm/src/element.js +409 -0
- package/build/esm/src/factory.js +463 -0
- package/build/esm/src/flag.js +22 -0
- package/build/esm/src/font.js +237 -0
- package/build/esm/src/fonts/academico.js +1 -0
- package/build/esm/src/fonts/academicobold.js +1 -0
- package/build/esm/src/fonts/bravura.js +1 -0
- package/build/esm/src/fonts/gonville.js +1 -0
- package/build/esm/src/fonts/petaluma.js +1 -0
- package/build/esm/src/fonts/petalumascript.js +1 -0
- package/build/esm/src/formatter.js +610 -0
- package/build/esm/src/fraction.js +170 -0
- package/build/esm/src/frethandfinger.js +141 -0
- package/build/esm/src/ghostnote.js +50 -0
- package/build/esm/src/glyphnote.js +44 -0
- package/build/esm/src/glyphs.js +2936 -0
- package/build/esm/src/gracenote.js +106 -0
- package/build/esm/src/gracenotegroup.js +138 -0
- package/build/esm/src/gracetabnote.js +11 -0
- package/build/esm/src/index.js +86 -0
- package/build/esm/src/keymanager.js +99 -0
- package/build/esm/src/keysignature.js +220 -0
- package/build/esm/src/keysignote.js +28 -0
- package/build/esm/src/metrics.js +237 -0
- package/build/esm/src/modifier.js +121 -0
- package/build/esm/src/modifiercontext.js +110 -0
- package/build/esm/src/multimeasurerest.js +127 -0
- package/build/esm/src/music.js +322 -0
- package/build/esm/src/note.js +383 -0
- package/build/esm/src/notehead.js +89 -0
- package/build/esm/src/notesubgroup.js +59 -0
- package/build/esm/src/ornament.js +192 -0
- package/build/esm/src/parenthesis.js +61 -0
- package/build/esm/src/parser.js +164 -0
- package/build/esm/src/pedalmarking.js +168 -0
- package/build/esm/src/registry.js +81 -0
- package/build/esm/src/rendercontext.js +20 -0
- package/build/esm/src/renderer.js +112 -0
- package/build/esm/src/repeatnote.js +17 -0
- package/build/esm/src/stave.js +579 -0
- package/build/esm/src/stavebarline.js +237 -0
- package/build/esm/src/staveconnector.js +180 -0
- package/build/esm/src/stavehairpin.js +115 -0
- package/build/esm/src/staveline.js +199 -0
- package/build/esm/src/stavemodifier.js +56 -0
- package/build/esm/src/stavenote.js +861 -0
- package/build/esm/src/staverepetition.js +120 -0
- package/build/esm/src/stavesection.js +36 -0
- package/build/esm/src/stavetempo.js +110 -0
- package/build/esm/src/stavetext.js +55 -0
- package/build/esm/src/stavetie.js +186 -0
- package/build/esm/src/stavevolta.js +53 -0
- package/build/esm/src/stem.js +133 -0
- package/build/esm/src/stemmablenote.js +193 -0
- package/build/esm/src/stringnumber.js +228 -0
- package/build/esm/src/strokes.js +164 -0
- package/build/esm/src/svgcontext.js +402 -0
- package/build/esm/src/system.js +166 -0
- package/build/esm/src/tables.js +696 -0
- package/build/esm/src/tabnote.js +278 -0
- package/build/esm/src/tabslide.js +68 -0
- package/build/esm/src/tabstave.js +17 -0
- package/build/esm/src/tabtie.js +19 -0
- package/build/esm/src/textbracket.js +128 -0
- package/build/esm/src/textdynamics.js +53 -0
- package/build/esm/src/textnote.js +116 -0
- package/build/esm/src/tickable.js +224 -0
- package/build/esm/src/tickcontext.js +189 -0
- package/build/esm/src/timesignature.js +169 -0
- package/build/esm/src/timesignote.js +30 -0
- package/build/esm/src/tremolo.js +30 -0
- package/build/esm/src/tuning.js +55 -0
- package/build/esm/src/tuplet.js +258 -0
- package/build/esm/src/typeguard.js +30 -0
- package/build/esm/src/util.js +67 -0
- package/build/esm/src/version.js +3 -0
- package/build/esm/src/vexflow.js +309 -0
- package/build/esm/src/vibrato.js +68 -0
- package/build/esm/src/vibratobracket.js +44 -0
- package/build/esm/src/voice.js +178 -0
- package/build/esm/src/web.js +15 -0
- package/build/esm/tests/accidental_tests.js +1055 -0
- package/build/esm/tests/annotation_tests.js +381 -0
- package/build/esm/tests/articulation_tests.js +432 -0
- package/build/esm/tests/auto_beam_formatting_tests.js +551 -0
- package/build/esm/tests/barline_tests.js +52 -0
- package/build/esm/tests/beam_tests.js +669 -0
- package/build/esm/tests/bend_tests.js +223 -0
- package/build/esm/tests/boundingbox_tests.js +53 -0
- package/build/esm/tests/browser_test_runner.js +128 -0
- package/build/esm/tests/chordsymbol_tests.js +405 -0
- package/build/esm/tests/clef_tests.js +141 -0
- package/build/esm/tests/crossbeam_tests.js +306 -0
- package/build/esm/tests/curve_tests.js +152 -0
- package/build/esm/tests/demo_petzold_tests.js +335 -0
- package/build/esm/tests/dot_tests.js +119 -0
- package/build/esm/tests/easyscore_tests.js +488 -0
- package/build/esm/tests/factory_tests.js +44 -0
- package/build/esm/tests/font_tests.js +134 -0
- package/build/esm/tests/formatter/framestack.js +61 -0
- package/build/esm/tests/formatter/tests.js +251 -0
- package/build/esm/tests/formatter_tests.js +759 -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 +119 -0
- package/build/esm/tests/gracenote_tests.js +414 -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 +106 -0
- package/build/esm/tests/keymanager_tests.js +68 -0
- package/build/esm/tests/keysignature_tests.js +322 -0
- package/build/esm/tests/mocks.js +70 -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/node_test_runner.js +31 -0
- package/build/esm/tests/notehead_tests.js +224 -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 +333 -0
- package/build/esm/tests/parser_tests.js +122 -0
- package/build/esm/tests/pedalmarking_tests.js +91 -0
- package/build/esm/tests/percussion_tests.js +184 -0
- package/build/esm/tests/playwright/flow.spec.js +127 -0
- package/build/esm/tests/playwright/visual_helpers.js +30 -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 +266 -0
- package/build/esm/tests/rhythm_tests.js +357 -0
- package/build/esm/tests/stave_tests.js +570 -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 +123 -0
- package/build/esm/tests/stavemodifier_tests.js +51 -0
- package/build/esm/tests/stavenote_tests.js +936 -0
- package/build/esm/tests/stavetie_tests.js +137 -0
- package/build/esm/tests/stringnumber_tests.js +283 -0
- package/build/esm/tests/strokes_tests.js +289 -0
- package/build/esm/tests/style_tests.js +96 -0
- package/build/esm/tests/tabnote_tests.js +462 -0
- package/build/esm/tests/tabslide_tests.js +133 -0
- package/build/esm/tests/tabstave_tests.js +24 -0
- package/build/esm/tests/tabtie_tests.js +171 -0
- package/build/esm/tests/test_runner.js +23 -0
- package/build/esm/tests/textbracket_tests.js +100 -0
- package/build/esm/tests/textnote_tests.js +216 -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 +173 -0
- package/build/esm/tests/tremolo_tests.js +34 -0
- package/build/esm/tests/tuning_tests.js +56 -0
- package/build/esm/tests/tuplet_tests.js +711 -0
- package/build/esm/tests/typeguard_tests.js +82 -0
- package/build/esm/tests/unison_tests.js +74 -0
- package/build/esm/tests/vexflow_test_helpers.js +318 -0
- package/build/esm/tests/vf_prefix_tests.js +101 -0
- package/build/esm/tests/vibrato_tests.js +93 -0
- package/build/esm/tests/vibratobracket_tests.js +45 -0
- package/build/esm/tests/vitest/job-0.test.js +2 -0
- package/build/esm/tests/vitest/job-1.test.js +2 -0
- package/build/esm/tests/vitest/job-2.test.js +2 -0
- package/build/esm/tests/vitest/job-3.test.js +2 -0
- package/build/esm/tests/vitest/run.js +5 -0
- package/build/esm/tests/vitest.setup.js +44 -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.d.ts +3 -0
- package/build/types/src/accidental.d.ts +60 -0
- package/build/types/src/annotation.d.ts +58 -0
- package/build/types/src/articulation.d.ts +78 -0
- package/build/types/src/barnote.d.ts +29 -0
- package/build/types/src/beam.d.ts +158 -0
- package/build/types/src/bend.d.ts +67 -0
- package/build/types/src/boundingbox.d.ts +42 -0
- package/build/types/src/canvascontext.d.ts +93 -0
- package/build/types/src/chordsymbol.d.ts +109 -0
- package/build/types/src/clef.d.ts +38 -0
- package/build/types/src/clefnote.d.ts +17 -0
- package/build/types/src/crescendo.d.ts +26 -0
- package/build/types/src/curve.d.ts +42 -0
- package/build/types/src/dot.d.ts +19 -0
- package/build/types/src/easyscore.d.ts +152 -0
- package/build/types/src/element.d.ts +278 -0
- package/build/types/src/factory.d.ts +273 -0
- package/build/types/src/flag.d.ts +12 -0
- package/build/types/src/font.d.ts +96 -0
- package/build/types/src/fonts/academico.d.ts +1 -0
- package/build/types/src/fonts/academicobold.d.ts +1 -0
- package/build/types/src/fonts/bravura.d.ts +1 -0
- package/build/types/src/fonts/gonville.d.ts +1 -0
- package/build/types/src/fonts/petaluma.d.ts +1 -0
- package/build/types/src/fonts/petalumascript.d.ts +1 -0
- package/build/types/src/formatter.d.ts +226 -0
- package/build/types/src/fraction.d.ts +65 -0
- package/build/types/src/frethandfinger.d.ts +19 -0
- package/build/types/src/ghostnote.d.ts +16 -0
- package/build/types/src/glyphnote.d.ts +14 -0
- package/build/types/src/glyphs.d.ts +2935 -0
- package/build/types/src/gracenote.d.ts +17 -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 +86 -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/metrics.d.ts +25 -0
- package/build/types/src/modifier.d.ts +90 -0
- package/build/types/src/modifiercontext.d.ts +48 -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 +232 -0
- package/build/types/src/notehead.d.ts +50 -0
- package/build/types/src/notesubgroup.d.ts +18 -0
- package/build/types/src/ornament.d.ts +71 -0
- package/build/types/src/parenthesis.d.ts +21 -0
- package/build/types/src/parser.d.ts +45 -0
- package/build/types/src/pedalmarking.d.ts +63 -0
- package/build/types/src/registry.d.ts +40 -0
- package/build/types/src/rendercontext.d.ts +59 -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 +181 -0
- package/build/types/src/stavebarline.d.ts +38 -0
- package/build/types/src/staveconnector.d.ts +53 -0
- package/build/types/src/stavehairpin.d.ts +56 -0
- package/build/types/src/staveline.d.ts +49 -0
- package/build/types/src/stavemodifier.d.ts +35 -0
- package/build/types/src/stavenote.d.ts +150 -0
- package/build/types/src/staverepetition.d.ts +30 -0
- package/build/types/src/stavesection.d.ts +8 -0
- package/build/types/src/stavetempo.d.ts +43 -0
- package/build/types/src/stavetext.d.ts +11 -0
- package/build/types/src/stavetie.d.ts +104 -0
- package/build/types/src/stavevolta.d.ts +15 -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 +26 -0
- package/build/types/src/strokes.d.ts +35 -0
- package/build/types/src/svgcontext.d.ts +135 -0
- package/build/types/src/system.d.ts +121 -0
- package/build/types/src/tables.d.ts +86 -0
- package/build/types/src/tabnote.d.ts +45 -0
- package/build/types/src/tabslide.d.ts +36 -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 +45 -0
- package/build/types/src/textdynamics.d.ts +34 -0
- package/build/types/src/textnote.d.ts +48 -0
- package/build/types/src/tickable.d.ts +149 -0
- package/build/types/src/tickcontext.d.ts +112 -0
- package/build/types/src/timesignature.d.ts +75 -0
- package/build/types/src/timesignote.d.ts +11 -0
- package/build/types/src/tremolo.d.ts +12 -0
- package/build/types/src/tuning.d.ts +23 -0
- package/build/types/src/tuplet.d.ts +98 -0
- package/build/types/src/typeguard.d.ts +100 -0
- package/build/types/src/util.d.ts +42 -0
- package/build/types/src/version.d.ts +3 -0
- package/build/types/src/vexflow.d.ts +261 -0
- package/build/types/src/vibrato.d.ts +20 -0
- package/build/types/src/vibratobracket.d.ts +28 -0
- package/build/types/src/voice.d.ts +109 -0
- package/build/types/src/web.d.ts +2 -0
- package/package.json +145 -0
- package/tests/flow.html +256 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
2
|
+
const VibratoBracketTests = {
|
|
3
|
+
Start() {
|
|
4
|
+
VexFlowTests.module('VibratoBracket');
|
|
5
|
+
const run = VexFlowTests.runTests;
|
|
6
|
+
run('Simple VibratoBracket', simple);
|
|
7
|
+
run('Harsh VibratoBracket Without End Note', withoutEndNote);
|
|
8
|
+
run('Harsh VibratoBracket Without Start Note', withoutStartNote);
|
|
9
|
+
},
|
|
10
|
+
};
|
|
11
|
+
function createTest(noteGroup, setupVibratoBracket) {
|
|
12
|
+
return (options) => {
|
|
13
|
+
const factory = VexFlowTests.makeFactory(options, 650, 200);
|
|
14
|
+
const stave = factory.Stave();
|
|
15
|
+
const score = factory.EasyScore();
|
|
16
|
+
const voice = score.voice(score.notes(noteGroup));
|
|
17
|
+
setupVibratoBracket(factory, voice.getTickables());
|
|
18
|
+
factory.Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
19
|
+
factory.draw();
|
|
20
|
+
options.assert.ok(true);
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
const simple = createTest('c4/4, c4, c4, c4', (factory, notes) => {
|
|
24
|
+
factory.VibratoBracket({
|
|
25
|
+
from: notes[0],
|
|
26
|
+
to: notes[3],
|
|
27
|
+
options: { line: 2 },
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
const withoutEndNote = createTest('c4/4, c4, c4, c4', (factory, notes) => {
|
|
31
|
+
factory.VibratoBracket({
|
|
32
|
+
from: notes[2],
|
|
33
|
+
to: null,
|
|
34
|
+
options: { line: 2, code: 0xeae2 },
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
const withoutStartNote = createTest('c4/4, c4, c4, c4', (factory, notes) => {
|
|
38
|
+
factory.VibratoBracket({
|
|
39
|
+
from: null,
|
|
40
|
+
to: notes[2],
|
|
41
|
+
options: { line: 2, code: 0xeae2 },
|
|
42
|
+
});
|
|
43
|
+
});
|
|
44
|
+
VexFlowTests.register(VibratoBracketTests);
|
|
45
|
+
export { VibratoBracketTests };
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { expect, test } from 'vitest';
|
|
11
|
+
import { TestRunner } from './test_runner.js';
|
|
12
|
+
function createAssert(moduleName) {
|
|
13
|
+
return {
|
|
14
|
+
test: { module: { name: moduleName } },
|
|
15
|
+
deepEqual: (actual, expected) => expect(actual).toEqual(expected),
|
|
16
|
+
equal: (actual, expected) => expect(actual == expected).toBe(true),
|
|
17
|
+
expect: (assertions) => expect.assertions(assertions),
|
|
18
|
+
notDeepEqual: (actual, expected) => expect(actual).not.toEqual(expected),
|
|
19
|
+
notEqual: (actual, expected) => expect(actual != expected).toBe(true),
|
|
20
|
+
notOk: (value) => expect(value).toBeFalsy(),
|
|
21
|
+
notStrictEqual: (actual, expected) => expect(actual).not.toBe(expected),
|
|
22
|
+
ok: (value) => expect(value).toBeTruthy(),
|
|
23
|
+
propEqual: (actual, expected) => expect(actual).toEqual(expected),
|
|
24
|
+
strictEqual: (actual, expected) => expect(actual).toBe(expected),
|
|
25
|
+
throws: (callback, expected) => {
|
|
26
|
+
const assertion = expect(callback);
|
|
27
|
+
typeof expected === 'string' || expected === undefined ? assertion.toThrow() : assertion.toThrow(expected);
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
let currentModule = '';
|
|
32
|
+
const vitestBackend = {
|
|
33
|
+
module(name) {
|
|
34
|
+
currentModule = name;
|
|
35
|
+
},
|
|
36
|
+
test(name, callback) {
|
|
37
|
+
const moduleName = currentModule;
|
|
38
|
+
test(`${moduleName} > ${name}`, () => __awaiter(this, void 0, void 0, function* () {
|
|
39
|
+
yield callback(createAssert(moduleName), { moduleName, testName: name });
|
|
40
|
+
}));
|
|
41
|
+
},
|
|
42
|
+
};
|
|
43
|
+
TestRunner.install(vitestBackend);
|
|
44
|
+
document.body.innerHTML = '<div id="qunit-tests"></div>';
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import { VexFlow } from '../src/vexflow.js';
|
|
2
|
+
import { VexFlowTests } from './vexflow_test_helpers.js';
|
|
3
|
+
import { Formatter } from '../src/formatter.js';
|
|
4
|
+
import { Stave } from '../src/stave.js';
|
|
5
|
+
import { Barline } from '../src/stavebarline.js';
|
|
6
|
+
import { StaveNote } from '../src/stavenote.js';
|
|
7
|
+
import { Voice } from '../src/voice.js';
|
|
8
|
+
import { MockTickable } from './mocks.js';
|
|
9
|
+
const VoiceTests = {
|
|
10
|
+
Start() {
|
|
11
|
+
VexFlowTests.module('Voice');
|
|
12
|
+
VexFlowTests.test('Strict Test', strict);
|
|
13
|
+
VexFlowTests.test('Ignore Test', ignore);
|
|
14
|
+
VexFlowTests.runTests('Full Voice Mode Test', full);
|
|
15
|
+
},
|
|
16
|
+
};
|
|
17
|
+
const BEAT = (1 * VexFlow.RESOLUTION) / 4;
|
|
18
|
+
const createTickable = () => new MockTickable().setTicks(BEAT);
|
|
19
|
+
function strict(assert) {
|
|
20
|
+
assert.expect(8);
|
|
21
|
+
const tickables = [createTickable(), createTickable(), createTickable()];
|
|
22
|
+
const voice = new Voice(VexFlow.TIME4_4);
|
|
23
|
+
assert.equal(voice.getTotalTicks().value(), BEAT * 4, '4/4 Voice has 4 beats');
|
|
24
|
+
assert.equal(voice.getTicksUsed().value(), BEAT * 0, 'No beats in voice');
|
|
25
|
+
voice.addTickables(tickables);
|
|
26
|
+
assert.equal(voice.getTicksUsed().value(), BEAT * 3, 'Three beats in voice');
|
|
27
|
+
voice.addTickable(createTickable());
|
|
28
|
+
assert.equal(voice.getTicksUsed().value(), BEAT * 4, 'Four beats in voice');
|
|
29
|
+
assert.equal(voice.isComplete(), true, 'Voice is complete');
|
|
30
|
+
const numeratorBeforeException = voice.getTicksUsed().numerator;
|
|
31
|
+
assert.throws(() => voice.addTickable(createTickable()), /BadArgument/, '"Too many ticks" exception');
|
|
32
|
+
assert.equal(voice.getTicksUsed().numerator, numeratorBeforeException, 'Revert `ticksUsed` after a "Too many ticks" exception');
|
|
33
|
+
assert.equal(voice.getSmallestTickCount().value(), BEAT, 'Smallest tick count is BEAT');
|
|
34
|
+
}
|
|
35
|
+
function ignore(assert) {
|
|
36
|
+
const tickables = [
|
|
37
|
+
createTickable(),
|
|
38
|
+
createTickable(),
|
|
39
|
+
createTickable().setIgnoreTicks(true),
|
|
40
|
+
createTickable(),
|
|
41
|
+
createTickable().setIgnoreTicks(true),
|
|
42
|
+
createTickable(),
|
|
43
|
+
];
|
|
44
|
+
const voice = new Voice(VexFlow.TIME4_4);
|
|
45
|
+
voice.addTickables(tickables);
|
|
46
|
+
assert.ok(true, 'all pass');
|
|
47
|
+
}
|
|
48
|
+
function full(options, contextBuilder) {
|
|
49
|
+
const ctx = contextBuilder(options.elementId, 550, 200);
|
|
50
|
+
const stave = new Stave(10, 50, 500).addClef('treble').addTimeSignature('4/4').setEndBarType(Barline.type.END);
|
|
51
|
+
const notes = [
|
|
52
|
+
new StaveNote({ keys: ['c/4'], duration: '4' }),
|
|
53
|
+
new StaveNote({ keys: ['d/4'], duration: '4' }),
|
|
54
|
+
new StaveNote({ keys: ['r/4'], duration: '4r' }),
|
|
55
|
+
];
|
|
56
|
+
notes.forEach((note) => note.setStave(stave));
|
|
57
|
+
const voice = new Voice(VexFlow.TIME4_4).setMode(Voice.Mode.FULL).addTickables(notes);
|
|
58
|
+
new Formatter().joinVoices([voice]).formatToStave([voice], stave);
|
|
59
|
+
stave.setContext(ctx).drawWithStyle();
|
|
60
|
+
voice.draw(ctx);
|
|
61
|
+
const bb = voice.getBoundingBox();
|
|
62
|
+
if (bb) {
|
|
63
|
+
ctx.rect(bb.getX(), bb.getY(), bb.getW(), bb.getH());
|
|
64
|
+
}
|
|
65
|
+
ctx.stroke();
|
|
66
|
+
options.assert.throws(() => voice.addTickable(new StaveNote({ keys: ['c/4'], duration: '2' })), /BadArgument/, 'Voice cannot exceed full amount of ticks');
|
|
67
|
+
}
|
|
68
|
+
VexFlowTests.register(VoiceTests);
|
|
69
|
+
export { VoiceTests };
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { Modifier } from './modifier';
|
|
2
|
+
import { ModifierContextState } from './modifiercontext';
|
|
3
|
+
import { Note } from './note';
|
|
4
|
+
import { Voice } from './voice';
|
|
5
|
+
type StaveLineAccidentalLayoutMetrics = {
|
|
6
|
+
column: number;
|
|
7
|
+
line: number;
|
|
8
|
+
/**
|
|
9
|
+
* A flat line needs more clearance above than below. This is
|
|
10
|
+
* set to true if the accidental is either a flat or double flat.
|
|
11
|
+
*/
|
|
12
|
+
flatLine: boolean;
|
|
13
|
+
/**
|
|
14
|
+
* Double sharps need less clearance above and below than other
|
|
15
|
+
* accidentals.
|
|
16
|
+
*/
|
|
17
|
+
dblSharpLine: boolean;
|
|
18
|
+
numAcc: number;
|
|
19
|
+
width: number;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* An `Accidental` inherits from `Modifier`, and is formatted within a
|
|
23
|
+
* `ModifierContext`. Accidentals are modifiers that can be attached to
|
|
24
|
+
* notes. Support is included for both western and microtonal accidentals.
|
|
25
|
+
*
|
|
26
|
+
* See `tests/accidental_tests.ts` for usage examples.
|
|
27
|
+
*/
|
|
28
|
+
export declare class Accidental extends Modifier {
|
|
29
|
+
/** Accidental code provided to the constructor. */
|
|
30
|
+
readonly type: string;
|
|
31
|
+
/** To enable logging for this class. Set `VexFlow.Accidental.DEBUG` to `true`. */
|
|
32
|
+
static DEBUG: boolean;
|
|
33
|
+
protected cautionary: boolean;
|
|
34
|
+
/** Accidentals category string. */
|
|
35
|
+
static get CATEGORY(): string;
|
|
36
|
+
/** Arrange accidentals inside a ModifierContext. */
|
|
37
|
+
static format(accidentals: Accidental[], state: ModifierContextState): void;
|
|
38
|
+
/** Helper function to determine whether two lines of accidentals collide vertically */
|
|
39
|
+
protected static checkCollision(line1: StaveLineAccidentalLayoutMetrics, line2: StaveLineAccidentalLayoutMetrics): boolean;
|
|
40
|
+
/**
|
|
41
|
+
* Use this method to automatically apply accidentals to a set of `voices`.
|
|
42
|
+
* The accidentals will be remembered between all the voices provided.
|
|
43
|
+
* Optionally, you can also provide an initial `keySignature`.
|
|
44
|
+
*/
|
|
45
|
+
static applyAccidentals(voices: Voice[], keySignature: string): void;
|
|
46
|
+
/**
|
|
47
|
+
* Create accidental.
|
|
48
|
+
* @param type value from `VexFlow.accidentalCodes.accidentals` table in `tables.ts`.
|
|
49
|
+
* For example: `#`, `##`, `b`, `n`, etc.
|
|
50
|
+
*/
|
|
51
|
+
constructor(type: string);
|
|
52
|
+
protected reset(): void;
|
|
53
|
+
/** Attach this accidental to `note`, which must be a `StaveNote`. */
|
|
54
|
+
setNote(note: Note): this;
|
|
55
|
+
/** If called, draws parenthesis around accidental. */
|
|
56
|
+
setAsCautionary(): this;
|
|
57
|
+
/** Render accidental onto canvas. */
|
|
58
|
+
draw(): void;
|
|
59
|
+
}
|
|
60
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Modifier } from './modifier';
|
|
2
|
+
import { ModifierContextState } from './modifiercontext';
|
|
3
|
+
export declare enum AnnotationHorizontalJustify {
|
|
4
|
+
LEFT = 1,
|
|
5
|
+
CENTER = 2,
|
|
6
|
+
RIGHT = 3,
|
|
7
|
+
CENTER_STEM = 4
|
|
8
|
+
}
|
|
9
|
+
export declare enum AnnotationVerticalJustify {
|
|
10
|
+
TOP = 1,
|
|
11
|
+
CENTER = 2,
|
|
12
|
+
BOTTOM = 3,
|
|
13
|
+
CENTER_STEM = 4
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Annotations are modifiers that can be attached to
|
|
17
|
+
* notes.
|
|
18
|
+
*
|
|
19
|
+
* See `tests/annotation_tests.ts` for usage examples.
|
|
20
|
+
*/
|
|
21
|
+
export declare class Annotation extends Modifier {
|
|
22
|
+
/** To enable logging for this class. Set `VexFlow.Annotation.DEBUG` to `true`. */
|
|
23
|
+
static DEBUG: boolean;
|
|
24
|
+
/** Annotations category string. */
|
|
25
|
+
static get CATEGORY(): string;
|
|
26
|
+
/** Text annotations can be positioned and justified relative to the note. */
|
|
27
|
+
static HorizontalJustify: typeof AnnotationHorizontalJustify;
|
|
28
|
+
static HorizontalJustifyString: Record<string, number>;
|
|
29
|
+
static VerticalJustify: typeof AnnotationVerticalJustify;
|
|
30
|
+
static VerticalJustifyString: Record<string, number>;
|
|
31
|
+
static get minAnnotationPadding(): number;
|
|
32
|
+
/** Arrange annotations within a `ModifierContext` */
|
|
33
|
+
static format(annotations: Annotation[], state: ModifierContextState): boolean;
|
|
34
|
+
protected horizontalJustification: AnnotationHorizontalJustify;
|
|
35
|
+
protected verticalJustification: AnnotationVerticalJustify;
|
|
36
|
+
/**
|
|
37
|
+
* Annotations inherit from `Modifier` and is positioned correctly when
|
|
38
|
+
* in a `ModifierContext`.
|
|
39
|
+
* Create a new `Annotation` with the string `text`.
|
|
40
|
+
*/
|
|
41
|
+
constructor(text: string);
|
|
42
|
+
/**
|
|
43
|
+
* Set vertical position of text (above or below stave).
|
|
44
|
+
* @param just value in `AnnotationVerticalJustify`.
|
|
45
|
+
*/
|
|
46
|
+
setVerticalJustification(just: string | AnnotationVerticalJustify): this;
|
|
47
|
+
/**
|
|
48
|
+
* Get horizontal justification.
|
|
49
|
+
*/
|
|
50
|
+
getJustification(): AnnotationHorizontalJustify;
|
|
51
|
+
/**
|
|
52
|
+
* Set horizontal justification.
|
|
53
|
+
* @param just value in `Annotation.Justify`.
|
|
54
|
+
*/
|
|
55
|
+
setJustification(just: string | AnnotationHorizontalJustify): this;
|
|
56
|
+
/** Render text beside the note. */
|
|
57
|
+
draw(): void;
|
|
58
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { Builder } from './easyscore';
|
|
2
|
+
import { Modifier } from './modifier';
|
|
3
|
+
import { ModifierContextState } from './modifiercontext';
|
|
4
|
+
import { Note } from './note';
|
|
5
|
+
import { StemmableNote } from './stemmablenote';
|
|
6
|
+
export interface ArticulationStruct {
|
|
7
|
+
code?: string;
|
|
8
|
+
aboveCode?: string;
|
|
9
|
+
belowCode?: string;
|
|
10
|
+
betweenLines: boolean;
|
|
11
|
+
}
|
|
12
|
+
export declare function getTopY(note: Note, textLine: number): number;
|
|
13
|
+
export declare function getBottomY(note: Note, textLine: number): number;
|
|
14
|
+
/**
|
|
15
|
+
* Get the initial offset of the articulation from the y value of the starting position.
|
|
16
|
+
* This is required because the top/bottom text positions already have spacing applied to
|
|
17
|
+
* provide a "visually pleasant" default position. However the y values provided from
|
|
18
|
+
* the stavenote's top/bottom do *not* have any pre-applied spacing. This function
|
|
19
|
+
* normalizes this asymmetry.
|
|
20
|
+
* @param note
|
|
21
|
+
* @param position
|
|
22
|
+
* @returns
|
|
23
|
+
*/
|
|
24
|
+
export declare function getInitialOffset(note: Note, position: number): number;
|
|
25
|
+
/**
|
|
26
|
+
* Articulations and Accents are modifiers that can be
|
|
27
|
+
* attached to notes. The complete list of articulations is available in
|
|
28
|
+
* `tables.ts` under `VexFlow.articulationCodes`.
|
|
29
|
+
*
|
|
30
|
+
* See `tests/articulation_tests.ts` for usage examples.
|
|
31
|
+
*/
|
|
32
|
+
export declare class Articulation extends Modifier {
|
|
33
|
+
/** To enable logging for this class. Set `VexFlow.Articulation.DEBUG` to `true`. */
|
|
34
|
+
static DEBUG: boolean;
|
|
35
|
+
/** Articulations category string. */
|
|
36
|
+
static get CATEGORY(): string;
|
|
37
|
+
protected static readonly INITIAL_OFFSET: number;
|
|
38
|
+
/** Articulation code provided to the constructor. */
|
|
39
|
+
readonly type: string;
|
|
40
|
+
protected articulation: ArticulationStruct;
|
|
41
|
+
protected heightShift: number;
|
|
42
|
+
/**
|
|
43
|
+
* FIXME:
|
|
44
|
+
* Most of the complex formatting logic (ie: snapping to space) is
|
|
45
|
+
* actually done in .render(). But that logic belongs in this method.
|
|
46
|
+
*
|
|
47
|
+
* Unfortunately, this isn't possible because, by this point, stem lengths
|
|
48
|
+
* have not yet been finalized. Finalized stem lengths are required to determine the
|
|
49
|
+
* initial position of any stem-side articulation.
|
|
50
|
+
*
|
|
51
|
+
* This indicates that all objects should have their stave set before being
|
|
52
|
+
* formatted. It can't be an optional if you want accurate vertical positioning.
|
|
53
|
+
* Consistently positioned articulations that play nice with other modifiers
|
|
54
|
+
* won't be possible until we stop relying on render-time formatting.
|
|
55
|
+
*
|
|
56
|
+
* Ideally, when this function has completed, the vertical articulation positions
|
|
57
|
+
* should be ready to render without further adjustment. But the current state
|
|
58
|
+
* is far from this ideal.
|
|
59
|
+
*/
|
|
60
|
+
static format(articulations: Articulation[], state: ModifierContextState): boolean;
|
|
61
|
+
static easyScoreHook({ articulations }: {
|
|
62
|
+
articulations: string;
|
|
63
|
+
}, note: StemmableNote, builder: Builder): void;
|
|
64
|
+
/**
|
|
65
|
+
* Create a new articulation.
|
|
66
|
+
* @param type entry in `VexFlow.articulationCodes` in `tables.ts` or Glyph code.
|
|
67
|
+
*
|
|
68
|
+
* Notes default positions (see https://w3c.github.io/smufl/latest/tables/articulation.html):
|
|
69
|
+
* - Even codes will be positioned ABOVE
|
|
70
|
+
* - Odd codes will be positioned BELOW
|
|
71
|
+
*/
|
|
72
|
+
constructor(type: string);
|
|
73
|
+
protected reset(): void;
|
|
74
|
+
/** Set if articulation should be rendered between lines. */
|
|
75
|
+
setBetweenLines(betweenLines?: boolean): this;
|
|
76
|
+
/** Render articulation in position next to note. */
|
|
77
|
+
draw(): void;
|
|
78
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { ModifierContext } from './modifiercontext';
|
|
2
|
+
import { Note } from './note';
|
|
3
|
+
import { BarlineType } from './stavebarline';
|
|
4
|
+
/**
|
|
5
|
+
* A `BarNote` is used to render bar lines (from `barline.ts`). `BarNote`s can
|
|
6
|
+
* be added to a voice and rendered in the middle of a stave. Since it has no
|
|
7
|
+
* duration, it consumes no `tick`s, and is dealt with appropriately by the formatter.
|
|
8
|
+
*
|
|
9
|
+
* See `tests/barnote_tests.ts` for usage examples.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BarNote extends Note {
|
|
12
|
+
/** To enable logging for this class. Set `VexFlow.BarNote.DEBUG` to `true`. */
|
|
13
|
+
static DEBUG: boolean;
|
|
14
|
+
static get CATEGORY(): string;
|
|
15
|
+
protected metrics: {
|
|
16
|
+
widths: Record<string, number>;
|
|
17
|
+
};
|
|
18
|
+
protected type: BarlineType;
|
|
19
|
+
constructor(type?: string | BarlineType);
|
|
20
|
+
/** Get the type of bar note.*/
|
|
21
|
+
getType(): BarlineType;
|
|
22
|
+
/** Set the type of bar note. */
|
|
23
|
+
setType(type: string | BarlineType): this;
|
|
24
|
+
addToModifierContext(mc: ModifierContext): this;
|
|
25
|
+
/** Overridden to ignore. */
|
|
26
|
+
preFormat(): this;
|
|
27
|
+
/** Render note to stave. */
|
|
28
|
+
draw(): void;
|
|
29
|
+
}
|
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import { Element } from './element';
|
|
2
|
+
import { Fraction } from './fraction';
|
|
3
|
+
import { RenderContext } from './rendercontext';
|
|
4
|
+
import { StemmableNote } from './stemmablenote';
|
|
5
|
+
import { Voice } from './voice';
|
|
6
|
+
export declare const BEAM_LEFT = "L";
|
|
7
|
+
export declare const BEAM_RIGHT = "R";
|
|
8
|
+
export declare const BEAM_BOTH = "B";
|
|
9
|
+
export type PartialBeamDirection = typeof BEAM_LEFT | typeof BEAM_RIGHT | typeof BEAM_BOTH;
|
|
10
|
+
/** `Beams` span over a set of `StemmableNotes`. */
|
|
11
|
+
export declare class Beam extends Element {
|
|
12
|
+
static get CATEGORY(): string;
|
|
13
|
+
renderOptions: {
|
|
14
|
+
flatBeamOffset?: number;
|
|
15
|
+
flatBeams: boolean;
|
|
16
|
+
secondaryBreakTicks?: number;
|
|
17
|
+
showStemlets: boolean;
|
|
18
|
+
beamWidth: number;
|
|
19
|
+
maxSlope: number;
|
|
20
|
+
minSlope: number;
|
|
21
|
+
slopeIterations: number;
|
|
22
|
+
slopeCost: number;
|
|
23
|
+
stemletExtension: number;
|
|
24
|
+
partialBeamLength: number;
|
|
25
|
+
minFlatBeamOffset: number;
|
|
26
|
+
};
|
|
27
|
+
notes: StemmableNote[];
|
|
28
|
+
postFormatted: boolean;
|
|
29
|
+
slope: number;
|
|
30
|
+
private readonly _stemDirection;
|
|
31
|
+
private readonly _ticks;
|
|
32
|
+
protected yShift: number;
|
|
33
|
+
private breakOnIndexes;
|
|
34
|
+
private _beamCount;
|
|
35
|
+
private unbeamable?;
|
|
36
|
+
/**
|
|
37
|
+
* Overrides to default beam directions for secondary-level beams that do not
|
|
38
|
+
* connect to any other note. See further explanation at
|
|
39
|
+
* `setPartialBeamSideAt`
|
|
40
|
+
*/
|
|
41
|
+
private forcedPartialDirections;
|
|
42
|
+
/** Get the direction of the beam */
|
|
43
|
+
getStemDirection(): number;
|
|
44
|
+
/**
|
|
45
|
+
* Get the default beam groups for a provided time signature.
|
|
46
|
+
* Attempt to guess if the time signature is not found in table.
|
|
47
|
+
* Currently this is fairly naive.
|
|
48
|
+
*/
|
|
49
|
+
static getDefaultBeamGroups(timeSig: string): Fraction[];
|
|
50
|
+
/**
|
|
51
|
+
* A helper function to automatically build basic beams for a voice. For more
|
|
52
|
+
* complex auto-beaming use `Beam.generateBeams()`.
|
|
53
|
+
* @param voice the voice to generate the beams for
|
|
54
|
+
* @param stemDirection a stem direction to apply to the entire voice
|
|
55
|
+
* @param groups an array of `Fraction` representing beat groupings for the beam
|
|
56
|
+
*/
|
|
57
|
+
static applyAndGetBeams(voice: Voice, stemDirection?: number, groups?: Fraction[]): Beam[];
|
|
58
|
+
/**
|
|
59
|
+
* A helper function to autimatically build beams for a voice with
|
|
60
|
+
* configuration options.
|
|
61
|
+
*
|
|
62
|
+
* Example configuration object:
|
|
63
|
+
*
|
|
64
|
+
* ```
|
|
65
|
+
* config = {
|
|
66
|
+
* groups: [new VexFlow.Fraction(2, 8)],
|
|
67
|
+
* stemDirection: -1,
|
|
68
|
+
* beamRests: true,
|
|
69
|
+
* beamMiddleOnly: true,
|
|
70
|
+
* showStemlets: false
|
|
71
|
+
* };
|
|
72
|
+
* ```
|
|
73
|
+
* @param notes an array of notes to create the beams for
|
|
74
|
+
* @param config the configuration object
|
|
75
|
+
* @param config.stemDirection set to apply the same direction to all notes
|
|
76
|
+
* @param config.beamRests set to `true` to include rests in the beams
|
|
77
|
+
* @param config.beamMiddleOnly set to `true` to only beam rests in the middle of the beat
|
|
78
|
+
* @param config.showStemlets set to `true` to draw stemlets for rests
|
|
79
|
+
* @param config.maintainStemDirections set to `true` to not apply new stem directions
|
|
80
|
+
* @param config.groups array of `Fractions` that represent the beat structure to beam the notes
|
|
81
|
+
*
|
|
82
|
+
*/
|
|
83
|
+
static generateBeams(notes: StemmableNote[], config?: {
|
|
84
|
+
flatBeamOffset?: number;
|
|
85
|
+
flatBeams?: boolean;
|
|
86
|
+
secondaryBreaks?: string;
|
|
87
|
+
showStemlets?: boolean;
|
|
88
|
+
maintainStemDirections?: boolean;
|
|
89
|
+
beamMiddleOnly?: boolean;
|
|
90
|
+
beamRests?: boolean;
|
|
91
|
+
groups?: Fraction[];
|
|
92
|
+
stemDirection?: number;
|
|
93
|
+
}): Beam[];
|
|
94
|
+
constructor(notes: StemmableNote[], autoStem?: boolean);
|
|
95
|
+
/** Get the notes in this beam. */
|
|
96
|
+
getNotes(): StemmableNote[];
|
|
97
|
+
/** Get the max number of beams in the set of notes. */
|
|
98
|
+
getBeamCount(): number;
|
|
99
|
+
/** Set which note `indexes` to break the secondary beam at. */
|
|
100
|
+
breakSecondaryAt(indexes: number[]): this;
|
|
101
|
+
/**
|
|
102
|
+
* Forces the direction of a partial beam (a secondary-level beam that exists
|
|
103
|
+
* on one note only of the beam group). This is useful in rhythms such as 6/8
|
|
104
|
+
* eighth-sixteenth-eighth-sixteenth, where the direction of the beam on the
|
|
105
|
+
* first sixteenth note can help imply whether the rhythm is to be felt as
|
|
106
|
+
* three groups of eighth notes (typical) or as two groups of three-sixteenths
|
|
107
|
+
* (less common):
|
|
108
|
+
* ```
|
|
109
|
+
* ┌───┬──┬──┐ ┌──┬──┬──┐
|
|
110
|
+
* │ ├─ │ ─┤ vs │ ─┤ │ ─┤
|
|
111
|
+
* │ │ │ │ │ │ │ │
|
|
112
|
+
* ```
|
|
113
|
+
*/
|
|
114
|
+
setPartialBeamSideAt(noteIndex: number, side: PartialBeamDirection): this;
|
|
115
|
+
/**
|
|
116
|
+
* Restore the default direction of a partial beam (a secondary-level beam
|
|
117
|
+
* that does not connect to any other notes).
|
|
118
|
+
*/
|
|
119
|
+
unsetPartialBeamSideAt(noteIndex: number): this;
|
|
120
|
+
/**
|
|
121
|
+
* @param firstX specified in pixels.
|
|
122
|
+
* @param firstY specified in pixels.
|
|
123
|
+
*
|
|
124
|
+
* @return the y coordinate for linear function.
|
|
125
|
+
*/
|
|
126
|
+
getSlopeY(x: number, firstX: number, firstY: number, slope: number): number;
|
|
127
|
+
/** Calculate the best possible slope for the provided notes. */
|
|
128
|
+
calculateSlope(): void;
|
|
129
|
+
/** Calculate a slope and y-shift for flat beams. */
|
|
130
|
+
calculateFlatSlope(): void;
|
|
131
|
+
/** Return the Beam y offset. */
|
|
132
|
+
getBeamYToDraw(): number;
|
|
133
|
+
/**
|
|
134
|
+
* Create new stems for the notes in the beam, so that each stem
|
|
135
|
+
* extends into the beams.
|
|
136
|
+
*/
|
|
137
|
+
applyStemExtensions(): void;
|
|
138
|
+
/** Return upper level beam direction. */
|
|
139
|
+
lookupBeamDirection(duration: string, prevTick: number, tick: number, nextTick: number, noteIndex: number): PartialBeamDirection;
|
|
140
|
+
/** Get the x coordinates for the beam lines of specific `duration`. */
|
|
141
|
+
getBeamLines(duration: string): {
|
|
142
|
+
start: number;
|
|
143
|
+
end?: number;
|
|
144
|
+
}[];
|
|
145
|
+
/** Render the stems for each note. */
|
|
146
|
+
protected drawStems(ctx: RenderContext): void;
|
|
147
|
+
protected drawBeamLines(ctx: RenderContext): void;
|
|
148
|
+
/** Pre-format the beam. */
|
|
149
|
+
preFormat(): this;
|
|
150
|
+
/**
|
|
151
|
+
* Post-format the beam. This can only be called after
|
|
152
|
+
* the notes in the beam have both `x` and `y` values. ie: they've
|
|
153
|
+
* been formatted and have staves.
|
|
154
|
+
*/
|
|
155
|
+
postFormat(): void;
|
|
156
|
+
/** Render the beam to the canvas context */
|
|
157
|
+
draw(): void;
|
|
158
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { ElementStyle } from './element';
|
|
2
|
+
import { Modifier } from './modifier';
|
|
3
|
+
import { ModifierContextState } from './modifiercontext';
|
|
4
|
+
export interface BendPhrase {
|
|
5
|
+
x?: number;
|
|
6
|
+
type: number;
|
|
7
|
+
text: string;
|
|
8
|
+
width?: number;
|
|
9
|
+
drawWidth?: number;
|
|
10
|
+
}
|
|
11
|
+
/** Bend implements tablature bends. */
|
|
12
|
+
export declare class Bend extends Modifier {
|
|
13
|
+
static get CATEGORY(): string;
|
|
14
|
+
static get UP(): number;
|
|
15
|
+
static get DOWN(): number;
|
|
16
|
+
static format(bends: Bend[], state: ModifierContextState): boolean;
|
|
17
|
+
protected tap: string;
|
|
18
|
+
protected phrase: BendPhrase[];
|
|
19
|
+
protected styleLine: ElementStyle;
|
|
20
|
+
/** Set the element style used for rendering the lines. */
|
|
21
|
+
setStyleLine(style: ElementStyle): this;
|
|
22
|
+
/** Get the element style used for rendering the lines. */
|
|
23
|
+
getStyleLine(): ElementStyle;
|
|
24
|
+
renderOptions: {
|
|
25
|
+
releaseWidth: number;
|
|
26
|
+
bendWidth: number;
|
|
27
|
+
};
|
|
28
|
+
/**
|
|
29
|
+
* Example of a phrase:
|
|
30
|
+
* ```
|
|
31
|
+
* [{
|
|
32
|
+
* type: UP,
|
|
33
|
+
* text: "whole"
|
|
34
|
+
* width: 8;
|
|
35
|
+
* },
|
|
36
|
+
* {
|
|
37
|
+
* type: DOWN,
|
|
38
|
+
* text: "whole"
|
|
39
|
+
* width: 8;
|
|
40
|
+
* },
|
|
41
|
+
* {
|
|
42
|
+
* type: UP,
|
|
43
|
+
* text: "half"
|
|
44
|
+
* width: 8;
|
|
45
|
+
* },
|
|
46
|
+
* {
|
|
47
|
+
* type: UP,
|
|
48
|
+
* text: "whole"
|
|
49
|
+
* width: 8;
|
|
50
|
+
* },
|
|
51
|
+
* {
|
|
52
|
+
* type: DOWN,
|
|
53
|
+
* text: "1 1/2"
|
|
54
|
+
* width: 8;
|
|
55
|
+
* }]
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
58
|
+
constructor(phrase: BendPhrase[]);
|
|
59
|
+
/** Set horizontal shift in pixels. */
|
|
60
|
+
setXShift(value: number): this;
|
|
61
|
+
setTap(value: string): this;
|
|
62
|
+
getTextHeight(): number;
|
|
63
|
+
/** Recalculate width. */
|
|
64
|
+
protected updateWidth(): this;
|
|
65
|
+
/** Draw the bend on the rendering context. */
|
|
66
|
+
draw(): void;
|
|
67
|
+
}
|