Skip to content

Commit

Permalink
fix: fixed a bug in stem calculation which made all stems up for a si…
Browse files Browse the repository at this point in the history
…ngle voice.
  • Loading branch information
matt-uib committed Mar 28, 2018
1 parent 46ca911 commit aeb670e
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions src/MusicalScore/Graphical/MusicSheetCalculator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2135,8 +2135,32 @@ export abstract class MusicSheetCalculator {
// Linked voice: set stem down:
voiceEntry.StemDirection = StemDirectionType.Down;
} else {
// if this voiceEntry belongs to the mainVoice: stem Up
voiceEntry.StemDirection = StemDirectionType.Up;
// if this voiceEntry belongs to the mainVoice:
// check first that there are also more voices present:
if (voiceEntry.ParentSourceStaffEntry.VoiceEntries.length > 1) {
// as this voiceEntry belongs to the mainVoice: stem Up
voiceEntry.StemDirection = StemDirectionType.Up;
}
}
}

// ToDo: shift code to end of measure to only check once for all beams
// check for a beam:
// if this voice entry currently has no desired direction yet:
if (voiceEntry.StemDirection === StemDirectionType.Undefined &&
voiceEntry.Notes.length > 0) {
const beam: Beam = voiceEntry.Notes[0].NoteBeam;
if (beam !== undefined) {
// if there is a beam, find any already set stemDirection in the beam:
for (const note of beam.Notes) {
if (note.ParentVoiceEntry === voiceEntry) {
continue;
} else if (note.ParentVoiceEntry.StemDirection !== StemDirectionType.Undefined) {
// set the stem direction
voiceEntry.StemDirection = note.ParentVoiceEntry.StemDirection;
break;
}
}
}
}
}
Expand Down

0 comments on commit aeb670e

Please sign in to comment.