浏览代码

fix(tremolo): enable half note tremolo between two different half notes.

fix #472
sschmid 6 年之前
父节点
当前提交
eefadf8a54
共有 2 个文件被更改,包括 12 次插入7 次删除
  1. 7 0
      external/vexflow/vexflow.d.ts
  2. 5 7
      src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

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

@@ -71,6 +71,11 @@ declare namespace Vex {
             public addStroke(index: number, stroke: Stroke): void;
         }
 
+        class NoteHead extends Note {
+            constructor(head_options: Object);
+            static CATEGORY(): string;
+        }
+
         export class TextBracket {
             constructor(note_struct: any);
             
@@ -129,6 +134,8 @@ declare namespace Vex {
             public setStemStyle(style: any): void;
             public setFlagStyle(style: any): void;
 
+            public getKeyProps(): Object[];
+
             // temp solution until noteheadStyles PR is through
             public note_heads: any; // NoteHead[]; 
             public flag: Element;

+ 5 - 7
src/MusicalScore/Graphical/VexFlow/VexFlowConverter.ts

@@ -256,14 +256,12 @@ export class VexFlowConverter {
             vfnote = new Vex.Flow.StaveNote(vfnoteStruct);
         }
 
-        console.log("length: " + firstNote.Length.RealValue);
+        // half note tremolo: set notehead to half note (Vexflow otherwise takes the notehead from duration):
         if (firstNote.Length.RealValue === 0.25 && firstNote.Notehead && firstNote.Notehead.Filled === false) {
-            /*for (const noteHead in vfnote.note_heads) {
-                (<any>noteHead).glyph_code = 'v81';
-            }*/
-            console.log("here");
-            (<any>vfnote).glyph.code = "v81";
-            //(<any>vfnote).glyph.reset(); // TODO not a function
+            const keyProps: Object[] = vfnote.getKeyProps();
+            for (let i: number = 0; i < keyProps.length; i++) {
+                (<any>keyProps[i]).code = "v81";
+            }
         }
 
         if (EngravingRules.Rules.ColoringEnabled) {