|
@@ -52,6 +52,7 @@ import { VexFlowStaffLine } from "./VexFlowStaffLine";
|
|
|
export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
/** space needed for a dash for lyrics spacing, calculated once */
|
|
|
private dashSpace: number;
|
|
|
+ public beamsNeedUpdate: boolean = false;
|
|
|
|
|
|
constructor() {
|
|
|
super();
|
|
@@ -69,6 +70,7 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
}
|
|
|
|
|
|
protected formatMeasures(): void {
|
|
|
+ // let totalFinalizeBeamsTime: number = 0;
|
|
|
for (const verticalMeasureList of this.graphicalMusicSheet.MeasureList) {
|
|
|
const firstMeasure: VexFlowMeasure = verticalMeasureList[0] as VexFlowMeasure;
|
|
|
// first measure has formatting method as lambda function object, but formats all measures. TODO this could be refactored
|
|
@@ -77,11 +79,15 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
|
|
|
for (const staffEntry of measure.staffEntries) {
|
|
|
(<VexFlowStaffEntry>staffEntry).calculateXPosition();
|
|
|
}
|
|
|
- // how much performance does this cost? finalizeBeams generates new Vexflow beams etc.
|
|
|
- // TODO only do when zoom has changed
|
|
|
- (measure as VexFlowMeasure).finalizeBeams(); // without this, when zooming a lot (e.g. 250%), beams keep their old, now wrong slope.
|
|
|
+ // const t0: number = performance.now();
|
|
|
+ if (this.beamsNeedUpdate) { // finalizeBeams takes a few milliseconds, so we can save some performance here
|
|
|
+ (measure as VexFlowMeasure).finalizeBeams(); // without this, when zooming a lot (e.g. 250%), beams keep their old, now wrong slope.
|
|
|
+ // totalFinalizeBeamsTime += performance.now() - t0;
|
|
|
+ // console.log("Total calls to finalizeBeams in VexFlowMusicSheetCalculator took " + totalFinalizeBeamsTime + " milliseconds.");
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ this.beamsNeedUpdate = false;
|
|
|
}
|
|
|
|
|
|
//protected clearSystemsAndMeasures(): void {
|