From 30d897e3c8811c1aa2dc9e60b55b3d20bc9260a9 Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Wed, 27 May 2026 14:53:20 +0300 Subject: [PATCH] Musicxml: fix testInferredTechnique test --- muse | 2 +- .../internal/import/importmusicxmlpass2.cpp | 48 +++++++++++-------- .../tests/data/testInferredTechnique_ref.mscx | 2 +- 3 files changed, 29 insertions(+), 23 deletions(-) diff --git a/muse b/muse index 5246c265c45f6..98c8f70baede1 160000 --- a/muse +++ b/muse @@ -1 +1 @@ -Subproject commit 5246c265c45f6227c8e35f41bc581d795e0e8465 +Subproject commit 98c8f70baede1e6ccedb71badeba26b7e047bf10 diff --git a/src/importexport/musicxml/internal/import/importmusicxmlpass2.cpp b/src/importexport/musicxml/internal/import/importmusicxmlpass2.cpp index 757e8c7751912..b462e8ad4f3d4 100644 --- a/src/importexport/musicxml/internal/import/importmusicxmlpass2.cpp +++ b/src/importexport/musicxml/internal/import/importmusicxmlpass2.cpp @@ -5001,36 +5001,42 @@ PlayingTechniqueType MusicXmlParserDirection::getPlayingTechnique() const return PlayingTechniqueType::Undefined; } - const String plainWords = MScoreTextToMusicXml::toPlainText(m_wordsText.simplified()); - static const std::unordered_map textToPlayTechniqueType { - { u"natural", PlayingTechniqueType::Natural }, - { u"normal", PlayingTechniqueType::Natural }, - { u"ord", PlayingTechniqueType::Natural }, - { u"arco", PlayingTechniqueType::Natural }, - { u"pizz", PlayingTechniqueType::Pizzicato }, - { u"open", PlayingTechniqueType::Open }, - { u"senza sord", PlayingTechniqueType::Open }, - { u"unmuted", PlayingTechniqueType::Open }, + String plainWords = MScoreTextToMusicXml::toPlainText(m_wordsText.simplified()).toLower(); + plainWords.remove(std::wregex(L"[\\.,;:]+")); // remove punctuation + + // Ordered longest-first so specific phrases match before their substrings + // (e.g. "without mute" before "mute", "con sord" before "ord") + static const std::vector > textToPlayTechniqueType { + { u"palm mute", PlayingTechniqueType::Undefined }, + { u"palmmute", PlayingTechniqueType::Undefined }, { u"without mute", PlayingTechniqueType::Open }, - { u"no mute", PlayingTechniqueType::Open }, - { u"mute", PlayingTechniqueType::Mute }, + { u"distortion", PlayingTechniqueType::Distortion }, + { u"senza sord", PlayingTechniqueType::Open }, + { u"harmonics", PlayingTechniqueType::Harmonics }, + { u"overdrive", PlayingTechniqueType::Overdrive }, + { u"sul pont", PlayingTechniqueType::SulPonticello }, + { u"sul tast", PlayingTechniqueType::SulTasto }, { u"con sord", PlayingTechniqueType::Mute }, - { u"sord", PlayingTechniqueType::Mute }, - { u"trem", PlayingTechniqueType::Tremolo }, { u"detache", PlayingTechniqueType::Detache }, { u"martele", PlayingTechniqueType::Martele }, - { u"legno", PlayingTechniqueType::ColLegno }, - { u"sul pont", PlayingTechniqueType::SulPonticello }, - { u"sul tast", PlayingTechniqueType::SulTasto }, + { u"natural", PlayingTechniqueType::Natural }, + { u"no mute", PlayingTechniqueType::Open }, + { u"unmuted", PlayingTechniqueType::Open }, { u"vibrato", PlayingTechniqueType::Vibrato }, { u"legato", PlayingTechniqueType::Legato }, - { u"distortion", PlayingTechniqueType::Distortion }, - { u"overdrive", PlayingTechniqueType::Overdrive }, - { u"harmonics", PlayingTechniqueType::Harmonics }, + { u"normal", PlayingTechniqueType::Natural }, + { u"legno", PlayingTechniqueType::ColLegno }, + { u"open", PlayingTechniqueType::Open }, + { u"arco", PlayingTechniqueType::Natural }, { u"jazz", PlayingTechniqueType::JazzTone }, + { u"mute", PlayingTechniqueType::Mute }, + { u"pizz", PlayingTechniqueType::Pizzicato }, + { u"sord", PlayingTechniqueType::Mute }, + { u"trem", PlayingTechniqueType::Tremolo }, + { u"ord", PlayingTechniqueType::Natural }, }; - for (auto& technique : textToPlayTechniqueType) { + for (const auto& technique : textToPlayTechniqueType) { if (plainWords.contains(technique.first)) { return technique.second; } diff --git a/src/importexport/musicxml/tests/data/testInferredTechnique_ref.mscx b/src/importexport/musicxml/tests/data/testInferredTechnique_ref.mscx index 241e750928d69..bad2cb11dd1f4 100644 --- a/src/importexport/musicxml/tests/data/testInferredTechnique_ref.mscx +++ b/src/importexport/musicxml/tests/data/testInferredTechnique_ref.mscx @@ -321,7 +321,7 @@ t_t - mute + open u_u senza sord