Browse Source

Implemented/fixed handling of rest notes.

Matthias Uiberacker 5 years ago
parent
commit
87ae7619cb

+ 12 - 5
src/MusicalScore/Graphical/MusicSheetCalculator.ts

@@ -66,7 +66,6 @@ import { AbstractTempoExpression } from "../VoiceData/Expressions/AbstractTempoE
 import { GraphicalInstantaneousDynamicExpression } from "./GraphicalInstantaneousDynamicExpression";
 import { ContDynamicEnum } from "../VoiceData/Expressions/ContinuousExpressions/ContinuousDynamicExpression";
 import { GraphicalContinuousDynamicExpression } from "./GraphicalContinuousDynamicExpression";
-import { TabNote } from "../VoiceData/TabNote";
 
 /**
  * Class used to do all the calculations in a MusicSheet, which in the end populates a GraphicalMusicSheet.
@@ -684,11 +683,18 @@ export abstract class MusicSheetCalculator {
                 const graphicalMeasure: GraphicalMeasure = allMeasures[idx][idx2];
 
                 if (graphicalMeasure.isVisible()) {
-                    visiblegraphicalMeasures.push(graphicalMeasure);
-
-                    // add Tab Measure if exists:
+                    // if a Tab Measure exists:
                     if (graphicalMeasure.tabMeasure !== undefined) {
+                        // if there is no linked measure with "normal notes" given for the Tabs,
+                        // add the current measure to show the normal notes:
+                        if (visiblegraphicalMeasures.length === 0) {
+                            visiblegraphicalMeasures.push(graphicalMeasure);
+                        }
+                        // add the Tab measure:
                         visiblegraphicalMeasures.push(graphicalMeasure.tabMeasure);
+                    } else {
+                        // default case: normal measure
+                        visiblegraphicalMeasures.push(graphicalMeasure);
                     }
 
                     if (EngravingRules.Rules.ColoringEnabled) {
@@ -1598,7 +1604,8 @@ export abstract class MusicSheetCalculator {
             }
 
             // handle TabNotes:
-            if (note instanceof TabNote) {
+            if (graphicalTabVoiceEntry) {
+                // notes should be either TabNotes or RestNotes -> add all:
                 const graphicalTabNote: GraphicalNote = MusicSheetCalculator.symbolFactory.createNote(  note,
                                                                                                         graphicalTabVoiceEntry,
                                                                                                         activeClef,

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

@@ -480,6 +480,7 @@ export class VexFlowConverter {
             const tabNote: TabNote = note.sourceNote as TabNote;
             const tabPosition: {str: number, fret: number} = {str: tabNote.StringNumber, fret: tabNote.FretNumber};
             tabPositions.push(tabPosition);
+
             if (numDots < note.numberOfDots) {
                 numDots = note.numberOfDots;
             }

+ 5 - 1
src/MusicalScore/Graphical/VexFlow/VexFlowTabMeasure.ts

@@ -39,7 +39,11 @@ export class VexFlowTabMeasure extends VexFlowMeasure {
 
             // create vex flow Notes:
             for (const gve of graphicalStaffEntry.graphicalVoiceEntries) {
-                (gve as VexFlowVoiceEntry).vfStaveNote = VexFlowConverter.CreateTabNote(gve);
+                if (gve.notes[0].sourceNote.isRest()) {
+                    (gve as VexFlowVoiceEntry).vfStaveNote = VexFlowConverter.GhostNote(gve.notes[0].sourceNote.Length);
+                } else {
+                    (gve as VexFlowVoiceEntry).vfStaveNote = VexFlowConverter.CreateTabNote(gve);
+                }
             }
         }