diff --git a/importexport/musicxml/importmxmlpass2.cpp b/importexport/musicxml/importmxmlpass2.cpp index 07effc8308c89..42ca952fc2cca 100644 --- a/importexport/musicxml/importmxmlpass2.cpp +++ b/importexport/musicxml/importmxmlpass2.cpp @@ -6839,9 +6839,17 @@ void MusicXMLParserNotations::articulations() while (_e.readNextStartElement()) { SymId id { SymId::noSym }; if (convertArticulationToSymId(_e.name().toString(), id)) { - Notation artic = Notation::notationWithAttributes(_e.name().toString(), - _e.attributes(), "articulations", id); - _notations.push_back(artic); + if (_e.name() == "detached-legato") { + _notations.push_back(Notation::notationWithAttributes("tenuto", + _e.attributes(), "articulations", SymId::articTenutoAbove)); + _notations.push_back(Notation::notationWithAttributes("staccato", + _e.attributes(), "articulations", SymId::articStaccatoAbove)); + } + else { + Notation artic = Notation::notationWithAttributes(_e.name().toString(), + _e.attributes(), "articulations", id); + _notations.push_back(artic); + } _e.skipCurrentElement(); // skip but don't log } else if (_e.name() == "breath-mark") { @@ -7334,35 +7342,6 @@ Notation Notation::notationWithAttributes(const QString& name, const QXmlStreamA return notation; } -//--------------------------------------------------------- -// mergeNotations -//--------------------------------------------------------- - -/** - Helper function to merge two Notations. Used to combine articulations in combineArticulations. - */ - -Notation Notation::mergeNotations(const Notation& n1, const Notation& n2, const SymId& symId) - { - // Sort and combine the names - std::vector names{ n1.name(), n2.name() }; - std::sort(names.begin(), names.end()); - QString name = names[0] + " " + names[1]; - - // Parents should match (and will both be "articulation") - Q_ASSERT(n1.parent() == n2.parent()); - QString parent = n1.parent(); - - Notation mergedNotation { name, parent, symId }; - for (const auto& attr : n1.attributes()) { - mergedNotation.addAttribute(attr.first, attr.second); - } - for (const auto& attr : n2.attributes()) { - mergedNotation.addAttribute(attr.first, attr.second); - } - return mergedNotation; - } - //--------------------------------------------------------- // addAttribute //--------------------------------------------------------- @@ -7454,69 +7433,6 @@ void MusicXMLParserNotations::skipLogCurrElem() _e.skipCurrentElement(); } -//--------------------------------------------------------- -// skipCombine -//--------------------------------------------------------- - -/** - Helper function to hold conditions under which a potential combine should be skipped. - */ - -bool MusicXMLParserNotations::skipCombine(const Notation& n1, const Notation& n2) - { - bool placementsSpecifiedAndDifferent = n1.attribute("placement") != "" && - n2.attribute("placement") != "" && - n1.attribute("placement") != n2.attribute("placement"); - bool upMarcatoDownOther = (n1.name() == "strong-accent" && n1.attribute("type") == "up" && - n2.attribute("placement") == "below") || - (n2.name() == "strong-accent" && n2.attribute("type") == "up" && - n1.attribute("placement") == "below"); - bool downMarcatoUpOther = (n1.name() == "strong-accent" && n1.attribute("type") == "down" && - n2.attribute("placement") == "above") || - (n2.name() == "strong-accent" && n2.attribute("type") == "down" && - n1.attribute("placement") == "above"); - bool slurEndpoint = _slurStart || _slurStop; - return placementsSpecifiedAndDifferent || upMarcatoDownOther || downMarcatoUpOther || slurEndpoint; - } - -//--------------------------------------------------------- -// combineArticulations -//--------------------------------------------------------- -/** - Combine any eligible articulations. - i.e. accent + staccato = staccato accent - */ - -void MusicXMLParserNotations::combineArticulations() - { - QMap, SymId> map; // map set of symbols to combined symbol - map[{ SymId::articAccentAbove, SymId::articStaccatoAbove }] = SymId::articAccentStaccatoAbove; - map[{ SymId::articMarcatoAbove, SymId::articStaccatoAbove }] = SymId::articMarcatoStaccatoAbove; - map[{ SymId::articMarcatoAbove, SymId::articTenutoAbove }] = SymId::articMarcatoTenutoAbove; - map[{ SymId::articAccentAbove, SymId::articTenutoAbove }] = SymId::articTenutoAccentAbove; - - // Iterate through each distinct pair (backwards, to allow for deletions) - for (std::vector::reverse_iterator n1 = _notations.rbegin(), n1Next = n1; n1 != _notations.rend(); n1 = n1Next) { - n1Next = std::next(n1); - if (n1->parent() != "articulations") - continue; - for (std::vector::reverse_iterator n2 = n1 + 1, n2Next = n1; n2 != _notations.rend(); n2 = n2Next) { - n2Next = std::next(n2); - if (n2->parent() != "articulations" || skipCombine(*n1, *n2)) - continue; - // Combine and remove articulations if present in map - std::set currentPair = { n1->symId(), n2->symId() }; - if (map.contains(currentPair)) { - Notation mergedNotation = Notation::mergeNotations(*n1, *n2, map.value(currentPair)); - n1Next = decltype(n1){ _notations.erase(std::next(n1).base()) }; - n2Next = decltype(n2){ _notations.erase(std::next(n2).base()) }; - _notations.push_back(mergedNotation); - } - } - } - } - - //--------------------------------------------------------- // parse //--------------------------------------------------------- @@ -7573,7 +7489,6 @@ void MusicXMLParserNotations::parse() qDebug("%s", qPrintable(notation.print())); } */ - combineArticulations(); addError(checkAtEndElement(_e, "notations")); } diff --git a/importexport/musicxml/importmxmlpass2.h b/importexport/musicxml/importmxmlpass2.h index b5713335b1bcb..23d8729c30878 100644 --- a/importexport/musicxml/importmxmlpass2.h +++ b/importexport/musicxml/importmxmlpass2.h @@ -162,7 +162,6 @@ class Notation { QString text() const { return _text; } static Notation notationWithAttributes(const QString& name, const QXmlStreamAttributes attributes, const QString& parent = "", const SymId& symId = SymId::noSym); - static Notation mergeNotations(const Notation& n1, const Notation& n2, const SymId& symId = SymId::noSym); private: QString _name; QString _parent; @@ -219,12 +218,10 @@ class MusicXMLParserNotations { QString tremoloType() const { return _tremoloType; } int tremoloNr() const { return _tremoloNr; } bool mustStopGraceAFter() const { return _slurStop || _wavyLineStop; } - bool skipCombine(const Notation& n1, const Notation& n2); private: void addError(const QString& error); ///< Add an error to be shown in the GUI void addNotation(const Notation& notation, ChordRest* const cr, Note* const note); void addTechnical(const Notation& notation, Note* note); - void combineArticulations(); void harmonic(); void articulations(); void dynamics(); diff --git a/mtest/musicxml/io/testArticulationCombination.xml b/mtest/musicxml/io/testArticulationCombination.xml new file mode 100644 index 0000000000000..2ef77d032a465 --- /dev/null +++ b/mtest/musicxml/io/testArticulationCombination.xml @@ -0,0 +1,454 @@ + + + + + Title + + + Composer + + MuseScore 0.7.0 + 2007-09-10 + + + + + + + + + + Piano + Pno. + + Piano + + + + 1 + 1 + 78.7402 + 0 + + + + + + + 1 + + 0 + + + + G + 2 + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + D + 5 + + 1 + 1 + quarter + down + + + + + + + + + + E + 5 + + 1 + 1 + quarter + down + + + + + + + + + + F + 5 + + 1 + 1 + quarter + down + + + + + + + + + + + + G + 5 + + 1 + 1 + quarter + down + + + + + + + + + F + 5 + + 1 + 1 + quarter + down + + + + + + + + + + E + 5 + + 1 + 1 + quarter + down + + + + + + + + + + D + 5 + + 1 + 1 + quarter + down + + + + + + + + + + + + + + A + 4 + + 1 + 1 + quarter + up + + + + + + + + + + G + 4 + + 1 + 1 + quarter + up + + + + + + + + + + F + 4 + + 1 + 1 + quarter + up + + + + + + + + + + E + 4 + + 1 + 1 + quarter + up + + + + + + + + + + + + D + 4 + + 1 + 1 + quarter + up + + + + + + + + + E + 4 + + 1 + 1 + quarter + up + + + + + + + + + + F + 4 + + 1 + 1 + quarter + up + + + + + + + + + + G + 4 + + 1 + 1 + quarter + up + + + + + + + + + + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + + C + 5 + + 1 + 1 + quarter + down + + + + + + + + + + light-heavy + + + + diff --git a/mtest/musicxml/io/testArticulationsCombined.pdf b/mtest/musicxml/io/testArticulationsCombined.pdf deleted file mode 100644 index e12b9508b2393..0000000000000 Binary files a/mtest/musicxml/io/testArticulationsCombined.pdf and /dev/null differ diff --git a/mtest/musicxml/io/testArticulationsCombined.xml b/mtest/musicxml/io/testArticulationsCombined.xml deleted file mode 100644 index 34299f6a65593..0000000000000 --- a/mtest/musicxml/io/testArticulationsCombined.xml +++ /dev/null @@ -1,467 +0,0 @@ - - - - - Test Combined Articulations - - - Henry Ives - - MuseScore 0.7.0 - 2007-09-10 - - - - - - - - - - 7 - 40 - - - 1697.14 - 1200 - - 85.7143 - 85.7143 - 85.7143 - 85.7143 - - - 85.7143 - 85.7143 - 85.7143 - 85.7143 - - - - - - - title - Test Combined Articulations - - - composer - Henry Ives - - - subtitle - Musescore Test Case - - - - brace - - - Piano - Pno. - - Piano - - - - 1 - 1 - 78.7402 - 0 - - - - - - - - - 50.00 - 0.00 - - 170.00 - - - - 2 - - 0 - - - - G - 2 - - - - - E - 4 - - 2 - 1 - quarter - up - - single - O'er - - - - - E - 4 - - 1 - 1 - eighth - up - begin - - - - - - - - - - - single - the - - - - - E - 4 - - 1 - 1 - eighth - up - end - - - - - - - - - - - begin - ram - - - - - - - E - 4 - - 2 - 1 - quarter - up - - - - - - - - - - - end - parts - - - - - E - 5 - - 2 - 1 - quarter - down - - - - - - - - single - we - - - - - - - E - 4 - - 2 - 1 - quarter - up - - single - watched - - - - - E - 4 - - 1 - 1 - eighth - up - begin - - single - were - - - - - E - 4 - - 1 - 1 - eighth - up - end - - single - so - - - - - - - E - 4 - - 2 - 1 - quarter - up - - - - - - - - - - begin - gal - - - - - E - 5 - - 2 - 1 - quarter - down - - - - - - - middle - lant - - - - - - - E - 4 - - 2 - 1 - quarter - up - - - - - - - - end - ly - - - - - - E - 4 - - 1 - 1 - eighth - up - begin - - - - F - 1 - 4 - - 1 - 1 - eighth - sharp - up - end - - - - - - - - begin - strea - - - - - - - G - 4 - - 2 - 1 - quarter - up - - end - ming? - - - - - G - 5 - - 2 - 1 - quarter - down - - - - - - - - single - and - - - - - - - G - 4 - - 2 - 1 - quarter - up - - single - the - - - - - G - 4 - - 1 - 1 - eighth - up - begin - - begin - roc - - - - - G - 4 - - 1 - 1 - eighth - up - end - - end - ket's - - - - - - - G - 4 - - 2 - 1 - quarter - up - - - - - - - - single - red - - - - - 2 - 1 - quarter - - - light-heavy - - - - diff --git a/mtest/musicxml/io/testArticulationsCombined_ref.mscx b/mtest/musicxml/io/testArticulationsCombined_ref.mscx deleted file mode 100644 index c7a3ad52a17bb..0000000000000 --- a/mtest/musicxml/io/testArticulationsCombined_ref.mscx +++ /dev/null @@ -1,474 +0,0 @@ - - - - - 0 - 480 - - 1 - 1 - 1 - 0 - - Henry Ives - - - - - - - - - Test Combined Articulations - - - - stdNormal - - 3 - - Piano - - Piano - Pno. - Piano - 21 - 108 - 21 - 108 - keyboard.piano - F - - 100 - 95 - - - 100 - 33 - - - 100 - 50 - - - 100 - 67 - - - 100 - 100 - - - 120 - 67 - - - 150 - 100 - - - 150 - 50 - - - 120 - 50 - - - 120 - 100 - - - - - - - - - - 12.5 - - - - Test Combined Articulations - - - - right,top - - Henry Ives - - - - - Musescore Test Case - - - - - - G - G - - - 2 - 4 - - - quarter - - O'er - - up - - 64 - 18 - - - - up - 4 - 4 - - - begin - eighth - - the - - - stringsUpBow - - - articAccentStaccatoBelow - - - 64 - 18 - - - - mid - eighth - - begin - ram - - - stringsUpBow - - - articAccentStaccatoBelow - - - 64 - 18 - - - - - - - - quarter - - end - parts - - - ornamentTremblement - - - articTenutoAccentBelow - - up - - 64 - 18 - - - - quarter - - we - - - articTenutoAccentAbove - - down - - 76 - 18 - - - - - - - - quarter - - watched - - up - - 64 - 18 - - - - up - 4 - 4 - - - begin - eighth - - were - - - 64 - 18 - - - - mid - eighth - - so - - - 64 - 18 - - - - - - - - quarter - - begin - gal - - - articTenutoStaccatoBelow - - - stringsDownBow - - up - - 64 - 18 - - - - quarter - - middle - lant - - - articTenutoStaccatoAbove - - down - - 76 - 18 - - - - - - - - quarter - - end - 480 - 2/8 - ly - - - articAccentStaccatoBelow - - up - - 64 - 18 - - - - up - 4 - 3 - - - begin - eighth - - 64 - 18 - - - - mid - eighth - - begin - strea - - - articStaccatoBelow - 4 - - - articMarcatoAbove - 3 - - - - accidentalSharp - - 66 - 20 - - - - - - - - quarter - - end - ming? - - up - - 67 - 15 - - - - quarter - - and - - - articAccentStaccatoAbove - - down - - 79 - 15 - - - - - - - - quarter - - the - - up - - 67 - 15 - - - - up - 0 - 0 - - - begin - eighth - - begin - roc - - - 67 - 15 - - - - mid - eighth - - end - ket's - - - 67 - 15 - - - - - - - - quarter - - red - - - articMarcatoTenutoAbove - 3 - - up - - 67 - 15 - - - - quarter - - - end - - - - - - diff --git a/mtest/musicxml/io/testNoteAttributes2_ref.xml b/mtest/musicxml/io/testNoteAttributes2_ref.xml index b2ec46a6823ac..3c04cc65c868f 100644 --- a/mtest/musicxml/io/testNoteAttributes2_ref.xml +++ b/mtest/musicxml/io/testNoteAttributes2_ref.xml @@ -448,7 +448,8 @@ up - + +