Skip to content

Commit

Permalink
ENG-68: Fix pedal endpoints on other tracks
Browse files Browse the repository at this point in the history
Sometimes pedals are imported that begin or end on segments that have
notes on tracks (or staves) other than the track the spanner is on.
Previously, this would cause incorrect tick adjustments on "change"
type pedals, and it would result in some pedals not being able to
compute a start or end element. This commit fixes these issues by
considering all tracks of a part when assessing pedal change tick
adjustments and when computing start elements.
  • Loading branch information
iveshenry18 committed Jul 30, 2021
1 parent cd0ea90 commit 86e9930
Show file tree
Hide file tree
Showing 4 changed files with 496 additions and 181 deletions.
15 changes: 13 additions & 2 deletions importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2033,9 +2033,20 @@ void MusicXMLParserPass2::part()
auto sp = i.key();
Fraction tick1 = Fraction::fromTicks(i.value().first);
Fraction tick2 = Fraction::fromTicks(i.value().second);
if (sp->isPedal() && toPedal(sp)->endHookType() == HookType::HOOK_45)
if (sp->isPedal() && toPedal(sp)->endHookType() == HookType::HOOK_45) {
// Handle pedal change end tick (slightly hacky)
tick2 += _score->findCR(tick2, sp->track())->ticks();
// Find CR on the end tick of
ChordRest* terminatingCR = _score->findCR(tick2, sp->effectiveTrack2());
for (int track = _pass1.getPart(id)->startTrack(); track <= _pass1.getPart(id)->endTrack(); ++track) {
ChordRest* tempCR = _score->findCR(tick2, track);
if (!terminatingCR
|| (tempCR && tempCR->tick() > terminatingCR->tick())
|| (tempCR && tempCR->tick() == terminatingCR->tick() && tempCR->ticks() < terminatingCR->ticks()))
terminatingCR = tempCR;
}
tick2 += terminatingCR->ticks();
sp->setTrack2(terminatingCR->track());
}
//qDebug("spanner %p tp %d tick1 %s tick2 %s track1 %d track2 %d",
// sp, sp->type(), qPrintable(tick1.print()), qPrintable(tick2.print()), sp->track(), sp->track2());
if (incompleteSpanners.find(sp) == incompleteSpanners.end()) {
Expand Down
17 changes: 11 additions & 6 deletions libmscore/spanner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include "chord.h"
#include "segment.h"
#include "measure.h"
#include "part.h"
#include "undo.h"
#include "staff.h"
#include "lyrics.h"
Expand Down Expand Up @@ -579,14 +580,18 @@ void Spanner::computeStartElement()
switch (_anchor) {
case Anchor::SEGMENT: {
Segment* seg = score()->tick2segmentMM(tick(), false, SegmentType::ChordRest);
int strack = (track() / VOICES) * VOICES;
int etrack = strack + VOICES;
int strack = part()->startTrack();
int etrack = part()->endTrack();
_startElement = 0;
if (seg) {
for (int t = strack; t < etrack; ++t) {
if (seg->element(t)) {
_startElement = seg->element(t);
break;
if (seg->element(track()))
_startElement = seg->element(track());
else {
for (int t = strack; t < etrack; ++t) {
if (seg->element(t)) {
_startElement = seg->element(t);
break;
}
}
}
}
Expand Down

0 comments on commit 86e9930

Please sign in to comment.