Skip to content

Commit

Permalink
Merge pull request #6104 from MarcSabatella/305069
Browse files Browse the repository at this point in the history
fix #305069: playback of chord symbols attached to fret diagrams
  • Loading branch information
anatoly-os committed May 25, 2020
2 parents 9356e65 + e7d54f4 commit 13785a5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
15 changes: 10 additions & 5 deletions libmscore/harmony.cpp
Expand Up @@ -241,7 +241,7 @@ void Harmony::write(XmlWriter& xml) const
int rBaseTpc = _baseTpc;
if (staff()) {
// parent can be a fret diagram
Segment* segment = parent()->isSegment() ? toSegment(parent()) : toSegment(parent()->parent());
Segment* segment = getParentSeg();
Fraction tick = segment ? segment->tick() : Fraction(-1,1);
const Interval& interval = part()->instrument(tick)->transpose();
if (xml.clipboardmode() && !score()->styleB(Sid::concertPitch) && interval.chromatic) {
Expand Down Expand Up @@ -884,7 +884,7 @@ void Harmony::endEdit(EditData& ed)
// we may now need to change the TPC's and the text, and re-render
if (score()->styleB(Sid::concertPitch) != h->score()->styleB(Sid::concertPitch)) {
Part* partDest = h->part();
Segment* segment = toSegment(parent());
Segment* segment = getParentSeg();
Fraction tick = segment ? segment->tick() : Fraction(-1,1);
Interval interval = partDest->instrument(tick)->transpose();
if (!interval.isZero()) {
Expand Down Expand Up @@ -1064,16 +1064,21 @@ Harmony* Harmony::findPrev() const
//---------------------------------------------------------
Fraction Harmony::ticksTilNext(bool stopAtMeasureEnd) const
{
Segment* seg = toSegment(parent());
Segment* seg = getParentSeg();
Fraction duration = seg->ticks();
Segment* cur = seg->next1();
while (cur) {
if (stopAtMeasureEnd && (cur->measure() != seg->measure()))
break; //limit by measure end

//find harmony on same track
Element* e = cur->findAnnotation(ElementType::HARMONY,
track(), track());
Element* e = cur->findAnnotation(ElementType::HARMONY, track(), track());
// no harmony; look for fret diagram
if (!e) {
e = cur->findAnnotation(ElementType::FRET_DIAGRAM, track(), track());
if (e)
e = toFretDiagram(e)->harmony();
}
if (e) {
//we have found the next chord symbol
//set duration to the difference between
Expand Down
20 changes: 14 additions & 6 deletions libmscore/rendermidi.cpp
Expand Up @@ -589,10 +589,14 @@ void MidiRenderer::collectMeasureEventsSimple(EventMap* events, Measure* m, cons
//render harmony
if (sctx.renderHarmony) {
for (Element* e : seg->annotations()) {
if (!e->isHarmony() || (e->track() < strack) || (e->track() >= etrack))
if (!e || (e->track() < strack) || (e->track() >= etrack))
continue;
Harmony* h = toHarmony(e);
if (!h->play())
Harmony* h = nullptr;
if (e->isHarmony())
h = toHarmony(e);
else if (e->isFretDiagram())
h = toFretDiagram(e)->harmony();
if (!h || !h->play())
continue;
renderHarmony(events, m, h, tickOffset);
}
Expand Down Expand Up @@ -670,10 +674,14 @@ void MidiRenderer::collectMeasureEventsDefault(EventMap* events, Measure* m, con
//render harmony
if (sctx.renderHarmony) {
for (Element* e : seg->annotations()) {
if (!e->isHarmony() || (e->track() < strack) || (e->track() >= etrack))
if (!e || (e->track() < strack) || (e->track() >= etrack))
continue;
Harmony* h = toHarmony(e);
if (!h->play())
Harmony* h = nullptr;
if (e->isHarmony())
h = toHarmony(e);
else if (e->isFretDiagram())
h = toFretDiagram(e)->harmony();
if (!h || !h->play())
continue;
renderHarmony(events, m, h, tickOffset);
}
Expand Down

0 comments on commit 13785a5

Please sign in to comment.