|
@@ -29,7 +29,7 @@ import {Voice} from "../../VoiceData/Voice";
|
|
|
import {LinkedVoice} from "../../VoiceData/LinkedVoice";
|
|
|
import {EngravingRules} from "../EngravingRules";
|
|
|
import {OrnamentContainer} from "../../VoiceData/OrnamentContainer";
|
|
|
-import {TechnicalInstruction, TechnicalInstructionType} from "../../VoiceData/Instructions/TechnicalInstruction";
|
|
|
+import {TechnicalInstruction} from "../../VoiceData/Instructions/TechnicalInstruction";
|
|
|
import {PlacementEnum} from "../../VoiceData/Expressions/AbstractExpression";
|
|
|
import {VexFlowGraphicalNote} from "./VexFlowGraphicalNote";
|
|
|
import {AutoBeamOptions} from "../../../OpenSheetMusicDisplay/OSMDOptions";
|
|
@@ -1230,22 +1230,25 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
|
|
|
protected createFingerings(voiceEntry: GraphicalVoiceEntry): void {
|
|
|
const vexFlowVoiceEntry: VexFlowVoiceEntry = voiceEntry as VexFlowVoiceEntry;
|
|
|
- const technicalInstructions: TechnicalInstruction[] = voiceEntry.parentVoiceEntry.TechnicalInstructions;
|
|
|
- let fingeringsCount: number = 0;
|
|
|
- for (const instruction of technicalInstructions) {
|
|
|
- if (instruction.type === TechnicalInstructionType.Fingering) {
|
|
|
- fingeringsCount++;
|
|
|
+ let numberOfFingerings: number = 0;
|
|
|
+ // count total number of fingerings
|
|
|
+ for (const note of voiceEntry.notes) {
|
|
|
+ const fingering: TechnicalInstruction = note.sourceNote.Fingering;
|
|
|
+ if (fingering) {
|
|
|
+ numberOfFingerings++;
|
|
|
}
|
|
|
}
|
|
|
let fingeringIndex: number = -1;
|
|
|
- for (const fingeringInstruction of technicalInstructions) {
|
|
|
- if (fingeringInstruction.type !== TechnicalInstructionType.Fingering) {
|
|
|
+ for (const note of voiceEntry.notes) {
|
|
|
+ const fingering: TechnicalInstruction = note.sourceNote.Fingering;
|
|
|
+ if (!fingering) {
|
|
|
+ fingeringIndex++;
|
|
|
continue;
|
|
|
}
|
|
|
fingeringIndex++; // 0 for first fingering
|
|
|
let fingeringPosition: PlacementEnum = this.rules.FingeringPosition;
|
|
|
- if (fingeringInstruction.placement !== PlacementEnum.NotYetDefined) {
|
|
|
- fingeringPosition = fingeringInstruction.placement;
|
|
|
+ if (fingering.placement !== PlacementEnum.NotYetDefined) {
|
|
|
+ fingeringPosition = fingering.placement;
|
|
|
}
|
|
|
let modifierPosition: any; // Vex.Flow.Stavemodifier.Position
|
|
|
switch (fingeringPosition) {
|
|
@@ -1275,21 +1278,21 @@ export class VexFlowMeasure extends GraphicalMeasure {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- const fretFinger: Vex.Flow.FretHandFinger = new Vex.Flow.FretHandFinger(fingeringInstruction.value);
|
|
|
+ const fretFinger: Vex.Flow.FretHandFinger = new Vex.Flow.FretHandFinger(fingering.value);
|
|
|
fretFinger.setPosition(modifierPosition);
|
|
|
fretFinger.setOffsetX(this.rules.FingeringOffsetX);
|
|
|
if (fingeringPosition === PlacementEnum.Above || fingeringPosition === PlacementEnum.Below) {
|
|
|
const offsetYSign: number = fingeringPosition === PlacementEnum.Above ? -1 : 1; // minus y is up
|
|
|
const ordering: number = fingeringPosition === PlacementEnum.Above ? fingeringIndex :
|
|
|
- fingeringsCount - 1 - fingeringIndex; // reverse order for fingerings below staff
|
|
|
- if (this.rules.FingeringInsideStafflines && fingeringsCount > 1) { // y-shift for single fingering is ok
|
|
|
+ numberOfFingerings - 1 - fingeringIndex; // reverse order for fingerings below staff
|
|
|
+ if (this.rules.FingeringInsideStafflines && numberOfFingerings > 1) { // y-shift for single fingering is ok
|
|
|
// experimental, bounding boxes wrong for fretFinger above/below, better would be creating Labels
|
|
|
// set y-shift. vexflow fretfinger simply places directly above/below note
|
|
|
const perFingeringShift: number = fretFinger.getWidth() / 2;
|
|
|
- const shiftCount: number = fingeringsCount * 2.5;
|
|
|
+ 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(fingeringInstruction.value);
|
|
|
+ const stringNumber: Vex.Flow.StringNumber = new Vex.Flow.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);
|