Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MU3] Fix #314696: Ties end at wrong note #7190

Merged
merged 2 commits into from
Dec 30, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 22 additions & 12 deletions libmscore/read206.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1054,18 +1054,8 @@ bool readNoteProperties206(Note* note, XmlReader& e)
{
const QStringRef& tag(e.name());

if (tag == "pitch") {
int pitch = e.readInt();
Tie* tie = note->tieBack();
if (tie) {
int startPitch = tie->startNote()->pitch();
if (pitch != startPitch) {
qDebug("readNoteProperties206: Changing pitch from %d to %d to match pitch of note at start of tie.", pitch, startPitch);
pitch = startPitch;
}
}
note->setPitch(pitch);
}
if (tag == "pitch")
note->setPitch(e.readInt());
else if (tag == "tpc") {
const int tpc = e.readInt();
note->setTpc1(tpc);
Expand Down Expand Up @@ -2077,6 +2067,25 @@ static void convertDoubleArticulations(Chord* chord, XmlReader& e)
}
}

//---------------------------------------------------------
// fixTies
//---------------------------------------------------------

static void fixTies(Chord* chord)
{
std::vector<Note*> notes;
for (Note* note : chord->notes()) {
Tie* tie = note->tieBack();
if (tie && tie->startNote()->pitch() != note->pitch()) {
notes.push_back(tie->startNote());
}
}
for (Note* note : notes) {
Note* endNote = chord->findNote(note->pitch());
note->tieFor()->setEndNote(endNote);
}
}

//---------------------------------------------------------
// readChord
//---------------------------------------------------------
Expand Down Expand Up @@ -2116,6 +2125,7 @@ static void readChord(Chord* chord, XmlReader& e)
e.unknown();
}
convertDoubleArticulations(chord, e);
fixTies(chord);
}

//---------------------------------------------------------
Expand Down