Skip to content

Commit

Permalink
Fix switching voices from the middle of a tuplet
Browse files Browse the repository at this point in the history
  • Loading branch information
mathesoncalum committed Oct 1, 2024
1 parent ca634a4 commit ce8f32e
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/notation/internal/notationnoteinput.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -454,6 +454,20 @@ void NotationNoteInput::setCurrentVoice(voice_idx_t voiceIndex)
}

mu::engraving::InputState& inputState = score()->inputState();

// TODO: Inserting notes to a new voice in the middle of a tuplet is not yet supported. In this case
// we'll move the input to the start of the tuplet...
if (const Segment* prevSeg = inputState.segment()) {
const ChordRest* prevCr = prevSeg->cr(inputState.track());
//! NOTE: if there's an existing ChordRest at the new voiceIndex, we don't need to move the cursor
if (prevCr && prevCr->topTuplet() && !prevSeg->cr(voiceIndex)) {
Segment* newSeg = score()->tick2segment(prevCr->topTuplet()->tick());
if (newSeg) {
inputState.setSegment(newSeg);
}
}
}

inputState.setVoice(voiceIndex);
notifyAboutStateChanged();
}
Expand Down

0 comments on commit ce8f32e

Please sign in to comment.