vexflow 5.0.0-alpha.2 → 5.0.0-alpha.3
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 +4 -4
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +4 -4
- package/build/cjs/vexflow-debug.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 -3
- package/entry/vexflow-bravura.ts +0 -25
- package/entry/vexflow-core.ts +0 -16
- package/entry/vexflow-debug-with-tests.ts +0 -64
- package/entry/vexflow-debug.ts +0 -54
- package/entry/vexflow.ts +0 -47
- package/src/accidental.ts +0 -570
- package/src/annotation.ts +0 -294
- package/src/articulation.ts +0 -383
- package/src/barnote.ts +0 -95
- package/src/beam.ts +0 -999
- package/src/bend.ts +0 -268
- package/src/boundingbox.ts +0 -108
- package/src/canvascontext.ts +0 -348
- package/src/chordsymbol.ts +0 -473
- package/src/clef.ts +0 -164
- package/src/clefnote.ts +0 -50
- package/src/crescendo.ts +0 -132
- package/src/curve.ts +0 -195
- package/src/dot.ts +0 -171
- package/src/easyscore.ts +0 -538
- package/src/element.ts +0 -692
- package/src/factory.ts +0 -694
- package/src/font.ts +0 -343
- package/src/fonts/academico.ts +0 -2
- package/src/fonts/academicobold.ts +0 -2
- package/src/fonts/bravura.ts +0 -2
- package/src/fonts/gonville.ts +0 -2
- package/src/fonts/petaluma.ts +0 -2
- package/src/fonts/petalumascript.ts +0 -2
- package/src/formatter.ts +0 -1107
- package/src/fraction.ts +0 -245
- package/src/frethandfinger.ts +0 -180
- package/src/ghostnote.ts +0 -75
- package/src/glyphnote.ts +0 -68
- package/src/glyphs.ts +0 -5880
- package/src/gracenote.ts +0 -146
- package/src/gracenotegroup.ts +0 -194
- package/src/gracetabnote.ts +0 -30
- package/src/index.ts +0 -90
- package/src/keymanager.ts +0 -153
- package/src/keysignature.ts +0 -272
- package/src/keysignote.ts +0 -46
- package/src/metrics.ts +0 -222
- package/src/modifier.ts +0 -216
- package/src/modifiercontext.ts +0 -177
- package/src/multimeasurerest.ts +0 -229
- package/src/music.ts +0 -443
- package/src/note.ts +0 -690
- package/src/notehead.ts +0 -158
- package/src/notesubgroup.ts +0 -88
- package/src/ornament.ts +0 -301
- package/src/parenthesis.ts +0 -89
- package/src/parser.ts +0 -263
- package/src/pedalmarking.ts +0 -273
- package/src/registry.ts +0 -146
- package/src/rendercontext.ts +0 -98
- package/src/renderer.ts +0 -166
- package/src/repeatnote.ts +0 -25
- package/src/stave.ts +0 -885
- package/src/stavebarline.ts +0 -231
- package/src/staveconnector.ts +0 -281
- package/src/stavehairpin.ts +0 -209
- package/src/staveline.ts +0 -343
- package/src/stavemodifier.ts +0 -93
- package/src/stavenote.ts +0 -1230
- package/src/staverepetition.ts +0 -148
- package/src/stavesection.ts +0 -54
- package/src/stavetempo.ts +0 -162
- package/src/stavetext.ts +0 -69
- package/src/stavetie.ts +0 -235
- package/src/stavevolta.ts +0 -66
- package/src/stem.ts +0 -225
- package/src/stemmablenote.ts +0 -248
- package/src/stringnumber.ts +0 -286
- package/src/strokes.ts +0 -214
- package/src/svgcontext.ts +0 -639
- package/src/system.ts +0 -327
- package/src/tables.ts +0 -796
- package/src/tabnote.ts +0 -449
- package/src/tabslide.ts +0 -115
- package/src/tabstave.ts +0 -31
- package/src/tabtie.ts +0 -44
- package/src/textbracket.ts +0 -231
- package/src/textdynamics.ts +0 -101
- package/src/textnote.ts +0 -175
- package/src/tickable.ts +0 -374
- package/src/tickcontext.ts +0 -280
- package/src/timesignature.ts +0 -229
- package/src/timesignote.ts +0 -45
- package/src/tremolo.ts +0 -51
- package/src/tuning.ts +0 -90
- package/src/tuplet.ts +0 -349
- package/src/typeguard.ts +0 -136
- package/src/util.ts +0 -169
- package/src/version.ts +0 -4
- package/src/vexflow.ts +0 -378
- package/src/vibrato.ts +0 -99
- package/src/vibratobracket.ts +0 -81
- package/src/voice.ts +0 -302
- package/src/web.ts +0 -35
package/src/gracenote.ts
DELETED
|
@@ -1,146 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
|
|
3
|
-
import { StaveNote, StaveNoteStruct } from './stavenote';
|
|
4
|
-
import { Stem } from './stem';
|
|
5
|
-
import { Tables } from './tables';
|
|
6
|
-
import { Category } from './typeguard';
|
|
7
|
-
import { RuntimeError } from './util';
|
|
8
|
-
|
|
9
|
-
export interface GraceNoteStruct extends StaveNoteStruct {
|
|
10
|
-
slash?: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export class GraceNote extends StaveNote {
|
|
14
|
-
static get CATEGORY(): string {
|
|
15
|
-
return Category.GraceNote;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
static get LEDGER_LINE_OFFSET(): number {
|
|
19
|
-
return 2;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
protected slash: boolean;
|
|
23
|
-
protected slur: boolean;
|
|
24
|
-
|
|
25
|
-
constructor(noteStruct: GraceNoteStruct) {
|
|
26
|
-
super({
|
|
27
|
-
strokePx: GraceNote.LEDGER_LINE_OFFSET,
|
|
28
|
-
...noteStruct,
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
this.slash = noteStruct.slash || false;
|
|
32
|
-
this.slur = true;
|
|
33
|
-
|
|
34
|
-
this.buildNoteHeads();
|
|
35
|
-
|
|
36
|
-
this.width = 3;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
getStemExtension(): number {
|
|
40
|
-
if (this.stemExtensionOverride) {
|
|
41
|
-
return this.stemExtensionOverride;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
let ret = super.getStemExtension();
|
|
45
|
-
ret = Stem.HEIGHT * this.getFontScale() - Stem.HEIGHT + ret;
|
|
46
|
-
return ret;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
draw(): void {
|
|
50
|
-
super.draw();
|
|
51
|
-
this.setRendered();
|
|
52
|
-
const stem = this.stem;
|
|
53
|
-
if (this.slash && stem) {
|
|
54
|
-
const scale = this.getFontScale();
|
|
55
|
-
|
|
56
|
-
let slashBBox = undefined;
|
|
57
|
-
const beam = this.beam;
|
|
58
|
-
if (beam) {
|
|
59
|
-
// FIXME: should render slash after beam?
|
|
60
|
-
if (!beam.postFormatted) {
|
|
61
|
-
beam.postFormat();
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
slashBBox = this.calcBeamedNotesSlashBBox(8 * scale, 8 * scale, {
|
|
65
|
-
stem: 6 * scale,
|
|
66
|
-
beam: 5 * scale,
|
|
67
|
-
});
|
|
68
|
-
} else {
|
|
69
|
-
const stemDirection = this.getStemDirection();
|
|
70
|
-
const noteHeadBounds = this.getNoteHeadBounds();
|
|
71
|
-
const noteHeadWidth = this.noteHeads[0].getWidth();
|
|
72
|
-
const x = stemDirection === Stem.DOWN ? this.getAbsoluteX() : this.getAbsoluteX() + noteHeadWidth;
|
|
73
|
-
const defaultOffsetY = (Tables.STEM_HEIGHT * scale) / 2;
|
|
74
|
-
const y =
|
|
75
|
-
stemDirection === Stem.DOWN ? noteHeadBounds.yBottom + defaultOffsetY : noteHeadBounds.yTop - defaultOffsetY;
|
|
76
|
-
|
|
77
|
-
if (stemDirection === Stem.DOWN) {
|
|
78
|
-
slashBBox = {
|
|
79
|
-
x1: x - noteHeadWidth,
|
|
80
|
-
y1: y - noteHeadWidth,
|
|
81
|
-
x2: x + noteHeadWidth,
|
|
82
|
-
y2: y + noteHeadWidth,
|
|
83
|
-
};
|
|
84
|
-
} else {
|
|
85
|
-
slashBBox = {
|
|
86
|
-
x1: x - noteHeadWidth,
|
|
87
|
-
y1: y + noteHeadWidth,
|
|
88
|
-
x2: x + noteHeadWidth,
|
|
89
|
-
y2: y - noteHeadWidth,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
// FIXME: avoid staff lines, ledger lines or others.
|
|
95
|
-
|
|
96
|
-
const ctx = this.checkContext();
|
|
97
|
-
ctx.save();
|
|
98
|
-
ctx.setLineWidth(1 * scale); // FIXME: use more appropriate value.
|
|
99
|
-
ctx.beginPath();
|
|
100
|
-
ctx.moveTo(slashBBox.x1, slashBBox.y1);
|
|
101
|
-
ctx.lineTo(slashBBox.x2, slashBBox.y2);
|
|
102
|
-
ctx.closePath();
|
|
103
|
-
ctx.stroke();
|
|
104
|
-
ctx.restore();
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
calcBeamedNotesSlashBBox(
|
|
109
|
-
slashStemOffset: number,
|
|
110
|
-
slashBeamOffset: number,
|
|
111
|
-
protrusions: { beam: number; stem: number }
|
|
112
|
-
): Record<string, number> {
|
|
113
|
-
const beam = this.beam;
|
|
114
|
-
if (!beam) throw new RuntimeError('NoBeam', "Can't calculate without a beam.");
|
|
115
|
-
|
|
116
|
-
const beamSlope = beam.slope;
|
|
117
|
-
const isBeamEndNote = beam.notes[beam.notes.length - 1] === this;
|
|
118
|
-
const scaleX = isBeamEndNote ? -1 : 1;
|
|
119
|
-
const beamAngle = Math.atan(beamSlope * scaleX);
|
|
120
|
-
|
|
121
|
-
// slash line intersecting point on beam.
|
|
122
|
-
const iPointOnBeam = {
|
|
123
|
-
dx: Math.cos(beamAngle) * slashBeamOffset,
|
|
124
|
-
dy: Math.sin(beamAngle) * slashBeamOffset,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
slashStemOffset *= this.getStemDirection();
|
|
128
|
-
const slashAngle = Math.atan((iPointOnBeam.dy - slashStemOffset) / iPointOnBeam.dx);
|
|
129
|
-
const protrusionStemDeltaX = Math.cos(slashAngle) * protrusions.stem * scaleX;
|
|
130
|
-
const protrusionStemDeltaY = Math.sin(slashAngle) * protrusions.stem;
|
|
131
|
-
const protrusionBeamDeltaX = Math.cos(slashAngle) * protrusions.beam * scaleX;
|
|
132
|
-
const protrusionBeamDeltaY = Math.sin(slashAngle) * protrusions.beam;
|
|
133
|
-
|
|
134
|
-
const stemX = this.getStemX();
|
|
135
|
-
const stem0X = beam.notes[0].getStemX();
|
|
136
|
-
const stemY = beam.getBeamYToDraw() + (stemX - stem0X) * beamSlope;
|
|
137
|
-
|
|
138
|
-
const ret = {
|
|
139
|
-
x1: stemX - protrusionStemDeltaX,
|
|
140
|
-
y1: stemY + slashStemOffset - protrusionStemDeltaY,
|
|
141
|
-
x2: stemX + iPointOnBeam.dx * scaleX + protrusionBeamDeltaX,
|
|
142
|
-
y2: stemY + iPointOnBeam.dy + protrusionBeamDeltaY,
|
|
143
|
-
};
|
|
144
|
-
return ret;
|
|
145
|
-
}
|
|
146
|
-
}
|
package/src/gracenotegroup.ts
DELETED
|
@@ -1,194 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
//
|
|
3
|
-
// ## Description
|
|
4
|
-
//
|
|
5
|
-
// This file implements `GraceNoteGroup` which is used to format and
|
|
6
|
-
// render grace notes.
|
|
7
|
-
|
|
8
|
-
import { Beam } from './beam';
|
|
9
|
-
import { Formatter } from './formatter';
|
|
10
|
-
import { Modifier } from './modifier';
|
|
11
|
-
import { ModifierContextState } from './modifiercontext';
|
|
12
|
-
import { Note } from './note';
|
|
13
|
-
import { RenderContext } from './rendercontext';
|
|
14
|
-
import { StaveNote } from './stavenote';
|
|
15
|
-
import { StaveTie } from './stavetie';
|
|
16
|
-
import { StemmableNote } from './stemmablenote';
|
|
17
|
-
import { Tables } from './tables';
|
|
18
|
-
import { TabTie } from './tabtie';
|
|
19
|
-
import { Category, isStaveNote } from './typeguard';
|
|
20
|
-
import { log } from './util';
|
|
21
|
-
import { Voice } from './voice';
|
|
22
|
-
|
|
23
|
-
// To enable logging for this class. Set `GraceNoteGroup.DEBUG` to `true`.
|
|
24
|
-
// eslint-disable-next-line
|
|
25
|
-
function L(...args: any) {
|
|
26
|
-
if (GraceNoteGroup.DEBUG) log('VexFlow.GraceNoteGroup', args);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
/** GraceNoteGroup is used to format and render grace notes. */
|
|
30
|
-
export class GraceNoteGroup extends Modifier {
|
|
31
|
-
static DEBUG: boolean = false;
|
|
32
|
-
|
|
33
|
-
static get CATEGORY(): string {
|
|
34
|
-
return Category.GraceNoteGroup;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
protected readonly voice: Voice;
|
|
38
|
-
protected readonly graceNotes: StemmableNote[];
|
|
39
|
-
protected readonly showSlur?: boolean;
|
|
40
|
-
|
|
41
|
-
protected preFormatted: boolean = false;
|
|
42
|
-
protected formatter?: Formatter;
|
|
43
|
-
public renderOptions: { slurYShift: number };
|
|
44
|
-
protected slur?: StaveTie | TabTie;
|
|
45
|
-
protected beams: Beam[];
|
|
46
|
-
|
|
47
|
-
/** Arranges groups inside a `ModifierContext`. */
|
|
48
|
-
static format(gracenoteGroups: GraceNoteGroup[], state: ModifierContextState): boolean {
|
|
49
|
-
const groupSpacingStave = 4;
|
|
50
|
-
const groupSpacingTab = 0;
|
|
51
|
-
|
|
52
|
-
if (!gracenoteGroups || gracenoteGroups.length === 0) return false;
|
|
53
|
-
|
|
54
|
-
const groupList = [];
|
|
55
|
-
let prevNote = null;
|
|
56
|
-
let shiftL = 0;
|
|
57
|
-
|
|
58
|
-
for (let i = 0; i < gracenoteGroups.length; ++i) {
|
|
59
|
-
const gracenoteGroup = gracenoteGroups[i];
|
|
60
|
-
const note = gracenoteGroup.getNote();
|
|
61
|
-
const isStavenote = isStaveNote(note);
|
|
62
|
-
const spacing = isStavenote ? groupSpacingStave : groupSpacingTab;
|
|
63
|
-
|
|
64
|
-
if (isStavenote && note !== prevNote) {
|
|
65
|
-
// Iterate through all notes to get the displaced pixels
|
|
66
|
-
for (let n = 0; n < note.keys.length; ++n) {
|
|
67
|
-
shiftL = Math.max(note.getLeftDisplacedHeadPx(), shiftL);
|
|
68
|
-
}
|
|
69
|
-
prevNote = note;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
groupList.push({ shift: shiftL, gracenoteGroup, spacing });
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
// If first note left shift in case it is displaced
|
|
76
|
-
let groupShift = groupList[0].shift;
|
|
77
|
-
let formatWidth;
|
|
78
|
-
for (let i = 0; i < groupList.length; ++i) {
|
|
79
|
-
const gracenoteGroup = groupList[i].gracenoteGroup;
|
|
80
|
-
gracenoteGroup.preFormat();
|
|
81
|
-
formatWidth = gracenoteGroup.getWidth() + groupList[i].spacing;
|
|
82
|
-
groupShift = Math.max(formatWidth, groupShift);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
for (let i = 0; i < groupList.length; ++i) {
|
|
86
|
-
const gracenoteGroup = groupList[i].gracenoteGroup;
|
|
87
|
-
formatWidth = gracenoteGroup.getWidth() + groupList[i].spacing;
|
|
88
|
-
gracenoteGroup.setSpacingFromNextModifier(
|
|
89
|
-
groupShift - Math.min(formatWidth, groupShift) + StaveNote.minNoteheadPadding
|
|
90
|
-
);
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
state.leftShift += groupShift;
|
|
94
|
-
return true;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
//** `GraceNoteGroup` inherits from `Modifier` and is placed inside a `ModifierContext`. */
|
|
98
|
-
constructor(graceNotes: StemmableNote[], showSlur?: boolean) {
|
|
99
|
-
super();
|
|
100
|
-
|
|
101
|
-
this.position = Modifier.Position.LEFT;
|
|
102
|
-
this.graceNotes = graceNotes;
|
|
103
|
-
this.width = 0;
|
|
104
|
-
|
|
105
|
-
this.showSlur = showSlur;
|
|
106
|
-
this.slur = undefined;
|
|
107
|
-
|
|
108
|
-
this.voice = new Voice({
|
|
109
|
-
numBeats: 4,
|
|
110
|
-
beatValue: 4,
|
|
111
|
-
resolution: Tables.RESOLUTION,
|
|
112
|
-
}).setStrict(false);
|
|
113
|
-
|
|
114
|
-
this.renderOptions = {
|
|
115
|
-
slurYShift: 0,
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
this.beams = [];
|
|
119
|
-
|
|
120
|
-
this.voice.addTickables(this.graceNotes);
|
|
121
|
-
|
|
122
|
-
return this;
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
preFormat(): void {
|
|
126
|
-
if (this.preFormatted) return;
|
|
127
|
-
|
|
128
|
-
if (!this.formatter) {
|
|
129
|
-
this.formatter = new Formatter();
|
|
130
|
-
}
|
|
131
|
-
this.formatter.joinVoices([this.voice]).format([this.voice], 0, {});
|
|
132
|
-
this.setWidth(this.formatter.getMinTotalWidth());
|
|
133
|
-
this.preFormatted = true;
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
beamNotes(graceNotes?: StemmableNote[]): this {
|
|
137
|
-
graceNotes = graceNotes || this.graceNotes;
|
|
138
|
-
if (graceNotes.length > 1) {
|
|
139
|
-
const beam = new Beam(graceNotes);
|
|
140
|
-
|
|
141
|
-
beam.renderOptions.beamWidth = 3;
|
|
142
|
-
beam.renderOptions.partialBeamLength = 4;
|
|
143
|
-
|
|
144
|
-
this.beams.push(beam);
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
return this;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
setWidth(width: number): this {
|
|
151
|
-
this.width = width;
|
|
152
|
-
return this;
|
|
153
|
-
}
|
|
154
|
-
|
|
155
|
-
getWidth(): number {
|
|
156
|
-
return this.width + StaveNote.minNoteheadPadding;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
getGraceNotes(): Note[] {
|
|
160
|
-
return this.graceNotes;
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
draw(): void {
|
|
164
|
-
const ctx: RenderContext = this.checkContext();
|
|
165
|
-
const note = this.checkAttachedNote();
|
|
166
|
-
this.setRendered();
|
|
167
|
-
|
|
168
|
-
L('Drawing grace note group for:', note);
|
|
169
|
-
|
|
170
|
-
this.alignSubNotesWithNote(this.getGraceNotes(), note); // Modifier function
|
|
171
|
-
|
|
172
|
-
// Draw grace notes.
|
|
173
|
-
this.graceNotes.forEach((graceNote) => graceNote.setContext(ctx).draw());
|
|
174
|
-
// Draw beams.
|
|
175
|
-
this.beams.forEach((beam) => beam.setContext(ctx).draw());
|
|
176
|
-
|
|
177
|
-
if (this.showSlur) {
|
|
178
|
-
// Create and draw slur.
|
|
179
|
-
const isStavenote = isStaveNote(note);
|
|
180
|
-
const TieClass = isStavenote ? StaveTie : TabTie;
|
|
181
|
-
|
|
182
|
-
this.slur = new TieClass({
|
|
183
|
-
lastNote: this.graceNotes[0],
|
|
184
|
-
firstNote: note,
|
|
185
|
-
firstIndexes: [0],
|
|
186
|
-
lastIndexes: [0],
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
this.slur.renderOptions.cp2 = 12;
|
|
190
|
-
this.slur.renderOptions.yShift = (isStavenote ? 7 : 5) + this.renderOptions.slurYShift;
|
|
191
|
-
this.slur.setContext(ctx).draw();
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
}
|
package/src/gracetabnote.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
// @author Balazs Forian-Szabo
|
|
3
|
-
//
|
|
4
|
-
// ## Description
|
|
5
|
-
//
|
|
6
|
-
// A basic implementation of grace notes
|
|
7
|
-
// to be rendered on a tab stave.
|
|
8
|
-
//
|
|
9
|
-
// See `tests/gracetabnote_tests.ts` for usage examples.
|
|
10
|
-
|
|
11
|
-
import { TabNote, TabNoteStruct } from './tabnote';
|
|
12
|
-
import { Category } from './typeguard';
|
|
13
|
-
|
|
14
|
-
export class GraceTabNote extends TabNote {
|
|
15
|
-
static get CATEGORY(): string {
|
|
16
|
-
return Category.GraceTabNote;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
constructor(noteStruct: TabNoteStruct) {
|
|
20
|
-
super(noteStruct, false);
|
|
21
|
-
|
|
22
|
-
this.renderOptions = {
|
|
23
|
-
...this.renderOptions,
|
|
24
|
-
// vertical shift from stave line
|
|
25
|
-
yShift: 0.3,
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
this.updateWidth();
|
|
29
|
-
}
|
|
30
|
-
}
|
package/src/index.ts
DELETED
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
// MIT License
|
|
3
|
-
|
|
4
|
-
export * from './accidental';
|
|
5
|
-
export * from './annotation';
|
|
6
|
-
export * from './articulation';
|
|
7
|
-
export * from './barnote';
|
|
8
|
-
export * from './beam';
|
|
9
|
-
export * from './bend';
|
|
10
|
-
export * from './boundingbox';
|
|
11
|
-
export * from './canvascontext';
|
|
12
|
-
export * from './chordsymbol';
|
|
13
|
-
export * from './clef';
|
|
14
|
-
export * from './clefnote';
|
|
15
|
-
export * from './crescendo';
|
|
16
|
-
export * from './curve';
|
|
17
|
-
export * from './dot';
|
|
18
|
-
export * from './easyscore';
|
|
19
|
-
export * from './element';
|
|
20
|
-
export * from './factory';
|
|
21
|
-
export * from './font';
|
|
22
|
-
// Do not export './fonts/*' because they are used by the entry/* files.
|
|
23
|
-
export * from './formatter';
|
|
24
|
-
export * from './fraction';
|
|
25
|
-
export * from './frethandfinger';
|
|
26
|
-
export * from './ghostnote';
|
|
27
|
-
export * from './glyphnote';
|
|
28
|
-
export * from './gracenote';
|
|
29
|
-
export * from './gracenotegroup';
|
|
30
|
-
export * from './gracetabnote';
|
|
31
|
-
export * from './keymanager';
|
|
32
|
-
export * from './keysignature';
|
|
33
|
-
export * from './keysignote';
|
|
34
|
-
export * from './modifier';
|
|
35
|
-
export * from './modifiercontext';
|
|
36
|
-
export * from './multimeasurerest';
|
|
37
|
-
export * from './music';
|
|
38
|
-
export * from './note';
|
|
39
|
-
export * from './notehead';
|
|
40
|
-
export * from './notesubgroup';
|
|
41
|
-
export * from './ornament';
|
|
42
|
-
export * from './parenthesis';
|
|
43
|
-
export * from './parser';
|
|
44
|
-
export * from './pedalmarking';
|
|
45
|
-
export * from './registry';
|
|
46
|
-
export * from './rendercontext';
|
|
47
|
-
export * from './renderer';
|
|
48
|
-
export * from './repeatnote';
|
|
49
|
-
export * from './stave';
|
|
50
|
-
export * from './stavebarline';
|
|
51
|
-
export * from './staveconnector';
|
|
52
|
-
export * from './stavehairpin';
|
|
53
|
-
export * from './staveline';
|
|
54
|
-
export * from './stavemodifier';
|
|
55
|
-
export * from './stavenote';
|
|
56
|
-
export * from './staverepetition';
|
|
57
|
-
export * from './stavesection';
|
|
58
|
-
export * from './stavetempo';
|
|
59
|
-
export * from './stavetext';
|
|
60
|
-
export * from './stavetie';
|
|
61
|
-
export * from './stavevolta';
|
|
62
|
-
export * from './stem';
|
|
63
|
-
export * from './stemmablenote';
|
|
64
|
-
export * from './stringnumber';
|
|
65
|
-
export * from './strokes';
|
|
66
|
-
export * from './svgcontext';
|
|
67
|
-
export * from './system';
|
|
68
|
-
// Do not export './tables' because it is internal. Its public API is accessible via VexFlow.*.
|
|
69
|
-
export * from './tabnote';
|
|
70
|
-
export * from './tabslide';
|
|
71
|
-
export * from './tabstave';
|
|
72
|
-
export * from './tabtie';
|
|
73
|
-
export * from './textbracket';
|
|
74
|
-
export * from './textdynamics';
|
|
75
|
-
export * from './textnote';
|
|
76
|
-
export * from './tickable';
|
|
77
|
-
export * from './tickcontext';
|
|
78
|
-
export * from './timesignature';
|
|
79
|
-
export * from './timesignote';
|
|
80
|
-
export * from './tremolo';
|
|
81
|
-
export * from './tuning';
|
|
82
|
-
export * from './tuplet';
|
|
83
|
-
export * from './typeguard';
|
|
84
|
-
export * from './util';
|
|
85
|
-
// Do not export './version'. It is accessible via VexFlow.BUILD.
|
|
86
|
-
export * from './vexflow';
|
|
87
|
-
export * from './vibrato';
|
|
88
|
-
export * from './vibratobracket';
|
|
89
|
-
export * from './voice';
|
|
90
|
-
export * from './web';
|
package/src/keymanager.ts
DELETED
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
//
|
|
3
|
-
// ## Description
|
|
4
|
-
//
|
|
5
|
-
// This class implements diatonic key management.
|
|
6
|
-
|
|
7
|
-
import { KeyParts, Music } from './music';
|
|
8
|
-
import { RuntimeError } from './util';
|
|
9
|
-
|
|
10
|
-
export class KeyManager {
|
|
11
|
-
protected music: Music;
|
|
12
|
-
// all attributes below are initialised in setKey which calls reset in the constructor
|
|
13
|
-
protected keyParts!: KeyParts;
|
|
14
|
-
protected keyString!: string;
|
|
15
|
-
protected key!: string;
|
|
16
|
-
protected scale!: number[];
|
|
17
|
-
protected scaleMap!: Record<string, string>;
|
|
18
|
-
protected scaleMapByValue!: Record<number, string>;
|
|
19
|
-
protected originalScaleMapByValue!: Record<number, string>;
|
|
20
|
-
|
|
21
|
-
constructor(key: string) {
|
|
22
|
-
this.music = new Music();
|
|
23
|
-
this.setKey(key);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
setKey(key: string): this {
|
|
27
|
-
this.key = key;
|
|
28
|
-
this.reset();
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
getKey(): string {
|
|
33
|
-
return this.key;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
reset(): this {
|
|
37
|
-
this.keyParts = this.music.getKeyParts(this.key);
|
|
38
|
-
|
|
39
|
-
this.keyString = this.keyParts.root;
|
|
40
|
-
if (this.keyParts.accidental) this.keyString += this.keyParts.accidental;
|
|
41
|
-
|
|
42
|
-
const isSupportedType = Music.scaleTypes[this.keyParts.type];
|
|
43
|
-
if (!isSupportedType) {
|
|
44
|
-
throw new RuntimeError('BadArguments', `Unsupported key type: ${this.key}`);
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
this.scale = this.music.getScaleTones(
|
|
48
|
-
this.music.getNoteValue(this.keyString),
|
|
49
|
-
Music.scaleTypes[this.keyParts.type]
|
|
50
|
-
);
|
|
51
|
-
|
|
52
|
-
this.scaleMap = {};
|
|
53
|
-
this.scaleMapByValue = {};
|
|
54
|
-
this.originalScaleMapByValue = {};
|
|
55
|
-
|
|
56
|
-
const noteLocation = Music.rootIndexes[this.keyParts.root];
|
|
57
|
-
|
|
58
|
-
for (let i = 0; i < Music.roots.length; ++i) {
|
|
59
|
-
const index = (noteLocation + i) % Music.roots.length;
|
|
60
|
-
const rootName = Music.roots[index];
|
|
61
|
-
|
|
62
|
-
const noteName = this.music.getRelativeNoteName(rootName, this.scale[i]);
|
|
63
|
-
this.scaleMap[rootName] = noteName;
|
|
64
|
-
this.scaleMapByValue[this.scale[i]] = noteName;
|
|
65
|
-
this.originalScaleMapByValue[this.scale[i]] = noteName;
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return this;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
getAccidental(key: string): {
|
|
72
|
-
note: string;
|
|
73
|
-
accidental?: string;
|
|
74
|
-
change?: boolean;
|
|
75
|
-
} {
|
|
76
|
-
const root = this.music.getKeyParts(key).root;
|
|
77
|
-
const parts = this.music.getNoteParts(this.scaleMap[root]);
|
|
78
|
-
|
|
79
|
-
return {
|
|
80
|
-
note: this.scaleMap[root],
|
|
81
|
-
accidental: parts.accidental,
|
|
82
|
-
};
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
selectNote(note: string): {
|
|
86
|
-
note: string;
|
|
87
|
-
accidental?: string;
|
|
88
|
-
change: boolean;
|
|
89
|
-
} {
|
|
90
|
-
note = note.toLowerCase();
|
|
91
|
-
const parts = this.music.getNoteParts(note);
|
|
92
|
-
|
|
93
|
-
// First look for matching note in our altered scale
|
|
94
|
-
const scaleNote = this.scaleMap[parts.root];
|
|
95
|
-
const modparts = this.music.getNoteParts(scaleNote);
|
|
96
|
-
|
|
97
|
-
if (scaleNote === note) {
|
|
98
|
-
return {
|
|
99
|
-
note: scaleNote,
|
|
100
|
-
accidental: parts.accidental,
|
|
101
|
-
change: false,
|
|
102
|
-
};
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
// Then search for a note of equivalent value in our altered scale
|
|
106
|
-
const valueNote = this.scaleMapByValue[this.music.getNoteValue(note)];
|
|
107
|
-
if (valueNote !== undefined) {
|
|
108
|
-
return {
|
|
109
|
-
note: valueNote,
|
|
110
|
-
accidental: this.music.getNoteParts(valueNote).accidental,
|
|
111
|
-
change: false,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
// Then search for a note of equivalent value in the original scale
|
|
116
|
-
const originalValueNote = this.originalScaleMapByValue[this.music.getNoteValue(note)];
|
|
117
|
-
if (originalValueNote !== undefined) {
|
|
118
|
-
this.scaleMap[modparts.root] = originalValueNote;
|
|
119
|
-
delete this.scaleMapByValue[this.music.getNoteValue(scaleNote)];
|
|
120
|
-
this.scaleMapByValue[this.music.getNoteValue(note)] = originalValueNote;
|
|
121
|
-
return {
|
|
122
|
-
note: originalValueNote,
|
|
123
|
-
accidental: this.music.getNoteParts(originalValueNote).accidental,
|
|
124
|
-
change: true,
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// Then try to unmodify a currently modified note.
|
|
129
|
-
if (modparts.root === note) {
|
|
130
|
-
delete this.scaleMapByValue[this.music.getNoteValue(this.scaleMap[parts.root])];
|
|
131
|
-
this.scaleMapByValue[this.music.getNoteValue(modparts.root)] = modparts.root;
|
|
132
|
-
this.scaleMap[modparts.root] = modparts.root;
|
|
133
|
-
return {
|
|
134
|
-
note: modparts.root,
|
|
135
|
-
accidental: undefined,
|
|
136
|
-
change: true,
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
// Last resort -- shitshoot
|
|
141
|
-
delete this.scaleMapByValue[this.music.getNoteValue(this.scaleMap[parts.root])];
|
|
142
|
-
this.scaleMapByValue[this.music.getNoteValue(note)] = note;
|
|
143
|
-
|
|
144
|
-
delete this.scaleMap[modparts.root];
|
|
145
|
-
this.scaleMap[modparts.root] = note;
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
note,
|
|
149
|
-
accidental: parts.accidental,
|
|
150
|
-
change: true,
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
}
|