vexflow 5.0.0-alpha.2 → 5.0.0-alpha.4
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 +528 -492
- package/build/cjs/vexflow-debug-with-tests.js.map +1 -1
- package/build/cjs/vexflow-debug.js +460 -452
- 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/accidental.js +22 -28
- package/build/esm/src/beam.js +24 -42
- package/build/esm/src/clefnote.js +6 -1
- package/build/esm/src/element.js +83 -101
- package/build/esm/src/fonts/gonville.js +1 -1
- package/build/esm/src/formatter.js +9 -17
- package/build/esm/src/fraction.js +15 -22
- package/build/esm/src/glyphnote.js +3 -2
- package/build/esm/src/metrics.js +3 -0
- package/build/esm/src/modifier.js +6 -21
- package/build/esm/src/multimeasurerest.js +16 -25
- package/build/esm/src/note.js +7 -0
- package/build/esm/src/registry.js +5 -19
- package/build/esm/src/stave.js +4 -6
- package/build/esm/src/stavenote.js +26 -40
- package/build/esm/src/stavetempo.js +4 -11
- package/build/esm/src/stavetie.js +82 -36
- package/build/esm/src/svgcontext.js +5 -12
- package/build/esm/src/tickable.js +13 -26
- package/build/esm/src/tickcontext.js +20 -2
- package/build/esm/src/version.js +3 -3
- package/build/esm/src/vibrato.js +6 -1
- package/build/esm/tests/clef_tests.js +5 -1
- package/build/esm/tests/glyphnote_tests.js +6 -0
- package/build/esm/tests/stavetie_tests.js +29 -0
- package/build/esm/tests/tabstave_tests.js +1 -0
- package/build/esm/tests/vexflow_test_helpers.js +25 -39
- package/build/types/src/accidental.d.ts +19 -1
- package/build/types/src/annotation.d.ts +1 -1
- package/build/types/src/beam.d.ts +12 -1
- package/build/types/src/clefnote.d.ts +2 -0
- package/build/types/src/element.d.ts +13 -3
- package/build/types/src/fonts/gonville.d.ts +1 -1
- package/build/types/src/formatter.d.ts +5 -3
- package/build/types/src/fraction.d.ts +12 -7
- package/build/types/src/modifier.d.ts +2 -1
- package/build/types/src/multimeasurerest.d.ts +4 -1
- package/build/types/src/note.d.ts +2 -0
- package/build/types/src/registry.d.ts +1 -1
- package/build/types/src/stavenote.d.ts +2 -1
- package/build/types/src/stavetempo.d.ts +3 -3
- package/build/types/src/stavetie.d.ts +39 -2
- package/build/types/src/svgcontext.d.ts +1 -1
- package/build/types/src/tickable.d.ts +2 -1
- package/build/types/src/tickcontext.d.ts +30 -0
- package/package.json +2 -4
- package/tests/flow.html +2 -2
- 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/timesignature.ts
DELETED
|
@@ -1,229 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
//
|
|
3
|
-
// ## Description
|
|
4
|
-
// Implements time signatures glyphs for staffs
|
|
5
|
-
// See tables.js for the internal time signatures
|
|
6
|
-
// representation
|
|
7
|
-
|
|
8
|
-
import { Element } from './element';
|
|
9
|
-
import { Glyphs } from './glyphs';
|
|
10
|
-
import { RenderContext } from './rendercontext';
|
|
11
|
-
import { Stave } from './stave';
|
|
12
|
-
import { StaveModifier, StaveModifierPosition } from './stavemodifier';
|
|
13
|
-
import { Category } from './typeguard';
|
|
14
|
-
import { RuntimeError } from './util';
|
|
15
|
-
|
|
16
|
-
export interface TimeSignatureInfo {
|
|
17
|
-
glyph: string;
|
|
18
|
-
line: number;
|
|
19
|
-
num: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const assertIsValidTimeSig = (timeSpec: string) => {
|
|
23
|
-
const numbers = timeSpec.split('/');
|
|
24
|
-
|
|
25
|
-
numbers.forEach((number) => {
|
|
26
|
-
// Characters consisting in number 0..9, '+', '-', '(' or ')'
|
|
27
|
-
if (/^[0-9+\-()]+$/.test(number) === false) {
|
|
28
|
-
throw new RuntimeError('BadTimeSignature', `Invalid time spec: ${timeSpec}. Must contain valid signatures.`);
|
|
29
|
-
}
|
|
30
|
-
});
|
|
31
|
-
};
|
|
32
|
-
|
|
33
|
-
/**
|
|
34
|
-
* A TimeSignature is a StaveModifier that can make its appropriate Glyphs directly from
|
|
35
|
-
* a provided "timeSpec" such as "4/4", "C|" (cut time), or even something more advanced
|
|
36
|
-
* such as "3/4(6/8)" or "2/4+5/8".
|
|
37
|
-
*/
|
|
38
|
-
export class TimeSignature extends StaveModifier {
|
|
39
|
-
static get CATEGORY(): string {
|
|
40
|
-
return Category.TimeSignature;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
bottomLine: number; // bottomLine and topLine are used to calculate the position of the
|
|
44
|
-
topLine: number; // top row of digits in a numeric TimeSignature.
|
|
45
|
-
|
|
46
|
-
protected timeSpec: string = '4/4';
|
|
47
|
-
protected line: number = 0;
|
|
48
|
-
protected topText: Element;
|
|
49
|
-
protected botText: Element;
|
|
50
|
-
protected isNumeric: boolean = true;
|
|
51
|
-
protected validateArgs: boolean;
|
|
52
|
-
protected topStartX: number = 0;
|
|
53
|
-
protected botStartX: number = 0;
|
|
54
|
-
protected lineShift: number = 0;
|
|
55
|
-
|
|
56
|
-
constructor(timeSpec: string = '4/4', customPadding = 15, validateArgs = true) {
|
|
57
|
-
super();
|
|
58
|
-
this.topText = new Element();
|
|
59
|
-
this.botText = new Element();
|
|
60
|
-
this.validateArgs = validateArgs;
|
|
61
|
-
|
|
62
|
-
const padding = customPadding;
|
|
63
|
-
|
|
64
|
-
this.topLine = 1;
|
|
65
|
-
this.bottomLine = 3;
|
|
66
|
-
this.setPosition(StaveModifierPosition.BEGIN);
|
|
67
|
-
this.setTimeSig(timeSpec);
|
|
68
|
-
this.setPadding(padding);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
static getTimeSigCode(key: string, smallSig = false): string {
|
|
72
|
-
let code: string = Glyphs.null;
|
|
73
|
-
switch (key) {
|
|
74
|
-
case 'C':
|
|
75
|
-
code = Glyphs.timeSigCommon;
|
|
76
|
-
break;
|
|
77
|
-
case 'C|':
|
|
78
|
-
code = Glyphs.timeSigCutCommon;
|
|
79
|
-
break;
|
|
80
|
-
case '+':
|
|
81
|
-
code = smallSig ? Glyphs.timeSigPlusSmall : Glyphs.timeSigPlus;
|
|
82
|
-
break;
|
|
83
|
-
case '-':
|
|
84
|
-
code = Glyphs.timeSigMinus;
|
|
85
|
-
break;
|
|
86
|
-
case '(':
|
|
87
|
-
code = smallSig ? Glyphs.timeSigParensLeftSmall : Glyphs.timeSigParensLeft;
|
|
88
|
-
break;
|
|
89
|
-
case ')':
|
|
90
|
-
code = smallSig ? Glyphs.timeSigParensRightSmall : Glyphs.timeSigParensRight;
|
|
91
|
-
break;
|
|
92
|
-
default:
|
|
93
|
-
code = String.fromCodePoint(0xe080 + Number(key[0])) /* timeSigN = Glyphs.timeSig0 + N */;
|
|
94
|
-
break;
|
|
95
|
-
}
|
|
96
|
-
return code;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Returns a new TimeSignatureGlyph (a Glyph subclass that knows how to draw both
|
|
101
|
-
* top and bottom digits along with plus signs etc.)
|
|
102
|
-
*/
|
|
103
|
-
makeTimeSignatureGlyph(topDigits: string, botDigits: string): void {
|
|
104
|
-
// note that 'code' is ignored by TimeSignatureGlyph when rendering.
|
|
105
|
-
let txt = '';
|
|
106
|
-
let topWidth = 0;
|
|
107
|
-
let height = 0;
|
|
108
|
-
for (let i = 0; i < topDigits.length; ++i) {
|
|
109
|
-
const code = TimeSignature.getTimeSigCode(topDigits[i], botDigits.length > 0);
|
|
110
|
-
txt += code;
|
|
111
|
-
}
|
|
112
|
-
this.topText.setText(txt);
|
|
113
|
-
topWidth = this.topText.getWidth();
|
|
114
|
-
height = this.topText.getHeight();
|
|
115
|
-
|
|
116
|
-
let botWidth = 0;
|
|
117
|
-
txt = '';
|
|
118
|
-
for (let i = 0; i < botDigits.length; ++i) {
|
|
119
|
-
const code = TimeSignature.getTimeSigCode(botDigits[i], true);
|
|
120
|
-
txt += code;
|
|
121
|
-
}
|
|
122
|
-
this.botText.setText(txt);
|
|
123
|
-
botWidth = this.botText.getWidth();
|
|
124
|
-
height = Math.max(height, this.botText.getHeight());
|
|
125
|
-
|
|
126
|
-
// If the height of the digits is more than three staff spaces (30), shift half a line line
|
|
127
|
-
// in order to center the digits on lines 1.5 and 4.5 rather than 2 and 4.
|
|
128
|
-
this.lineShift = height > 30 ? 0.5 : 0;
|
|
129
|
-
|
|
130
|
-
this.width = Math.max(topWidth, botWidth);
|
|
131
|
-
this.topStartX = (this.width - topWidth) / 2.0;
|
|
132
|
-
this.botStartX = (this.width - botWidth) / 2.0;
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
/**
|
|
136
|
-
* Set a new time signature specification without changing customPadding, etc.
|
|
137
|
-
*
|
|
138
|
-
* The getter for this is `getTimeSpec` not `getTimeSig`.
|
|
139
|
-
*/
|
|
140
|
-
setTimeSig(timeSpec: string): this {
|
|
141
|
-
this.timeSpec = timeSpec;
|
|
142
|
-
if (timeSpec === 'C' || timeSpec === 'C|') {
|
|
143
|
-
const code = TimeSignature.getTimeSigCode(timeSpec);
|
|
144
|
-
this.line = 2;
|
|
145
|
-
this.text = code;
|
|
146
|
-
this.isNumeric = false;
|
|
147
|
-
} else {
|
|
148
|
-
if (this.validateArgs) {
|
|
149
|
-
assertIsValidTimeSig(timeSpec);
|
|
150
|
-
}
|
|
151
|
-
const parts = timeSpec.split('/');
|
|
152
|
-
this.line = 0;
|
|
153
|
-
this.isNumeric = true;
|
|
154
|
-
this.makeTimeSignatureGlyph(parts[0] ?? '', parts[1] ?? '');
|
|
155
|
-
}
|
|
156
|
-
return this;
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
/**
|
|
160
|
-
* Return the timeSpec (such as '4/4' or 'C|' or even '2/4+3/8') of the TimeSignature
|
|
161
|
-
*/
|
|
162
|
-
getTimeSpec(): string {
|
|
163
|
-
return this.timeSpec;
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
/**
|
|
167
|
-
* Return the staff line that the TimeSignature sits on. Generally 0 for numerator/
|
|
168
|
-
* denominator time signatures such as 3/4 and 2 for cut/common.
|
|
169
|
-
*/
|
|
170
|
-
getLine(): number {
|
|
171
|
-
return this.line;
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
/**
|
|
175
|
-
* Set the line number that the TimeSignature sits on. Half-values are acceptable
|
|
176
|
-
* for spaces, etc. Can be altered, for instance, for signatures that sit above the
|
|
177
|
-
* staff in large orchestral scores.
|
|
178
|
-
*/
|
|
179
|
-
setLine(line: number) {
|
|
180
|
-
this.line = line;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
/**
|
|
184
|
-
* Return a boolean on whether this TimeSignature is drawn with one or more numbers
|
|
185
|
-
* (such as 4/4) or not (as in cut time).
|
|
186
|
-
*/
|
|
187
|
-
getIsNumeric(): boolean {
|
|
188
|
-
return this.isNumeric;
|
|
189
|
-
}
|
|
190
|
-
|
|
191
|
-
/**
|
|
192
|
-
* Set whether this TimeSignature is drawn with one or more numbers.
|
|
193
|
-
*/
|
|
194
|
-
setIsNumeric(isNumeric: boolean) {
|
|
195
|
-
this.isNumeric = isNumeric;
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
/**
|
|
199
|
-
* Draw the time signature on a Stave using its RenderContext. Both setStave
|
|
200
|
-
* and setContext must already be run.
|
|
201
|
-
*/
|
|
202
|
-
draw(): void {
|
|
203
|
-
const stave = this.checkStave();
|
|
204
|
-
const ctx = stave.checkContext();
|
|
205
|
-
this.setRendered();
|
|
206
|
-
this.drawAt(ctx, stave, this.x);
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
drawAt(ctx: RenderContext, stave: Stave, x: number): void {
|
|
210
|
-
this.setRendered();
|
|
211
|
-
|
|
212
|
-
this.applyStyle(ctx);
|
|
213
|
-
ctx.openGroup('timesignature', this.getAttribute('id'));
|
|
214
|
-
if (this.isNumeric) {
|
|
215
|
-
let startX = x + this.topStartX;
|
|
216
|
-
let y = 0;
|
|
217
|
-
if (this.botText.getText().length > 0) y = stave.getYForLine(this.topLine - this.lineShift);
|
|
218
|
-
else y = (stave.getYForLine(this.topLine) + stave.getYForLine(this.bottomLine)) / 2;
|
|
219
|
-
this.topText.renderText(ctx, startX, y);
|
|
220
|
-
startX = x + this.botStartX;
|
|
221
|
-
y = stave.getYForLine(this.bottomLine + this.lineShift);
|
|
222
|
-
this.botText.renderText(ctx, startX, y);
|
|
223
|
-
} else {
|
|
224
|
-
this.renderText(ctx, x - this.x, stave.getYForLine(this.line));
|
|
225
|
-
}
|
|
226
|
-
ctx.closeGroup();
|
|
227
|
-
this.restoreStyle(ctx);
|
|
228
|
-
}
|
|
229
|
-
}
|
package/src/timesignote.ts
DELETED
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
// @author: Taehoon Moon 2014
|
|
3
|
-
|
|
4
|
-
import { ModifierContext } from './modifiercontext';
|
|
5
|
-
import { Note } from './note';
|
|
6
|
-
import { TimeSignature } from './timesignature';
|
|
7
|
-
import { Category } from './typeguard';
|
|
8
|
-
|
|
9
|
-
export class TimeSigNote extends Note {
|
|
10
|
-
static get CATEGORY(): string {
|
|
11
|
-
return Category.TimeSigNote;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
protected timeSig: TimeSignature;
|
|
15
|
-
|
|
16
|
-
constructor(timeSpec: string, customPadding?: number) {
|
|
17
|
-
super({ duration: 'b' });
|
|
18
|
-
|
|
19
|
-
this.timeSig = new TimeSignature(timeSpec, customPadding);
|
|
20
|
-
this.setWidth(this.timeSig.getWidth());
|
|
21
|
-
|
|
22
|
-
// Note properties
|
|
23
|
-
this.ignoreTicks = true;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/* Overridden to ignore */
|
|
27
|
-
// eslint-disable-next-line
|
|
28
|
-
addToModifierContext(mc: ModifierContext): this {
|
|
29
|
-
// DO NOTHING.
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
preFormat(): this {
|
|
34
|
-
this.preFormatted = true;
|
|
35
|
-
return this;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
draw(): void {
|
|
39
|
-
const stave = this.checkStave();
|
|
40
|
-
const ctx = this.checkContext();
|
|
41
|
-
this.setRendered();
|
|
42
|
-
|
|
43
|
-
this.timeSig.drawAt(ctx, stave, this.getAbsoluteX());
|
|
44
|
-
}
|
|
45
|
-
}
|
package/src/tremolo.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
// Copyright (c) 2023-present VexFlow contributors: https://github.com/vexflow/vexflow/graphs/contributors
|
|
2
|
-
// @author Mike Corrigan <corrigan@gmail.com>
|
|
3
|
-
// MIT License
|
|
4
|
-
|
|
5
|
-
import { Glyphs } from './glyphs';
|
|
6
|
-
import { Metrics } from './metrics';
|
|
7
|
-
import { Modifier } from './modifier';
|
|
8
|
-
import { Stem } from './stem';
|
|
9
|
-
import { Category } from './typeguard';
|
|
10
|
-
|
|
11
|
-
/** Tremolo implements tremolo notation. */
|
|
12
|
-
export class Tremolo extends Modifier {
|
|
13
|
-
static get CATEGORY(): string {
|
|
14
|
-
return Category.Tremolo;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
protected readonly num: number;
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* @param num number of bars
|
|
21
|
-
*/
|
|
22
|
-
constructor(num: number) {
|
|
23
|
-
super();
|
|
24
|
-
|
|
25
|
-
this.num = num;
|
|
26
|
-
this.position = Modifier.Position.CENTER;
|
|
27
|
-
this.text = Glyphs.tremolo1;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Draw the tremolo on the rendering context. */
|
|
31
|
-
draw(): void {
|
|
32
|
-
const ctx = this.checkContext();
|
|
33
|
-
const note = this.checkAttachedNote();
|
|
34
|
-
this.setRendered();
|
|
35
|
-
|
|
36
|
-
const stemDirection = note.getStemDirection();
|
|
37
|
-
const scale = note.getFontScale();
|
|
38
|
-
const ySpacing = Metrics.get(`Tremolo.spacing`) * stemDirection * scale;
|
|
39
|
-
|
|
40
|
-
const x =
|
|
41
|
-
note.getAbsoluteX() + (stemDirection === Stem.UP ? note.getGlyphWidth() - Stem.WIDTH / 2 : Stem.WIDTH / 2);
|
|
42
|
-
let y = note.getStemExtents().topY + (this.num <= 3 ? ySpacing : 0);
|
|
43
|
-
|
|
44
|
-
this.fontInfo.size = Metrics.get(`Tremolo.fontSize`) * scale;
|
|
45
|
-
|
|
46
|
-
for (let i = 0; i < this.num; ++i) {
|
|
47
|
-
this.renderText(ctx, x, y);
|
|
48
|
-
y += ySpacing;
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
}
|
package/src/tuning.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
|
-
import { Tables } from './tables';
|
|
5
|
-
import { RuntimeError } from './util';
|
|
6
|
-
|
|
7
|
-
/** `Tuning` implements varies types of tunings for tablature. */
|
|
8
|
-
export class Tuning {
|
|
9
|
-
protected tuningValues: number[] = [];
|
|
10
|
-
|
|
11
|
-
static get names(): Record<string, string> {
|
|
12
|
-
return {
|
|
13
|
-
standard: 'E/5,B/4,G/4,D/4,A/3,E/3',
|
|
14
|
-
dagdad: 'D/5,A/4,G/4,D/4,A/3,D/3',
|
|
15
|
-
dropd: 'E/5,B/4,G/4,D/4,A/3,D/3',
|
|
16
|
-
eb: 'Eb/5,Bb/4,Gb/4,Db/4,Ab/3,Db/3',
|
|
17
|
-
standardBanjo: 'D/5,B/4,G/4,D/4,G/5',
|
|
18
|
-
};
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Constructor.
|
|
23
|
-
* @param tuningString tuning name (eg. 'dagdad') or comma separated note strings
|
|
24
|
-
*/
|
|
25
|
-
constructor(tuningString = 'E/5,B/4,G/4,D/4,A/3,E/3,B/2,E/2') {
|
|
26
|
-
// Default to standard tuning.
|
|
27
|
-
this.setTuning(tuningString);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
/** Return the note number associated to the note string. */
|
|
31
|
-
noteToInteger(noteString: string): number {
|
|
32
|
-
return Tables.keyProperties(noteString).intValue ?? -1;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Set tuning identified by tuning name (eg. 'dagdad')
|
|
37
|
-
* @param tuningString tuning name (eg. 'dagdad') or comma separated note strings
|
|
38
|
-
*/
|
|
39
|
-
setTuning(tuningString: string): void {
|
|
40
|
-
if (Tuning.names[tuningString]) {
|
|
41
|
-
tuningString = Tuning.names[tuningString];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
this.tuningValues = [];
|
|
45
|
-
|
|
46
|
-
const keys = tuningString.split(/\s*,\s*/);
|
|
47
|
-
if (keys.length === 0) {
|
|
48
|
-
throw new RuntimeError('BadArguments', `Invalid tuning string: ${tuningString}`);
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (let i = 0; i < keys.length; ++i) {
|
|
52
|
-
this.tuningValues[i] = this.noteToInteger(keys[i]);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/** Return the note number associated with a tablature string. */
|
|
57
|
-
getValueForString(stringNum: string | number): number {
|
|
58
|
-
const s = Number(stringNum);
|
|
59
|
-
if (s < 1 || s > this.tuningValues.length) {
|
|
60
|
-
throw new RuntimeError(
|
|
61
|
-
'BadArguments',
|
|
62
|
-
`String number must be between 1 and ${this.tuningValues.length}:${stringNum}`
|
|
63
|
-
);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
return this.tuningValues[s - 1];
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/** Return the note number associated with a tablature string and fret. */
|
|
70
|
-
getValueForFret(fretNum: string | number, stringNum: string | number): number {
|
|
71
|
-
const stringValue = this.getValueForString(stringNum);
|
|
72
|
-
const f = Number(fretNum);
|
|
73
|
-
|
|
74
|
-
if (f < 0) {
|
|
75
|
-
throw new RuntimeError('BadArguments', `Fret number must be 0 or higher: ${fretNum}`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
return stringValue + f;
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
/** Return the note string associated with tablature string and fret. */
|
|
82
|
-
getNoteForFret(fretNum: string | number, stringNum: string | number): string {
|
|
83
|
-
const noteValue = this.getValueForFret(fretNum, stringNum);
|
|
84
|
-
|
|
85
|
-
const octave = Math.floor(noteValue / 12);
|
|
86
|
-
const value = noteValue % 12;
|
|
87
|
-
|
|
88
|
-
return `${Tables.integerToNote(value)}/${octave}`;
|
|
89
|
-
}
|
|
90
|
-
}
|