diff --git a/src/engraving/dom/chord.cpp b/src/engraving/dom/chord.cpp index dc7e7ed6f40e2..68a7b804905ab 100644 --- a/src/engraving/dom/chord.cpp +++ b/src/engraving/dom/chord.cpp @@ -1131,34 +1131,6 @@ bool Chord::underBeam() const return false; } -//--------------------------------------------------------- -// updatePercussionNotes -//--------------------------------------------------------- - -static void updatePercussionNotes(Chord* c, const Drumset* drumset) -{ - TRACEFUNC; - for (Chord* ch : c->graceNotes()) { - updatePercussionNotes(ch, drumset); - } - std::vector lnotes(c->notes()); // we need a copy! - for (Note* note : lnotes) { - if (!drumset) { - note->setLine(0); - } else { - int pitch = note->pitch(); - if (!drumset->isValid(pitch)) { - note->setLine(0); - //! NOTE May be called too often - //LOGW("unmapped drum note %d", pitch); - } else if (!note->fixed()) { - note->undoChangeProperty(Pid::HEAD_GROUP, drumset->noteHead(pitch)); - note->setLine(drumset->line(pitch)); - } - } - } -} - //--------------------------------------------------------- // cmdUpdateNotes //--------------------------------------------------------- diff --git a/src/engraving/dom/utils.cpp b/src/engraving/dom/utils.cpp index 907e4ec2331ea..1918a5d0ceaf8 100644 --- a/src/engraving/dom/utils.cpp +++ b/src/engraving/dom/utils.cpp @@ -1971,4 +1971,28 @@ bool noteIsBefore(const Note* n1, const Note* n2) return false; } + +void updatePercussionNotes(Chord* c, const Drumset* drumset) +{ + TRACEFUNC; + for (Chord* ch : c->graceNotes()) { + updatePercussionNotes(ch, drumset); + } + std::vector lnotes(c->notes()); // we need a copy! + for (Note* note : lnotes) { + if (!drumset) { + note->setLine(0); + } else { + int pitch = note->pitch(); + if (!drumset->isValid(pitch)) { + note->setLine(0); + //! NOTE May be called too often + //LOGW("unmapped drum note %d", pitch); + } else if (!note->fixed()) { + note->undoChangeProperty(Pid::HEAD_GROUP, drumset->noteHead(pitch)); + note->setLine(drumset->line(pitch)); + } + } + } +} } diff --git a/src/engraving/dom/utils.h b/src/engraving/dom/utils.h index 16dafc72553f4..c934c67989407 100644 --- a/src/engraving/dom/utils.h +++ b/src/engraving/dom/utils.h @@ -31,6 +31,7 @@ namespace mu::engraving { class Chord; class ChordRest; +class Drumset; class EngravingItem; class KeySig; class Lyrics; @@ -133,4 +134,5 @@ extern std::vector filterTargetElements(const Selection& sel, En extern Lyrics* searchNextLyrics(Segment* s, staff_idx_t staffIdx, int verse, PlacementV p); extern bool noteIsBefore(const Note* n1, const Note* n2); +extern void updatePercussionNotes(Chord* c, const Drumset* drumset); } // namespace mu::engraving diff --git a/src/engraving/rw/read460/tread.cpp b/src/engraving/rw/read460/tread.cpp index 79e8eab9f5d9b..70e3f614ee32a 100644 --- a/src/engraving/rw/read460/tread.cpp +++ b/src/engraving/rw/read460/tread.cpp @@ -3836,6 +3836,18 @@ void TRead::lineBreakFromTag(String& str) void TRead::readNoteParenGroup(Chord* ch, XmlReader& e, ReadContext& ctx) { + StaffGroup staffGroup = ctx.staff(ch->staffIdx())->staffTypeForElement(ch)->group(); + if (staffGroup == StaffGroup::PERCUSSION) { + // We should have read all notes by now. They need to be sorted for percussion staves + const Instrument* instrument = ch->part()->instrument(ch->tick()); + const Drumset* drumset = instrument->drumset(); + if (!drumset) { + LOGW("no drumset"); + } + updatePercussionNotes(ch, drumset); + ch->sortNotes(); + } + Parenthesis* leftParen = nullptr; Parenthesis* rightParen = nullptr; std::vector notes; diff --git a/vtest/scores/paren-chords-4.mscz b/vtest/scores/paren-chords-4.mscz new file mode 100644 index 0000000000000..5a4ad8ec55092 Binary files /dev/null and b/vtest/scores/paren-chords-4.mscz differ