Ver Fonte

Implemented showing dots.
Also split ties work now.

Matthias há 8 anos atrás
pai
commit
18911dea3c

+ 2 - 0
external/vexflow/vexflow.d.ts

@@ -59,6 +59,8 @@ declare namespace Vex {
             public addAccidental(index: number, accidental: Accidental): StaveNote;
 
             public setStyle(style: any): void;
+
+            public addDotToAll(): void;
         }
 
         export class StaveTie {

+ 10 - 0
src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

@@ -114,6 +114,7 @@ export class VexFlowConverter {
         let frac: Fraction = notes[0].graphicalNoteLength;
         let duration: string = VexFlowConverter.duration(frac);
         let vfclef: string;
+        let numDots: number = 0;
         for (let note of notes) {
             let res: [string, string, ClefInstruction] = (note as VexFlowGraphicalNote).vfpitch;
             if (res === undefined) {
@@ -126,6 +127,12 @@ export class VexFlowConverter {
             if (!vfclef) {
                 vfclef = VexFlowConverter.Clef(res[2]);
             }
+            if (numDots < note.numberOfDots) {
+                numDots = note.numberOfDots;
+            }
+        }
+        for (let i: number = 0, len: number = numDots; i < len; ++i) {
+            duration += "d";
         }
         let vfnote: Vex.Flow.StaveNote = new Vex.Flow.StaveNote({
             auto_stem: true,
@@ -143,6 +150,9 @@ export class VexFlowConverter {
                 vfnote.addAccidental(i, new Vex.Flow.Accidental(accidentals[i]));
             }
         }
+        for (let i: number = 0, len: number = numDots; i < len; ++i) {
+            vfnote.addDotToAll();
+        }
         return vfnote;
     }
 

+ 22 - 11
src/MusicalScore/Graphical/VexFlow/VexFlowMusicSheetCalculator.ts

@@ -177,8 +177,6 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
         let vfStartNote: Vex.Flow.StaveNote = undefined;
         if (startNote !== undefined) {
             vfStartNote = startNote.vfnote[0];
-            let measure: VexFlowMeasure = (startNote.parentStaffEntry.parentMeasure as VexFlowMeasure);
-            measure.vfTies.push();
         }
 
         let endNote: VexFlowGraphicalNote = (tie.EndNote as VexFlowGraphicalNote);
@@ -186,16 +184,29 @@ export class VexFlowMusicSheetCalculator extends MusicSheetCalculator {
         if (endNote !== undefined) {
             vfEndNote = endNote.vfnote[0];
         }
-        let vfTie: Vex.Flow.StaveTie = new Vex.Flow.StaveTie({
-            first_note: vfStartNote,
-            last_note : vfEndNote,
-        });
-        let tieAnchorNote: VexFlowGraphicalNote = startNote;
-        if (startNote !== undefined) {
-            tieAnchorNote = endNote;
+
+
+        if (tieIsAtSystemBreak) {
+            // split tie into two ties:
+            let vfTie1: Vex.Flow.StaveTie = new Vex.Flow.StaveTie({
+                first_note: vfStartNote,
+            });
+            let measure1: VexFlowMeasure = (startNote.parentStaffEntry.parentMeasure as VexFlowMeasure);
+            measure1.vfTies.push(vfTie1);
+
+            let vfTie2: Vex.Flow.StaveTie = new Vex.Flow.StaveTie({
+                last_note : vfEndNote,
+            });
+            let measure2: VexFlowMeasure = (endNote.parentStaffEntry.parentMeasure as VexFlowMeasure);
+            measure2.vfTies.push(vfTie2);
+        } else {
+            let vfTie: Vex.Flow.StaveTie = new Vex.Flow.StaveTie({
+                first_note: vfStartNote,
+                last_note : vfEndNote,
+            });
+            let measure: VexFlowMeasure = (endNote.parentStaffEntry.parentMeasure as VexFlowMeasure);
+            measure.vfTies.push(vfTie);
         }
-        let measure: VexFlowMeasure = (tieAnchorNote.parentStaffEntry.parentMeasure as VexFlowMeasure);
-        measure.vfTies.push(vfTie);
     }
 
     protected calculateSingleStaffLineLyricsPosition(staffLine: StaffLine, lyricVersesNumber: number[]): void {