From 4678b4042580e8c56aedca5f0793f2539469b9dc Mon Sep 17 00:00:00 2001 From: James Mizen Date: Fri, 28 Jun 2024 16:28:41 +0100 Subject: [PATCH 1/2] Fix missing glissandos and tremolos when creating a new part --- src/engraving/dom/excerpt.cpp | 37 +++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/engraving/dom/excerpt.cpp b/src/engraving/dom/excerpt.cpp index 55979532d6d26..819420200cb4f 100644 --- a/src/engraving/dom/excerpt.cpp +++ b/src/engraving/dom/excerpt.cpp @@ -1484,6 +1484,7 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star addElement(newEl); } + TremoloTwoChord* tremolo = nullptr; for (track_idx_t srcTrack : muse::keys(map)) { TupletMap tupletMap; // tuplets cannot cross measure boundaries track_idx_t dstTrack = map.at(srcTrack); @@ -1580,6 +1581,19 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star LOGD("cloneStaff2: cannot find tie"); } } + // add back spanners (going back from end to start spanner element + // makes sure the 'other' spanner anchor element is already set up) + // 'on' is the old spanner end note and 'nn' is the new spanner end note + for (Spanner* oldSp : on->spannerBack()) { + Note* newStart = Spanner::startElementFromSpanner(oldSp, nn); + if (newStart != nullptr) { + Spanner* newSp = toSpanner(oldSp->linkedClone()); + newSp->setNoteSpan(newStart, nn); + score->addElement(newSp); + } else { + LOGD("cloneStaff2: cannot find spanner start note"); + } + } GuitarBend* bendBack = on->bendBack(); Note* newStartNote = bendBack ? toNote(bendBack->startNote()->findLinkedInStaff(dstStaff)) : nullptr; if (bendBack && newStartNote) { @@ -1606,6 +1620,29 @@ void Excerpt::cloneStaff2(Staff* srcStaff, Staff* dstStaff, const Fraction& star nn->addSpannerFor(newBend); } } + // two note tremolo + if (och->tremoloTwoChord()) { + if (och == och->tremoloTwoChord()->chord1()) { + if (tremolo) { + LOGD("cloneStaff2: unconnected two note tremolo"); + } + tremolo = item_cast(och->tremoloTwoChord()->linkedClone()); + tremolo->setScore(nch->score()); + tremolo->setParent(nch); + tremolo->setTrack(nch->track()); + tremolo->setChords(nch, 0); + nch->setTremoloTwoChord(tremolo); + } else if (och == och->tremoloTwoChord()->chord2()) { + if (!tremolo) { + LOGD("cloneStaff2: first note for two note tremolo missing"); + } else { + tremolo->setChords(tremolo->chord1(), nch); + nch->setTremoloTwoChord(tremolo); + } + } else { + LOGD("cloneStaff2: inconsistent two note tremolo"); + } + } } } } From 7ef03b73074d7a6e496e8bf160df6422134e4131 Mon Sep 17 00:00:00 2001 From: James Mizen Date: Mon, 1 Jul 2024 08:56:50 +0100 Subject: [PATCH 2/2] Add test --- .../tests/parts_data/part-spanners-parts.mscx | 1440 +++++++++++++++++ .../tests/parts_data/part-spanners.mscx | 611 +++++++ src/engraving/tests/parts_tests.cpp | 10 + 3 files changed, 2061 insertions(+) create mode 100644 src/engraving/tests/parts_data/part-spanners-parts.mscx create mode 100644 src/engraving/tests/parts_data/part-spanners.mscx diff --git a/src/engraving/tests/parts_data/part-spanners-parts.mscx b/src/engraving/tests/parts_data/part-spanners-parts.mscx new file mode 100644 index 0000000000000..f870cc2f41803 --- /dev/null +++ b/src/engraving/tests/parts_data/part-spanners-parts.mscx @@ -0,0 +1,1440 @@ + + + + 480 + + 1 + 1 + 1 + 0 + 1 + + + Composer / arranger + + + + + + + Subtitle + + + Untitled score + + Orchestra + + Flutes + + + Oboes + +
+ flutes + oboes + clarinets + saxophones + bassoons + +
+
+ horns + trumpets + cornets + flugelhorns + trombones + tubas + +
+
+ timpani +
+
+ keyboard-percussion + + drums + unpitched-metal-percussion + unpitched-wooden-percussion + other-percussion + +
+ keyboards + harps + organs + synths + + +
+ voices + voice-groups +
+
+ orchestral-strings +
+
+ + + + stdNormal + + + 1 + + Flute + + Flute + Fl. + Flute + 59 + 98 + 60 + 93 + wind.flutes.flute + + + + + + + + + stdNormal + + + Oboe + + Oboe + Ob. + Oboe + 58 + 96 + 58 + 87 + wind.reed.oboe + + + + + + + + 10 + + + + + + + 0 + + + + 4 + 4 + + + + 0 + + + + + 1 + + + + + + quarter + + + + + + + 1/4 + + + + + + 67 + 15 + + + + + quarter + + + + -1/4 + + + + + + 62 + 16 + + + + + quarter + + + 67 + 15 + + + gliss. + + 1 + 3 + + + + 1/4 + + + + + + + + quarter + + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + + ritardando + 1.9 + 0 + 1.9 + rit. + + (rit.) + + + + + 1 + + + + + + half + 1/4 + + + 67 + 15 + + + c16 + + 0 + 2 + + + + + half + 1/4 + + + 62 + 16 + + + + + quarter + + + 67 + 15 + + + 0 + 0 + 1 + + 3 + + + + 1/4 + + + + + + + + quarter + + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + + no + eighth + + 1 + + + + noteheadParenthesisLeft + + + + noteheadParenthesisRight + + + 65 + 13 + 0 + + + 1 + 0 + 1 + + 3 + + + + + + + + + + + quarter + + + 67 + 15 + 0 + + + + 0 + + + + + + + + quarter + + + + + + + + + 1/4 + + + + 62 + 16 + + + + + quarter + + + + + + -1/4 + + + + 62 + 16 + + + + + quarter + + + + + + + + + + 0 + + + + 4 + 4 + + + + 0 + + + + + 1 + + + + + + quarter + + + + + + + 1/4 + + + + + + 67 + 15 + + + + + quarter + + + + -1/4 + + + + + + 62 + 16 + + + + + quarter + + + 67 + 15 + + + gliss. + + 1 + 3 + + + + 1/4 + + + + + + + + quarter + + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + + half + 1/4 + + + 67 + 15 + + + c16 + + 0 + 2 + + + + + half + 1/4 + + + 62 + 16 + + + + + quarter + + + 67 + 15 + + + 0 + 0 + 1 + + 3 + + + + 1/4 + + + + + + + + quarter + + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + no + eighth + + 1 + + + + noteheadParenthesisLeft + + + + noteheadParenthesisRight + + + 65 + 13 + 0 + + + 1 + 0 + 1 + + 3 + + + + + + + + + + + quarter + + + 67 + 15 + 0 + + + + 0 + + + + + + + + quarter + + + + + + + + + 1/4 + + + + 62 + 16 + + + + + quarter + + + + + + -1/4 + + + + 62 + 16 + + + + + quarter + + + + + + Flute + 480 + + 1 + 1 + 1 + 0 + Flute + + + 1 + + stdNormal + + + Flute + + Flute + Fl. + Flute + 59 + 98 + 60 + 93 + wind.flutes.flute + + + + + + + + 10 + + + + + Flute + + + + + + + + 0 + + + + + 4 + 4 + + + + 0 + + + + + + 1 + + + + + + + quarter + + + + + + + + 1/4 + + + + + + + 67 + 15 + + + + + + quarter + + + + -1/4 + + + + + + + 62 + 16 + + + + + + quarter + + + + 67 + 15 + + + gliss. + + + 1 + 3 + + + + 1/4 + + + + + + + + + quarter + + + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + + ritardando + 1.9 + 0 + 1.9 + rit. + + (rit.) + + + + + + 1 + + + + + + + half + 1/4 + + + + 67 + 15 + + + c16 + + + 0 + 2 + + + + + + half + 1/4 + + + + 62 + 16 + + + + + + quarter + + + + 67 + 15 + + + 0 + 0 + 1 + + + 3 + + + + 1/4 + + + + + + + + + quarter + + + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + + + no + eighth + + 1 + + + + + noteheadParenthesisLeft + + + + + noteheadParenthesisRight + + + + 65 + 13 + 0 + + + 1 + 0 + 1 + + + 3 + + + + + + + + + + + + quarter + + + + 67 + 15 + 0 + + + + 0 + + + + + + + + + quarter + + + + + + + + + + + 1/4 + + + + 62 + 16 + + + + + + quarter + + + + + + + -1/4 + + + + 62 + 16 + + + + + + quarter + + + + + + + Oboe + 480 + + 1 + 1 + 1 + 0 + Oboe + + + 2 + + stdNormal + + + Oboe + + Oboe + Ob. + Oboe + 58 + 96 + 58 + 87 + wind.reed.oboe + + + + + + + + 10 + + + -1 + + + + + Oboe + + + + + + + + 0 + + + + + 4 + 4 + + + + 0 + + + + + + 1 + + + + + + + quarter + + + + + + + + 1/4 + + + + + + + 67 + 15 + + + + + + quarter + + + + -1/4 + + + + + + + 62 + 16 + + + + + + quarter + + + + 67 + 15 + + + gliss. + + + 1 + 3 + + + + 1/4 + + + + + + + + + quarter + + + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + + ritardando + 1.9 + 0 + 1.9 + rit. + + (rit.) + + + -1 + + + + + + 1 + + + + + + + half + 1/4 + + + + 67 + 15 + + + c16 + + + 0 + 2 + + + + + + half + 1/4 + + + + 62 + 16 + + + + + + quarter + + + + 67 + 15 + + + 0 + 0 + 1 + + + 3 + + + + 1/4 + + + + + + + + + quarter + + + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + + + no + eighth + + 1 + + + + + noteheadParenthesisLeft + + + + + noteheadParenthesisRight + + + + 65 + 13 + 0 + + + 1 + 0 + 1 + + + 3 + + + + + + + + + + + + quarter + + + + 67 + 15 + 0 + + + + 0 + + + + + + + + + quarter + + + + + + + + + + + 1/4 + + + + 62 + 16 + + + + + + quarter + + + + + + + -1/4 + + + + 62 + 16 + + + + + + quarter + + + + + +
+
diff --git a/src/engraving/tests/parts_data/part-spanners.mscx b/src/engraving/tests/parts_data/part-spanners.mscx new file mode 100644 index 0000000000000..61557fc63b427 --- /dev/null +++ b/src/engraving/tests/parts_data/part-spanners.mscx @@ -0,0 +1,611 @@ + + + + 480 + + 1 + 1 + 1 + 0 + 1 + + + Composer / arranger + + + + + + + Subtitle + + + Untitled score + + Orchestra + + Flutes + + + Oboes + +
+ flutes + oboes + clarinets + saxophones + bassoons + +
+
+ horns + trumpets + cornets + flugelhorns + trombones + tubas + +
+
+ timpani +
+
+ keyboard-percussion + + drums + unpitched-metal-percussion + unpitched-wooden-percussion + other-percussion + +
+ keyboards + harps + organs + synths + + +
+ voices + voice-groups +
+
+ orchestral-strings +
+
+ + + + stdNormal + + + 1 + + Flute + + Flute + Fl. + Flute + 59 + 98 + 60 + 93 + wind.flutes.flute + + + + + + + + + stdNormal + + + Oboe + + Oboe + Ob. + Oboe + 58 + 96 + 58 + 87 + wind.reed.oboe + + + + + + + + + + 0 + + + 4 + 4 + + + + 0 + + + + 1 + + + + + quarter + + + + + + 1/4 + + + + + 67 + 15 + + + + quarter + + + + -1/4 + + + + + 62 + 16 + + + + quarter + + 67 + 15 + + + gliss. + 1 + 3 + + + + 1/4 + + + + + + + quarter + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + + ritardando + 1.9 + 0 + 1.9 + rit. + + (rit.) + + + + 1 + + + + + half + 1/4 + + 67 + 15 + + + c16 + 0 + 2 + + + + half + 1/4 + + 62 + 16 + + + + quarter + + 67 + 15 + + + 0 + 0 + 1 + 3 + + + + 1/4 + + + + + + + quarter + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + no + eighth + + 1 + + + noteheadParenthesisLeft + + + noteheadParenthesisRight + + 65 + 13 + 0 + + + 1 + 0 + 1 + 3 + + + + + + + + + + quarter + + 67 + 15 + 0 + + + + 0 + + + + + + + quarter + + + + + + + 1/4 + + + + 62 + 16 + + + + quarter + + + + + -1/4 + + + + 62 + 16 + + + + quarter + + + + + + + + + 0 + + + 4 + 4 + + + + 0 + + + + 1 + + + + + quarter + + + + + + 1/4 + + + + + 67 + 15 + + + + quarter + + + + -1/4 + + + + + 62 + 16 + + + + quarter + + 67 + 15 + + + gliss. + 1 + 3 + + + + 1/4 + + + + + + + quarter + + 62 + 16 + + + + -1/4 + + + + + + + + + + + + + -1 + + + + + half + 1/4 + + 67 + 15 + + + c16 + 0 + 2 + + + + half + 1/4 + + 62 + 16 + + + + quarter + + 67 + 15 + + + 0 + 0 + 1 + 3 + + + + 1/4 + + + + + + + quarter + + 62 + 16 + + + + -1/4 + + + + + + + + + + + no + eighth + + 1 + + + noteheadParenthesisLeft + + + noteheadParenthesisRight + + 65 + 13 + 0 + + + 1 + 0 + 1 + 3 + + + + + + + + + + quarter + + 67 + 15 + 0 + + + + 0 + + + + + + + quarter + + + + + + + 1/4 + + + + 62 + 16 + + + + quarter + + + + + -1/4 + + + + 62 + 16 + + + + quarter + + + + +
+
diff --git a/src/engraving/tests/parts_tests.cpp b/src/engraving/tests/parts_tests.cpp index 1ec285e711b02..a2fec92c22948 100644 --- a/src/engraving/tests/parts_tests.cpp +++ b/src/engraving/tests/parts_tests.cpp @@ -1260,6 +1260,16 @@ TEST_F(Engraving_PartsTests, partPropertyLinking) PARTS_DATA_DIR + u"partPropertyLinking-part-0.mscx")); } +TEST_F(Engraving_PartsTests, partSpanners) +{ + bool useRead302 = MScore::useRead302InTestMode; + MScore::useRead302InTestMode = false; + + testPartCreation(u"part-spanners"); + + MScore::useRead302InTestMode = useRead302; +} + //--------------------------------------------------------- // staffStyles //---------------------------------------------------------