Skip to content

Commit 3435bdc

Browse files
more dependencies, update vexflow for types
1 parent 3646aaa commit 3435bdc

File tree

8 files changed

+79
-233
lines changed

8 files changed

+79
-233
lines changed

package-lock.json

Lines changed: 60 additions & 201 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
"grunt": "^1.5.3",
99
"grunt-typedoc": "^0.2.4",
1010
"grunt-webpack": "^4.0.3",
11-
"@knodes/typedoc-plugin-pages": "^0.23.0",
1211
"jquery": "^3.6.0"
1312
},
1413
"dependencies": {
@@ -23,7 +22,7 @@
2322
"ts-loader": "^9.2.5",
2423
"typedoc": "^0.25.0",
2524
"typescript": "^5.2.2",
26-
"vexflow_smoosic": "4.2.2",
25+
"vexflow_smoosic": "4.2.6",
2726
"webpack": "^5.89.0",
2827
"xmldom": "^0.6.0"
2928
},

src/common/vex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,7 @@ export function getChordSymbolMetricsForGlyph(code: string) {
386386
code = 'accidentalSharp';
387387
}
388388
const glyphMetrics = VexChordSymbol.metrics;
389-
return glyphMetrics[code];
389+
return (glyphMetrics as any)[code];
390390
}
391391
/**
392392
* Vex 5 compatibility. yShift

src/smo/data/scoreText.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,8 @@ import { smoSerialize } from '../../common/serializationHelpers';
1010
import { SmoScoreModifierBase, ScaledPageLayout } from './scoreModifiers';
1111
import { SmoAttrs, SmoModifierBase } from './common';
1212
import { SmoSelector } from '../xform/selections';
13-
import { VexFlow, FontInfo } from '../../common/vex';
13+
import { FontInfo } from '../../common/vex';
1414
import { TextFormatter } from '../../common/textformatter';
15-
const VF = VexFlow;
16-
1715

1816
/**
1917
* Parameters for a single text block. Text blocks make up a text group.

src/smo/mxml/xmlHelpers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@ import { SmoNote } from '../data/note';
77
import { Pitch, PitchLetter } from '../data/common';
88
import { SmoSelector } from '../xform/selections';
99
import { SmoBarline } from '../data/measureModifiers';
10-
import { VexFlow } from '../../common/vex';
11-
12-
const VF = VexFlow;
1310

1411
export interface XmlOrnamentData {
1512
ctor: string,
@@ -83,7 +80,7 @@ export class XmlHelpers {
8380
// ### closestStemType
8481
// smo infers the stem type from the duration, but other applications don't
8582
static closestStemType(ticks: number) {
86-
const nticks = VF.durationToTicks(SmoMusic.vexStemType(ticks));
83+
const nticks = SmoMusic.closestDurationTickLtEq(ticks);
8784
return XmlHelpers.ticksToNoteTypeMap[nticks];
8885
}
8986
static get beamStates(): Record<string, number> {

src/smo/xform/beamers.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,6 @@ import { SmoAttrs, getId } from '../data/common';
66
import { SmoMeasure, ISmoBeamGroup } from '../data/measure';
77
import { TickMap } from './tickMap';
88
import { smoSerialize } from '../../common/serializationHelpers';
9-
import { VexFlow } from '../../common/vex';
10-
const VF = VexFlow;
119

1210
export interface SmoBeamGroupParams {
1311
notes: SmoNote[],
@@ -154,8 +152,7 @@ export class SmoBeamer {
154152
}
155153

156154
// is this beamable length-wise
157-
const vexDuration = SmoMusic.closestVexDuration(note.tickCount);
158-
const stemTicks = VF.durationToTicks(vexDuration);
155+
const stemTicks = SmoMusic.closestDurationTickLtEq(note.tickCount);
159156
if (note.noteType === 'n' && stemTicks < 4096) {
160157
this.currentGroup.push(note);
161158
}

src/smo/xform/operations.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,6 @@ import {
2222
SmoUnmakeTupletActor, SmoContractTupletActor
2323
} from './tickDuration';
2424
import { SmoBeamer } from './beamers';
25-
import { smoSerialize } from '../../common/serializationHelpers';
26-
import { VexFlow } from '../../common/vex';
27-
const VF = VexFlow;
28-
2925
/**
3026
* supported operations for {@link SmoOperation.batchSelectionOperation} to change a note's duration
3127
*/
@@ -371,7 +367,7 @@ export class SmoOperation {
371367
// Don't dot if the thing on the right of the . is too small
372368
const dotCount = SmoMusic.smoTicksToVexDots(nticks);
373369
const multiplier = Math.pow(2, dotCount);
374-
const baseDot = VF.durationToTicks(SmoMusic.closestVexDuration(nticks)) / (multiplier * 2);
370+
const baseDot = SmoMusic.closestDurationTickLtEq(nticks) / (multiplier * 2);
375371
if (baseDot <= 128) {
376372
return;
377373
}

src/smo/xform/tickMap.ts

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
// Copyright (c) Aaron David Newman 2021.
33
import { SmoMusic } from '../data/music';
44
import { TickMappable } from '../data/measure';
5-
import { Pitch, PitchLetter, TickAccidental } from '../data/common';
5+
import { Pitch, IsPitchLetter, TickAccidental } from '../data/common';
66
import { SmoNote } from '../data/note';
7-
import { VexFlow } from '../../common/vex';
87

98
/**
109
* create a map note durations at each index into the voice, including the accidentals at each duration.
@@ -50,21 +49,22 @@ export class TickMap {
5049
// ### _getAccidentalsForKey
5150
// Update `map` with the correct accidental based on the key signature.
5251
_getAccidentalsForKey(map: Record<string, TickAccidental>) {
53-
const music: any = new VexFlow.Music();
54-
const keys = music.createScaleMap(this.keySignature);
52+
const keys = SmoMusic.getScaleTonesForKey(this.keySignature);
5553
const keyKeys = Object.keys(keys);
5654
keyKeys.forEach((keyKey) => {
5755
const vexKey = keys[keyKey];
5856
if (vexKey.length > 1 && (vexKey[1] === 'b' || vexKey[1] === '#')) {
59-
const pitch = {
60-
letter: vexKey[0],
61-
accidental: vexKey[1],
62-
octave: 4
63-
};
64-
map[vexKey[0]] = {
65-
duration: 0,
66-
pitch
67-
};
57+
if (IsPitchLetter(vexKey[0])) {
58+
const pitch = {
59+
letter: vexKey[0],
60+
accidental: vexKey[1],
61+
octave: 4
62+
};
63+
map[vexKey[0]] = {
64+
duration: 0,
65+
pitch
66+
};
67+
}
6868
}
6969
});
7070
}

0 commit comments

Comments
 (0)