|
@@ -1,4 +1,5 @@
|
|
|
import Vex from "vexflow";
|
|
|
+import VF = Vex.Flow;
|
|
|
import {GraphicalMeasure} from "../GraphicalMeasure";
|
|
|
import {SourceMeasure} from "../../VoiceData/SourceMeasure";
|
|
|
import {Staff} from "../../VoiceData/Staff";
|
|
@@ -12,10 +13,10 @@ import {VexFlowStaffEntry} from "./VexFlowStaffEntry";
|
|
|
import {Beam} from "../../VoiceData/Beam";
|
|
|
import {GraphicalNote} from "../GraphicalNote";
|
|
|
import {GraphicalStaffEntry} from "../GraphicalStaffEntry";
|
|
|
-import StaveConnector = Vex.Flow.StaveConnector;
|
|
|
-import StaveNote = Vex.Flow.StaveNote;
|
|
|
-import StemmableNote = Vex.Flow.StemmableNote;
|
|
|
-import NoteSubGroup = Vex.Flow.NoteSubGroup;
|
|
|
+import StaveConnector = VF.StaveConnector;
|
|
|
+import StaveNote = VF.StaveNote;
|
|
|
+import StemmableNote = VF.StemmableNote;
|
|
|
+import NoteSubGroup = VF.NoteSubGroup;
|
|
|
import log from "loglevel";
|
|
|
import {unitInPixels} from "./VexFlowMusicSheetDrawer";
|
|
|
import {Tuplet} from "../../VoiceData/Tuplet";
|
|
@@ -37,7 +38,7 @@ import { NoteType } from "../../VoiceData/NoteType";
|
|
|
import { Arpeggio } from "../../VoiceData/Arpeggio";
|
|
|
import { GraphicalTie } from "../GraphicalTie";
|
|
|
|
|
|
-// type StemmableNote = Vex.Flow.StemmableNote;
|
|
|
+// type StemmableNote = VF.StemmableNote;
|
|
|
|
|
|
export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
constructor(staff: Staff, sourceMeasure: SourceMeasure = undefined, staffLine: StaffLine = undefined) {
|
|
@@ -62,29 +63,29 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
/** octaveOffset according to active clef */
|
|
|
public octaveOffset: number = 3;
|
|
|
/** The VexFlow Voices in the measure */
|
|
|
- public vfVoices: { [voiceID: number]: Vex.Flow.Voice } = {};
|
|
|
+ public vfVoices: { [voiceID: number]: VF.Voice } = {};
|
|
|
/** Call this function (if present) to x-format all the voices in the measure */
|
|
|
public formatVoices: (width: number, parent: VexFlowMeasure) => void;
|
|
|
/** The VexFlow Ties in the measure */
|
|
|
- public vfTies: Vex.Flow.StaveTie[] = [];
|
|
|
+ public vfTies: VF.StaveTie[] = [];
|
|
|
/** The repetition instructions given as words or symbols (coda, dal segno..) */
|
|
|
- public vfRepetitionWords: Vex.Flow.Repetition[] = [];
|
|
|
+ public vfRepetitionWords: VF.Repetition[] = [];
|
|
|
/** The VexFlow Stave (= one measure in a staffline) */
|
|
|
- protected stave: Vex.Flow.Stave;
|
|
|
+ protected stave: VF.Stave;
|
|
|
/** VexFlow StaveConnectors (vertical lines) */
|
|
|
- protected connectors: Vex.Flow.StaveConnector[] = [];
|
|
|
+ protected connectors: VF.StaveConnector[] = [];
|
|
|
/** Intermediate object to construct beams */
|
|
|
private beams: { [voiceID: number]: [Beam, VexFlowVoiceEntry[]][] } = {};
|
|
|
/** Beams created by (optional) autoBeam function. */
|
|
|
- private autoVfBeams: Vex.Flow.Beam[];
|
|
|
+ private autoVfBeams: VF.Beam[];
|
|
|
/** Beams of tuplet notes created by (optional) autoBeam function. */
|
|
|
- private autoTupletVfBeams: Vex.Flow.Beam[];
|
|
|
+ private autoTupletVfBeams: VF.Beam[];
|
|
|
/** VexFlow Beams */
|
|
|
- private vfbeams: { [voiceID: number]: Vex.Flow.Beam[] };
|
|
|
+ private vfbeams: { [voiceID: number]: VF.Beam[] };
|
|
|
/** Intermediate object to construct tuplets */
|
|
|
protected tuplets: { [voiceID: number]: [Tuplet, VexFlowVoiceEntry[]][] } = {};
|
|
|
/** VexFlow Tuplets */
|
|
|
- private vftuplets: { [voiceID: number]: Vex.Flow.Tuplet[] } = {};
|
|
|
+ private vftuplets: { [voiceID: number]: VF.Tuplet[] } = {};
|
|
|
// The engraving rules of OSMD.
|
|
|
public rules: EngravingRules;
|
|
|
|
|
@@ -105,7 +106,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
|
|
|
// TODO save beginning and end bar type, set these again after new stave.
|
|
|
|
|
|
- this.stave = new Vex.Flow.Stave(0, 0, 0, {
|
|
|
+ this.stave = new VF.Stave(0, 0, 0, {
|
|
|
fill_style: this.rules.StaffLineColor,
|
|
|
space_above_staff_ln: 0,
|
|
|
space_below_staff_ln: 0
|
|
@@ -118,10 +119,10 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
// constructor sets beginning and end bar type to standard
|
|
|
|
|
|
- this.stave.setBegBarType(Vex.Flow.Barline.type.NONE); // technically not correct, but we'd need to set the next measure's beginning bar type
|
|
|
+ this.stave.setBegBarType(VF.Barline.type.NONE); // technically not correct, but we'd need to set the next measure's beginning bar type
|
|
|
if (this.parentSourceMeasure && this.parentSourceMeasure.endingBarStyleEnum === SystemLinesEnum.None) {
|
|
|
// fix for vexflow ignoring ending barline style after new stave, apparently
|
|
|
- this.stave.setEndBarType(Vex.Flow.Barline.type.NONE);
|
|
|
+ this.stave.setEndBarType(VF.Barline.type.NONE);
|
|
|
}
|
|
|
// the correct bar types seem to be set later
|
|
|
|
|
@@ -174,7 +175,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
this.stave.addClef("tab", undefined, undefined, undefined);
|
|
|
} else {
|
|
|
const vfclef: { type: string, size: string, annotation: string } = VexFlowConverter.Clef(clef, "default");
|
|
|
- this.stave.addClef(vfclef.type, vfclef.size, vfclef.annotation, Vex.Flow.StaveModifier.Position.BEGIN);
|
|
|
+ this.stave.addClef(vfclef.type, vfclef.size, vfclef.annotation, VF.StaveModifier.Position.BEGIN);
|
|
|
}
|
|
|
this.updateInstructionWidth();
|
|
|
}
|
|
@@ -191,7 +192,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
return this.getYForLine(this.options.num_lines);
|
|
|
};
|
|
|
} else if (lineNumber === 1) {
|
|
|
- // Vex.Flow.Stave.setNumLines hides all but the top line.
|
|
|
+ // VF.Stave.setNumLines hides all but the top line.
|
|
|
// this is better
|
|
|
(this.stave.options as any).line_config = [
|
|
|
{ visible: false },
|
|
@@ -262,10 +263,10 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
* @param rhythm
|
|
|
*/
|
|
|
public addRhythmAtBegin(rhythm: RhythmInstruction): void {
|
|
|
- const timeSig: Vex.Flow.TimeSignature = VexFlowConverter.TimeSignature(rhythm);
|
|
|
+ const timeSig: VF.TimeSignature = VexFlowConverter.TimeSignature(rhythm);
|
|
|
this.stave.addModifier(
|
|
|
timeSig,
|
|
|
- Vex.Flow.StaveModifier.Position.BEGIN
|
|
|
+ VF.StaveModifier.Position.BEGIN
|
|
|
);
|
|
|
this.updateInstructionWidth();
|
|
|
}
|
|
@@ -284,8 +285,8 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
for (const modifier of this.stave.getModifiers()) {
|
|
|
if (!visible) {
|
|
|
// make clef invisible in vexflow. (only rendered to correct layout and staffentry boundingbox)
|
|
|
- if (modifier.getCategory() === "clefs" && modifier.getPosition() === Vex.Flow.StaveModifier.Position.END) {
|
|
|
- if ((modifier as any).type === vfclef.type) { // any = Vex.Flow.Clef
|
|
|
+ if (modifier.getCategory() === "clefs" && modifier.getPosition() === VF.StaveModifier.Position.END) {
|
|
|
+ if ((modifier as any).type === vfclef.type) { // any = VF.Clef
|
|
|
const transparentStyle: string = "#12345600";
|
|
|
const originalStyle: any = (modifier as any).getStyle();
|
|
|
if (originalStyle) {
|
|
@@ -323,27 +324,27 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
case SystemLinesEnum.BoldThinDots:
|
|
|
//customize the barline draw function if repeat is beginning of system
|
|
|
if (!renderInitialLine) {
|
|
|
- (this.stave as any).modifiers[0].draw = function(stave: Vex.Flow.Stave): void {
|
|
|
+ (this.stave as any).modifiers[0].draw = function(stave: VF.Stave): void {
|
|
|
(stave as any).checkContext();
|
|
|
this.setRendered();
|
|
|
switch (this.type) {
|
|
|
- case Vex.Flow.Barline.type.SINGLE:
|
|
|
+ case VF.Barline.type.SINGLE:
|
|
|
this.drawVerticalBar(stave, this.x, false);
|
|
|
break;
|
|
|
- case Vex.Flow.Barline.type.DOUBLE:
|
|
|
+ case VF.Barline.type.DOUBLE:
|
|
|
this.drawVerticalBar(stave, this.x, true);
|
|
|
break;
|
|
|
- case Vex.Flow.Barline.type.END:
|
|
|
+ case VF.Barline.type.END:
|
|
|
this.drawVerticalEndBar(stave, this.x);
|
|
|
break;
|
|
|
- case Vex.Flow.Barline.type.REPEAT_BEGIN:
|
|
|
+ case VF.Barline.type.REPEAT_BEGIN:
|
|
|
//removed the vertical line rendering that exists in VF codebase
|
|
|
this.drawRepeatBar(stave, this.x, true);
|
|
|
break;
|
|
|
- case Vex.Flow.Barline.type.REPEAT_END:
|
|
|
+ case VF.Barline.type.REPEAT_END:
|
|
|
this.drawRepeatBar(stave, this.x, false);
|
|
|
break;
|
|
|
- case Vex.Flow.Barline.type.REPEAT_BOTH:
|
|
|
+ case VF.Barline.type.REPEAT_BOTH:
|
|
|
this.drawRepeatBar(stave, this.x, false);
|
|
|
this.drawRepeatBar(stave, this.x, true);
|
|
|
break;
|
|
@@ -353,29 +354,29 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
- this.stave.setBegBarType(Vex.Flow.Barline.type.REPEAT_BEGIN);
|
|
|
+ this.stave.setBegBarType(VF.Barline.type.REPEAT_BEGIN);
|
|
|
break;
|
|
|
default:
|
|
|
- //this.stave.setBegBarType(Vex.Flow.Barline.type.NONE); // not necessary, it seems
|
|
|
+ //this.stave.setBegBarType(VF.Barline.type.NONE); // not necessary, it seems
|
|
|
break;
|
|
|
}
|
|
|
break;
|
|
|
case SystemLinePosition.MeasureEnd:
|
|
|
switch (lineType) {
|
|
|
case SystemLinesEnum.DotsBoldBoldDots:
|
|
|
- this.stave.setEndBarType(Vex.Flow.Barline.type.REPEAT_BOTH);
|
|
|
+ this.stave.setEndBarType(VF.Barline.type.REPEAT_BOTH);
|
|
|
break;
|
|
|
case SystemLinesEnum.DotsThinBold:
|
|
|
- this.stave.setEndBarType(Vex.Flow.Barline.type.REPEAT_END);
|
|
|
+ this.stave.setEndBarType(VF.Barline.type.REPEAT_END);
|
|
|
break;
|
|
|
case SystemLinesEnum.DoubleThin:
|
|
|
- this.stave.setEndBarType(Vex.Flow.Barline.type.DOUBLE);
|
|
|
+ this.stave.setEndBarType(VF.Barline.type.DOUBLE);
|
|
|
break;
|
|
|
case SystemLinesEnum.ThinBold:
|
|
|
- this.stave.setEndBarType(Vex.Flow.Barline.type.END);
|
|
|
+ this.stave.setEndBarType(VF.Barline.type.END);
|
|
|
break;
|
|
|
case SystemLinesEnum.None:
|
|
|
- this.stave.setEndBarType(Vex.Flow.Barline.type.NONE);
|
|
|
+ this.stave.setEndBarType(VF.Barline.type.NONE);
|
|
|
break;
|
|
|
// TODO: Add support for additional Barline types when VexFlow supports them
|
|
|
default:
|
|
@@ -394,7 +395,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
*/
|
|
|
public addMeasureNumber(): void {
|
|
|
const text: string = this.MeasureNumber.toString();
|
|
|
- const position: number = StavePositionEnum.ABOVE; //Vex.Flow.StaveModifier.Position.ABOVE;
|
|
|
+ const position: number = StavePositionEnum.ABOVE; //VF.StaveModifier.Position.ABOVE;
|
|
|
const options: any = {
|
|
|
justification: 1,
|
|
|
shift_x: 0,
|
|
@@ -405,49 +406,49 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
|
|
|
public addWordRepetition(repetitionInstruction: RepetitionInstruction): void {
|
|
|
- let instruction: Vex.Flow.Repetition.type = undefined;
|
|
|
- let position: any = Vex.Flow.StaveModifier.Position.END;
|
|
|
+ let instruction: VF.Repetition.type = undefined;
|
|
|
+ let position: any = VF.StaveModifier.Position.END;
|
|
|
const xShift: number = this.beginInstructionsWidth;
|
|
|
switch (repetitionInstruction.type) {
|
|
|
case RepetitionInstructionEnum.Segno:
|
|
|
// create Segno Symbol:
|
|
|
- instruction = Vex.Flow.Repetition.type.SEGNO_LEFT;
|
|
|
- position = Vex.Flow.StaveModifier.Position.LEFT;
|
|
|
+ instruction = VF.Repetition.type.SEGNO_LEFT;
|
|
|
+ position = VF.StaveModifier.Position.LEFT;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.Coda:
|
|
|
// create Coda Symbol:
|
|
|
- instruction = Vex.Flow.Repetition.type.CODA_LEFT;
|
|
|
- position = Vex.Flow.StaveModifier.Position.LEFT;
|
|
|
+ instruction = VF.Repetition.type.CODA_LEFT;
|
|
|
+ position = VF.StaveModifier.Position.LEFT;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.DaCapo:
|
|
|
- instruction = Vex.Flow.Repetition.type.DC;
|
|
|
+ instruction = VF.Repetition.type.DC;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.DalSegno:
|
|
|
- instruction = Vex.Flow.Repetition.type.DS;
|
|
|
+ instruction = VF.Repetition.type.DS;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.Fine:
|
|
|
- instruction = Vex.Flow.Repetition.type.FINE;
|
|
|
+ instruction = VF.Repetition.type.FINE;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.ToCoda:
|
|
|
- instruction = (Vex.Flow.Repetition as any).type.TO_CODA;
|
|
|
+ instruction = (VF.Repetition as any).type.TO_CODA;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.DaCapoAlFine:
|
|
|
- instruction = Vex.Flow.Repetition.type.DC_AL_FINE;
|
|
|
+ instruction = VF.Repetition.type.DC_AL_FINE;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.DaCapoAlCoda:
|
|
|
- instruction = Vex.Flow.Repetition.type.DC_AL_CODA;
|
|
|
+ instruction = VF.Repetition.type.DC_AL_CODA;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.DalSegnoAlFine:
|
|
|
- instruction = Vex.Flow.Repetition.type.DS_AL_FINE;
|
|
|
+ instruction = VF.Repetition.type.DS_AL_FINE;
|
|
|
break;
|
|
|
case RepetitionInstructionEnum.DalSegnoAlCoda:
|
|
|
- instruction = Vex.Flow.Repetition.type.DS_AL_CODA;
|
|
|
+ instruction = VF.Repetition.type.DS_AL_CODA;
|
|
|
break;
|
|
|
default:
|
|
|
break;
|
|
|
}
|
|
|
if (instruction) {
|
|
|
- const repetition: Vex.Flow.Repetition = new Vex.Flow.Repetition(instruction, xShift, -this.rules.RepetitionSymbolsYOffset);
|
|
|
+ const repetition: VF.Repetition = new VF.Repetition(instruction, xShift, -this.rules.RepetitionSymbolsYOffset);
|
|
|
this.stave.addModifier(repetition, position);
|
|
|
return;
|
|
|
}
|
|
@@ -456,23 +457,23 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
|
|
|
protected addVolta(repetitionInstruction: RepetitionInstruction): void {
|
|
|
- let voltaType: number = Vex.Flow.Volta.type.BEGIN;
|
|
|
+ let voltaType: number = VF.Volta.type.BEGIN;
|
|
|
if (repetitionInstruction.type === RepetitionInstructionEnum.Ending) {
|
|
|
switch (repetitionInstruction.alignment) {
|
|
|
case AlignmentType.Begin:
|
|
|
if (this.parentSourceMeasure.endsRepetitionEnding()) {
|
|
|
- voltaType = Vex.Flow.Volta.type.BEGIN_END;
|
|
|
+ voltaType = VF.Volta.type.BEGIN_END;
|
|
|
} else {
|
|
|
- voltaType = Vex.Flow.Volta.type.BEGIN;
|
|
|
+ voltaType = VF.Volta.type.BEGIN;
|
|
|
}
|
|
|
break;
|
|
|
case AlignmentType.End:
|
|
|
if (this.parentSourceMeasure.beginsRepetitionEnding()) {
|
|
|
- //voltaType = Vex.Flow.Volta.type.BEGIN_END;
|
|
|
+ //voltaType = VF.Volta.type.BEGIN_END;
|
|
|
// don't add BEGIN_END volta a second time:
|
|
|
return;
|
|
|
} else {
|
|
|
- voltaType = Vex.Flow.Volta.type.END;
|
|
|
+ voltaType = VF.Volta.type.END;
|
|
|
}
|
|
|
break;
|
|
|
default:
|
|
@@ -520,9 +521,9 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
|
|
|
if (prevMeasure) {
|
|
|
- const prevStaveModifiers: Vex.Flow.StaveModifier[] = prevMeasure.stave.getModifiers();
|
|
|
+ const prevStaveModifiers: VF.StaveModifier[] = prevMeasure.stave.getModifiers();
|
|
|
for (let i: number = 0; i < prevStaveModifiers.length; i++) {
|
|
|
- const nextStaveModifier: Vex.Flow.StaveModifier = prevStaveModifiers[i];
|
|
|
+ const nextStaveModifier: VF.StaveModifier = prevStaveModifiers[i];
|
|
|
if (nextStaveModifier.hasOwnProperty("volta")) {
|
|
|
const prevskyBottomLineCalculator: SkyBottomLineCalculator = prevMeasure.ParentStaffLine.SkyBottomLineCalculator;
|
|
|
const prevStart: number = prevMeasure.PositionAndShape.AbsolutePosition.x + prevMeasure.PositionAndShape.BorderMarginLeft + 0.4;
|
|
@@ -556,7 +557,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
*/
|
|
|
public setWidth(width: number): void {
|
|
|
super.setWidth(width);
|
|
|
- // Set the width of the Vex.Flow.Stave
|
|
|
+ // Set the width of the VF.Stave
|
|
|
this.stave.setWidth(width * unitInPixels);
|
|
|
// Force the width of the Begin Instructions
|
|
|
//this.stave.setNoteStartX(this.beginInstructionsWidth * UnitInPixels);
|
|
@@ -672,7 +673,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
if (!gNote?.vfnote) { // can happen were invisible, then multi rest measure. TODO fix multi rest measure not removed
|
|
|
return;
|
|
|
}
|
|
|
- const vfnote: Vex.Flow.StemmableNote = gNote.vfnote[0];
|
|
|
+ const vfnote: VF.StemmableNote = gNote.vfnote[0];
|
|
|
// if (note.isRest()) // TODO somehow there are never rest notes in ve.Notes
|
|
|
// TODO also, grace notes are not included here, need to be fixed as well. (and a few triple beamed notes in Bach Air)
|
|
|
let relPosY: number = 0;
|
|
@@ -793,7 +794,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
|
|
|
private createGhostGves(duration: Fraction): VexFlowVoiceEntry[] {
|
|
|
- const vfghosts: Vex.Flow.GhostNote[] = VexFlowConverter.GhostNotes(duration);
|
|
|
+ const vfghosts: VF.GhostNote[] = VexFlowConverter.GhostNotes(duration);
|
|
|
const ghostGves: VexFlowVoiceEntry[] = [];
|
|
|
for (const vfghost of vfghosts) {
|
|
|
const ghostGve: VexFlowVoiceEntry = new VexFlowVoiceEntry(undefined, undefined);
|
|
@@ -864,7 +865,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
const beamedNotes: StaveNote[] = []; // already beamed notes, will be ignored by this.autoBeamNotes()
|
|
|
for (const voiceID in this.beams) {
|
|
|
if (this.beams.hasOwnProperty(voiceID)) {
|
|
|
- let vfbeams: Vex.Flow.Beam[] = this.vfbeams[voiceID];
|
|
|
+ let vfbeams: VF.Beam[] = this.vfbeams[voiceID];
|
|
|
if (!vfbeams) {
|
|
|
vfbeams = this.vfbeams[voiceID] = [];
|
|
|
}
|
|
@@ -883,7 +884,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
continue;
|
|
|
}
|
|
|
|
|
|
- const notes: Vex.Flow.StaveNote[] = [];
|
|
|
+ const notes: VF.StaveNote[] = [];
|
|
|
const psBeam: Beam = beam[0];
|
|
|
const voiceEntries: VexFlowVoiceEntry[] = beam[1];
|
|
|
|
|
@@ -903,7 +904,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
let beamColor: string;
|
|
|
const stemColors: string[] = [];
|
|
|
for (const entry of voiceEntries) {
|
|
|
- const note: Vex.Flow.StaveNote = ((<VexFlowVoiceEntry>entry).vfStaveNote as StaveNote);
|
|
|
+ const note: VF.StaveNote = ((<VexFlowVoiceEntry>entry).vfStaveNote as StaveNote);
|
|
|
if (note) {
|
|
|
notes.push(note);
|
|
|
beamedNotes.push(note);
|
|
@@ -916,7 +917,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
}
|
|
|
if (notes.length > 1) {
|
|
|
- const vfBeam: Vex.Flow.Beam = new Vex.Flow.Beam(notes, autoStemBeam);
|
|
|
+ const vfBeam: VF.Beam = new VF.Beam(notes, autoStemBeam);
|
|
|
if (isGraceBeam) {
|
|
|
// smaller beam, as in Vexflow.GraceNoteGroup.beamNotes()
|
|
|
(<any>vfBeam).render_options.beam_width = 3;
|
|
@@ -954,13 +955,16 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
* @param beamedNotes notes that will not be autobeamed (usually because they are already beamed)
|
|
|
*/
|
|
|
private autoBeamNotes(beamedNotes: StemmableNote[]): void {
|
|
|
+ if (!this.rules.AutoBeamTabs && this.isTabMeasure) { // could also use an option tabBeams to disable beams there completely
|
|
|
+ return;
|
|
|
+ }
|
|
|
let notesToAutoBeam: StemmableNote[] = [];
|
|
|
let consecutiveBeamableNotes: StemmableNote[] = [];
|
|
|
let currentTuplet: Tuplet;
|
|
|
let tupletNotesToAutoBeam: StaveNote[] = [];
|
|
|
this.autoTupletVfBeams = [];
|
|
|
const separateAutoBeams: StemmableNote[][] = []; // a set of separate beams, each having a set of notes (StemmableNote[]).
|
|
|
- this.autoVfBeams = []; // final Vex.Flow.Beams will be pushed/collected into this
|
|
|
+ this.autoVfBeams = []; // final VF.Beams will be pushed/collected into this
|
|
|
let timeSignature: Fraction = this.parentSourceMeasure.ActiveTimeSignature;
|
|
|
if (!timeSignature) { // this doesn't happen in OSMD, but maybe in a SourceGenerator
|
|
|
timeSignature = this.parentSourceMeasure.Duration; // suboptimal, can be 1/1 in a 4/4 time signature
|
|
@@ -1034,7 +1038,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
} else {
|
|
|
if (currentTuplet !== noteTuplet) { // new tuplet, finish old one
|
|
|
if (tupletNotesToAutoBeam.length > 1) {
|
|
|
- const vfBeam: Vex.Flow.Beam = new Vex.Flow.Beam(tupletNotesToAutoBeam, true);
|
|
|
+ const vfBeam: VF.Beam = new VF.Beam(tupletNotesToAutoBeam, true);
|
|
|
if (this.rules.FlatBeams) {
|
|
|
(<any>vfBeam).render_options.flat_beams = true;
|
|
|
(<any>vfBeam).render_options.flat_beam_offset = this.rules.FlatBeamOffset;
|
|
@@ -1058,7 +1062,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
}
|
|
|
if (tupletNotesToAutoBeam.length >= 2) {
|
|
|
- const vfBeam: Vex.Flow.Beam = new Vex.Flow.Beam(tupletNotesToAutoBeam, true);
|
|
|
+ const vfBeam: VF.Beam = new VF.Beam(tupletNotesToAutoBeam, true);
|
|
|
if (this.rules.FlatBeams) {
|
|
|
(<any>vfBeam).render_options.flat_beams = true;
|
|
|
(<any>vfBeam).render_options.flat_beam_offset = this.rules.FlatBeamOffset;
|
|
@@ -1081,15 +1085,15 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
maintain_stem_directions: autoBeamOptions.maintain_stem_directions,
|
|
|
};
|
|
|
if (autoBeamOptions.groups && autoBeamOptions.groups.length) {
|
|
|
- const groups: Vex.Flow.Fraction[] = [];
|
|
|
+ const groups: VF.Fraction[] = [];
|
|
|
for (const fraction of autoBeamOptions.groups) {
|
|
|
- groups.push(new Vex.Flow.Fraction(fraction[0], fraction[1]));
|
|
|
+ groups.push(new VF.Fraction(fraction[0], fraction[1]));
|
|
|
}
|
|
|
generateBeamOptions.groups = groups;
|
|
|
}
|
|
|
|
|
|
for (const notesForSeparateAutoBeam of separateAutoBeams) {
|
|
|
- const newBeams: Vex.Flow.Beam[] = Vex.Flow.Beam.generateBeams(notesForSeparateAutoBeam, generateBeamOptions);
|
|
|
+ const newBeams: VF.Beam[] = VF.Beam.generateBeams(notesForSeparateAutoBeam, generateBeamOptions);
|
|
|
for (const vfBeam of newBeams) {
|
|
|
if (this.rules.FlatBeams) {
|
|
|
(<any>vfBeam).render_options.flat_beams = true;
|
|
@@ -1111,12 +1115,12 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
this.vftuplets = {};
|
|
|
for (const voiceID in this.tuplets) {
|
|
|
if (this.tuplets.hasOwnProperty(voiceID)) {
|
|
|
- let vftuplets: Vex.Flow.Tuplet[] = this.vftuplets[voiceID];
|
|
|
+ let vftuplets: VF.Tuplet[] = this.vftuplets[voiceID];
|
|
|
if (!vftuplets) {
|
|
|
vftuplets = this.vftuplets[voiceID] = [];
|
|
|
}
|
|
|
for (const tupletBuilder of this.tuplets[voiceID]) {
|
|
|
- const tupletStaveNotes: Vex.Flow.StaveNote[] = [];
|
|
|
+ const tupletStaveNotes: VF.StaveNote[] = [];
|
|
|
const tupletVoiceEntries: VexFlowVoiceEntry[] = tupletBuilder[1];
|
|
|
for (const tupletVoiceEntry of tupletVoiceEntries) {
|
|
|
tupletStaveNotes.push(((tupletVoiceEntry).vfStaveNote as StaveNote));
|
|
@@ -1127,11 +1131,11 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
const bracketed: boolean = tuplet.Bracket ||
|
|
|
(tuplet.TupletLabelNumber === 3 && this.rules.TripletsBracketed) ||
|
|
|
(tuplet.TupletLabelNumber !== 3 && this.rules.TupletsBracketed);
|
|
|
- let location: number = Vex.Flow.Tuplet.LOCATION_TOP;
|
|
|
+ let location: number = VF.Tuplet.LOCATION_TOP;
|
|
|
if (tuplet.tupletLabelNumberPlacement === PlacementEnum.Below) {
|
|
|
- location = Vex.Flow.Tuplet.LOCATION_BOTTOM;
|
|
|
+ location = VF.Tuplet.LOCATION_BOTTOM;
|
|
|
}
|
|
|
- vftuplets.push(new Vex.Flow.Tuplet( tupletStaveNotes,
|
|
|
+ vftuplets.push(new VF.Tuplet( tupletStaveNotes,
|
|
|
{
|
|
|
bracketed: bracketed,
|
|
|
location: location,
|
|
@@ -1181,7 +1185,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
//}
|
|
|
if (graceGVoiceEntriesBefore.length > 0) {
|
|
|
// add grace notes that came before this main note to a GraceNoteGroup in Vexflow, attached to the main note
|
|
|
- const graceNotes: Vex.Flow.GraceNote[] = [];
|
|
|
+ const graceNotes: VF.GraceNote[] = [];
|
|
|
for (let i: number = 0; i < graceGVoiceEntriesBefore.length; i++) {
|
|
|
const gveGrace: VexFlowVoiceEntry = <VexFlowVoiceEntry>graceGVoiceEntriesBefore[i];
|
|
|
//if (gveGrace.notes[0].sourceNote.PrintObject) {
|
|
@@ -1195,7 +1199,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
gveGrace.vfStaveNote = vfStaveNote;
|
|
|
graceNotes.push(vfStaveNote);
|
|
|
}
|
|
|
- const graceNoteGroup: Vex.Flow.GraceNoteGroup = new Vex.Flow.GraceNoteGroup(graceNotes, graceSlur);
|
|
|
+ const graceNoteGroup: VF.GraceNoteGroup = new VF.GraceNoteGroup(graceNotes, graceSlur);
|
|
|
((gve as VexFlowVoiceEntry).vfStaveNote as StaveNote).addModifier(0, graceNoteGroup);
|
|
|
graceGVoiceEntriesBefore = [];
|
|
|
}
|
|
@@ -1232,11 +1236,11 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
//const isMainVoice: boolean = !(voice instanceof LinkedVoice);
|
|
|
|
|
|
// add a vexFlow voice for this voice:
|
|
|
- this.vfVoices[voice.VoiceId] = new Vex.Flow.Voice({
|
|
|
+ this.vfVoices[voice.VoiceId] = new VF.Voice({
|
|
|
beat_value: this.parentSourceMeasure.Duration.Denominator,
|
|
|
num_beats: this.parentSourceMeasure.Duration.Numerator,
|
|
|
- resolution: Vex.Flow.RESOLUTION,
|
|
|
- }).setMode(Vex.Flow.Voice.Mode.SOFT);
|
|
|
+ resolution: VF.RESOLUTION,
|
|
|
+ }).setMode(VF.Voice.Mode.SOFT);
|
|
|
|
|
|
const restFilledEntries: GraphicalVoiceEntry[] = this.getRestFilledVexFlowStaveNotesPerVoice(voice);
|
|
|
// .sort((a,b) => a.)
|
|
@@ -1270,7 +1274,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
// The cast is necesary because...vexflow -> see types
|
|
|
if (vexFlowVoiceEntry.vfStaveNote.getCategory && vexFlowVoiceEntry.vfStaveNote.getCategory() === "stavenotes") {
|
|
|
// GhostNotes and other StemmableNotes don't have this function
|
|
|
- (vexFlowVoiceEntry.vfStaveNote as Vex.Flow.StaveNote).addModifier(0, clefModifier);
|
|
|
+ (vexFlowVoiceEntry.vfStaveNote as VF.StaveNote).addModifier(0, clefModifier);
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1305,8 +1309,8 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
// TODO right now our arpeggio object has all arpeggio notes from arpeggios across all voices.
|
|
|
// see VoiceGenerator. Doesn't matter for Vexflow for now though
|
|
|
if (voiceEntry.notes && voiceEntry.notes.length > 1) {
|
|
|
- const type: Vex.Flow.Stroke.Type = VexFlowConverter.StrokeTypeFromArpeggioType(arpeggio.type);
|
|
|
- const stroke: Vex.Flow.Stroke = new Vex.Flow.Stroke(type, {
|
|
|
+ const type: VF.Stroke.Type = VexFlowConverter.StrokeTypeFromArpeggioType(arpeggio.type);
|
|
|
+ const stroke: VF.Stroke = new VF.Stroke(type, {
|
|
|
all_voices: this.rules.ArpeggiosGoAcrossVoices
|
|
|
// default: false. This causes arpeggios to always go across all voices, which is often unwanted.
|
|
|
// also, this can cause infinite height of stroke, see #546
|
|
@@ -1338,10 +1342,10 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
|
|
|
const vfStemDir: number = vfnote[0].getStemDirection();
|
|
|
switch (vfStemDir) {
|
|
|
- case (Vex.Flow.Stem.UP):
|
|
|
+ case (VF.Stem.UP):
|
|
|
gVoiceEntry.parentVoiceEntry.StemDirection = StemDirectionType.Up;
|
|
|
break;
|
|
|
- case (Vex.Flow.Stem.DOWN):
|
|
|
+ case (VF.Stem.DOWN):
|
|
|
gVoiceEntry.parentVoiceEntry.StemDirection = StemDirectionType.Down;
|
|
|
break;
|
|
|
default:
|
|
@@ -1419,37 +1423,37 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
fingeringPosition = fingering.placement;
|
|
|
}
|
|
|
let offsetX: number = this.rules.FingeringOffsetX;
|
|
|
- let modifierPosition: number; // Vex.Flow.Stavemodifier.Position
|
|
|
+ let modifierPosition: number; // VF.Stavemodifier.Position
|
|
|
switch (fingeringPosition) {
|
|
|
default:
|
|
|
case PlacementEnum.Left:
|
|
|
- modifierPosition = Vex.Flow.StaveModifier.Position.LEFT;
|
|
|
+ modifierPosition = VF.StaveModifier.Position.LEFT;
|
|
|
offsetX -= note.baseFingeringXOffset * unitInPixels;
|
|
|
break;
|
|
|
case PlacementEnum.Right:
|
|
|
- modifierPosition = Vex.Flow.StaveModifier.Position.RIGHT;
|
|
|
+ modifierPosition = VF.StaveModifier.Position.RIGHT;
|
|
|
offsetX += note.baseFingeringXOffset * unitInPixels;
|
|
|
break;
|
|
|
case PlacementEnum.Above:
|
|
|
- modifierPosition = Vex.Flow.StaveModifier.Position.ABOVE;
|
|
|
+ modifierPosition = VF.StaveModifier.Position.ABOVE;
|
|
|
break;
|
|
|
case PlacementEnum.Below:
|
|
|
- modifierPosition = Vex.Flow.StaveModifier.Position.BELOW;
|
|
|
+ modifierPosition = VF.StaveModifier.Position.BELOW;
|
|
|
break;
|
|
|
case PlacementEnum.NotYetDefined: // automatic fingering placement, could be more complex/customizable
|
|
|
const sourceStaff: Staff = voiceEntry.parentStaffEntry.sourceStaffEntry.ParentStaff;
|
|
|
if (voiceEntry.notes.length > 1 || voiceEntry.parentStaffEntry.graphicalVoiceEntries.length > 1) {
|
|
|
- modifierPosition = Vex.Flow.StaveModifier.Position.LEFT;
|
|
|
+ modifierPosition = VF.StaveModifier.Position.LEFT;
|
|
|
} else if (sourceStaff.idInMusicSheet === 0) {
|
|
|
- modifierPosition = Vex.Flow.StaveModifier.Position.ABOVE;
|
|
|
+ modifierPosition = VF.StaveModifier.Position.ABOVE;
|
|
|
fingeringPosition = PlacementEnum.Above;
|
|
|
} else {
|
|
|
- modifierPosition = Vex.Flow.StaveModifier.Position.BELOW;
|
|
|
+ modifierPosition = VF.StaveModifier.Position.BELOW;
|
|
|
fingeringPosition = PlacementEnum.Below;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const fretFinger: Vex.Flow.FretHandFinger = new Vex.Flow.FretHandFinger(fingering.value);
|
|
|
+ const fretFinger: VF.FretHandFinger = new VF.FretHandFinger(fingering.value);
|
|
|
fretFinger.setPosition(modifierPosition);
|
|
|
fretFinger.setOffsetX(offsetX);
|
|
|
if (fingeringPosition === PlacementEnum.Above || fingeringPosition === PlacementEnum.Below) {
|
|
@@ -1463,7 +1467,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
const shiftCount: number = numberOfFingerings * 2.5;
|
|
|
fretFinger.setOffsetY(offsetYSign * (ordering + shiftCount) * perFingeringShift);
|
|
|
} else if (!this.rules.FingeringInsideStafflines) { // use StringNumber for placement above/below stafflines
|
|
|
- const stringNumber: Vex.Flow.StringNumber = new Vex.Flow.StringNumber(fingering.value);
|
|
|
+ const stringNumber: VF.StringNumber = new VF.StringNumber(fingering.value);
|
|
|
(<any>stringNumber).radius = 0; // hack to remove the circle around the number
|
|
|
stringNumber.setPosition(modifierPosition);
|
|
|
stringNumber.setOffsetY(offsetYSign * ordering * stringNumber.getWidth() * 2 / 3);
|
|
@@ -1513,7 +1517,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
// log.warn("stringNumber > 6 not supported"); // TODO do we need to support more?
|
|
|
// leave stringNumber as is, warning not really necessary
|
|
|
}
|
|
|
- const vfStringNumber: Vex.Flow.StringNumber = new Vex.Flow.StringNumber(stringNumber);
|
|
|
+ const vfStringNumber: VF.StringNumber = new VF.StringNumber(stringNumber);
|
|
|
// Remove circle from string number. Not needed for
|
|
|
// disambiguation from fingerings since we use Roman
|
|
|
// Numerals for RenderStringNumbersClassical
|
|
@@ -1525,9 +1529,9 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
// }
|
|
|
if (voiceEntry.notes.length > 1 || voiceEntry.parentStaffEntry.graphicalVoiceEntries.length > 1) {
|
|
|
vfStringNumber.setOffsetX(note.baseStringNumberXOffset * 13);
|
|
|
- vfStringNumber.setPosition(Vex.Flow.Modifier.Position.RIGHT);
|
|
|
+ vfStringNumber.setPosition(VF.Modifier.Position.RIGHT);
|
|
|
} else {
|
|
|
- vfStringNumber.setPosition(Vex.Flow.Modifier.Position.ABOVE);
|
|
|
+ vfStringNumber.setPosition(VF.Modifier.Position.ABOVE);
|
|
|
}
|
|
|
vfStringNumber.setOffsetY(offsetY);
|
|
|
|
|
@@ -1542,16 +1546,16 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
* @param lineType
|
|
|
*/
|
|
|
public lineTo(top: VexFlowMeasure, lineType: any): void {
|
|
|
- const connector: StaveConnector = new Vex.Flow.StaveConnector(top.getVFStave(), this.stave);
|
|
|
+ const connector: StaveConnector = new VF.StaveConnector(top.getVFStave(), this.stave);
|
|
|
connector.setType(lineType);
|
|
|
this.connectors.push(connector);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Return the VexFlow Stave corresponding to this graphicalMeasure
|
|
|
- * @returns {Vex.Flow.Stave}
|
|
|
+ * @returns {VF.Stave}
|
|
|
*/
|
|
|
- public getVFStave(): Vex.Flow.Stave {
|
|
|
+ public getVFStave(): VF.Stave {
|
|
|
return this.stave;
|
|
|
}
|
|
|
|
|
@@ -1562,11 +1566,11 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
protected updateInstructionWidth(): void {
|
|
|
let vfBeginInstructionsWidth: number = 0;
|
|
|
let vfEndInstructionsWidth: number = 0;
|
|
|
- const modifiers: Vex.Flow.StaveModifier[] = this.stave.getModifiers();
|
|
|
+ const modifiers: VF.StaveModifier[] = this.stave.getModifiers();
|
|
|
for (const mod of modifiers) {
|
|
|
- if (mod.getPosition() === StavePositionEnum.BEGIN) { //Vex.Flow.StaveModifier.Position.BEGIN) {
|
|
|
+ if (mod.getPosition() === StavePositionEnum.BEGIN) { //VF.StaveModifier.Position.BEGIN) {
|
|
|
vfBeginInstructionsWidth += mod.getWidth() + mod.getPadding(undefined);
|
|
|
- } else if (mod.getPosition() === StavePositionEnum.END) { //Vex.Flow.StaveModifier.Position.END) {
|
|
|
+ } else if (mod.getPosition() === StavePositionEnum.END) { //VF.StaveModifier.Position.END) {
|
|
|
vfEndInstructionsWidth += mod.getWidth() + mod.getPadding(undefined);
|
|
|
}
|
|
|
}
|
|
@@ -1575,7 +1579,7 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
this.endInstructionsWidth = (vfEndInstructionsWidth ?? 0) / unitInPixels;
|
|
|
}
|
|
|
|
|
|
- public addStaveTie(stavetie: Vex.Flow.StaveTie, graphicalTie: GraphicalTie): void {
|
|
|
+ public addStaveTie(stavetie: VF.StaveTie, graphicalTie: GraphicalTie): void {
|
|
|
this.vfTies.push(stavetie);
|
|
|
graphicalTie.vfTie = stavetie;
|
|
|
}
|