From 132491e561abae6e9327a63f5c43aed8b2a74c97 Mon Sep 17 00:00:00 2001 From: Klaus Rettinghaus Date: Tue, 28 Nov 2023 11:44:27 +0100 Subject: [PATCH] fix pedal import/export for MusicXML --- .../musicxml/internal/musicxml/exportxml.cpp | 6 +- .../internal/musicxml/importmxmlpass2.cpp | 6 + .../musicxml/tests/data/testDirections1.xml | 4 +- .../tests/data/testDirections1_ref.xml | 4 +- .../musicxml/tests/data/testPedalChanges.xml | 138 ++--- .../tests/data/testPedalChanges_ref.mscx | 495 ------------------ .../musicxml/tests/musicxml_tests.cpp | 2 +- 7 files changed, 59 insertions(+), 596 deletions(-) delete mode 100644 src/importexport/musicxml/tests/data/testPedalChanges_ref.mscx diff --git a/src/importexport/musicxml/internal/musicxml/exportxml.cpp b/src/importexport/musicxml/internal/musicxml/exportxml.cpp index d22dfed4e46fd..502d5fcd4346b 100644 --- a/src/importexport/musicxml/internal/musicxml/exportxml.cpp +++ b/src/importexport/musicxml/internal/musicxml/exportxml.cpp @@ -5159,12 +5159,12 @@ void ExportMusicXml::pedal(Pedal const* const pd, staff_idx_t staff, const Fract pedalType = "change"; break; case HookType::NONE: - pedalType = "resume"; + pedalType = pd->lineVisible() ? "resume" : "start"; break; default: pedalType = "start"; } - signText = pd->beginText() == "" ? " sign=\"no\"" : " sign=\"yes\""; + signText = pd->beginText().isEmpty() ? " sign=\"no\"" : " sign=\"yes\""; } else { if (!pd->endText().isEmpty() || pd->endHookType() == HookType::HOOK_90) { pedalType = "stop"; @@ -5173,7 +5173,7 @@ void ExportMusicXml::pedal(Pedal const* const pd, staff_idx_t staff, const Fract } // "change" type is handled only on the beginning of pedal lines - signText = pd->endText() == "" ? " sign=\"no\"" : " sign=\"yes\""; + signText = pd->endText().isEmpty() ? " sign=\"no\"" : " sign=\"yes\""; } pedalXml = QString("pedal type=\"%1\"").arg(pedalType); pedalXml += lineText; diff --git a/src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp b/src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp index 35a5b20889b2b..8f1b5c5fccd99 100644 --- a/src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp +++ b/src/importexport/musicxml/internal/musicxml/importmxmlpass2.cpp @@ -3552,6 +3552,8 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */, p->setBeginText(u"keyboardPedalPed"); p->setContinueText(u"(keyboardPedalPed)"); } else { + p->setBeginText(u""); + p->setContinueText(u""); p->setBeginHookType(type == "resume" ? HookType::NONE : HookType::HOOK_90); } p->setEndHookType(HookType::NONE); @@ -3596,6 +3598,10 @@ void MusicXMLParserDirection::pedal(const QString& type, const int /* number */, } else { p->setLineVisible(false); } + if (sign == "no") { + p->setBeginText(u""); + p->setContinueText(u""); + } if (color.isValid()) { p->setColor(color); } diff --git a/src/importexport/musicxml/tests/data/testDirections1.xml b/src/importexport/musicxml/tests/data/testDirections1.xml index 6e36f6ce5acc2..41bd54d0ddb18 100644 --- a/src/importexport/musicxml/tests/data/testDirections1.xml +++ b/src/importexport/musicxml/tests/data/testDirections1.xml @@ -102,7 +102,7 @@ - + @@ -132,7 +132,7 @@ - + diff --git a/src/importexport/musicxml/tests/data/testDirections1_ref.xml b/src/importexport/musicxml/tests/data/testDirections1_ref.xml index 6e36f6ce5acc2..41bd54d0ddb18 100644 --- a/src/importexport/musicxml/tests/data/testDirections1_ref.xml +++ b/src/importexport/musicxml/tests/data/testDirections1_ref.xml @@ -102,7 +102,7 @@ - + @@ -132,7 +132,7 @@ - + diff --git a/src/importexport/musicxml/tests/data/testPedalChanges.xml b/src/importexport/musicxml/tests/data/testPedalChanges.xml index f8a9eb7910b56..a64a996bdb940 100644 --- a/src/importexport/musicxml/tests/data/testPedalChanges.xml +++ b/src/importexport/musicxml/tests/data/testPedalChanges.xml @@ -1,6 +1,6 @@ - - + + Pedal Changes @@ -16,46 +16,7 @@ - - - 7 - 40 - - - 1697.14 - 1200 - - 85.7143 - 85.7143 - 85.7143 - 85.7143 - - - 85.7143 - 85.7143 - 85.7143 - 85.7143 - - - - - - - title - Pedal Changes - - - subtitle - MuseScore Testcase - - - composer - Henry Ives - - - brace - Piano Pno. @@ -72,16 +33,7 @@ - - - - - 50.00 - 0.00 - - 170.00 - - + 1 @@ -98,10 +50,10 @@ - + - + C 4 @@ -111,7 +63,7 @@ quarter up - + D 4 @@ -121,7 +73,7 @@ quarter up - + E 4 @@ -131,7 +83,7 @@ quarter up - + F 4 @@ -143,12 +95,12 @@ - + - - + + G 4 @@ -158,7 +110,7 @@ quarter up - + A 4 @@ -170,10 +122,10 @@ - + - + B 4 @@ -183,7 +135,7 @@ quarter down - + C 5 @@ -195,12 +147,12 @@ - + - - + + D 5 @@ -210,7 +162,7 @@ quarter down - + E 5 @@ -220,7 +172,7 @@ quarter down - + F 5 @@ -230,7 +182,7 @@ quarter down - + G 5 @@ -241,13 +193,13 @@ down - + - + - + A 5 @@ -257,7 +209,7 @@ quarter down - + B 5 @@ -269,10 +221,10 @@ - + - + A 5 @@ -282,7 +234,7 @@ quarter down - + G 5 @@ -293,13 +245,13 @@ down - + - + - + F 5 @@ -309,7 +261,7 @@ quarter down - + E 5 @@ -319,7 +271,7 @@ quarter down - + D 5 @@ -329,7 +281,7 @@ quarter down - + C 5 @@ -341,12 +293,12 @@ - + - - + + B 4 @@ -356,7 +308,7 @@ quarter down - + A 4 @@ -366,7 +318,7 @@ quarter up - + G 4 @@ -376,7 +328,7 @@ quarter up - + F 4 @@ -387,13 +339,13 @@ up - + - + - + E 4 @@ -403,7 +355,7 @@ quarter up - + D 4 @@ -421,7 +373,7 @@ - + diff --git a/src/importexport/musicxml/tests/data/testPedalChanges_ref.mscx b/src/importexport/musicxml/tests/data/testPedalChanges_ref.mscx deleted file mode 100644 index 50f12a6c42924..0000000000000 --- a/src/importexport/musicxml/tests/data/testPedalChanges_ref.mscx +++ /dev/null @@ -1,495 +0,0 @@ - - - - 480 - - 1 - 1 - 1 - 0 - - Henry Ives - - - - - - - - Pedal Changes - - - - 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 - 0 - - - - Pedal Changes - - - - - MuseScore Testcase - - - - right,top - - Henry Ives - - - - - - G - G - 1 - - - 4 - 4 - - - - 1 - - - - 1 - - - - - quarter - up - - 60 - 14 - - - - quarter - up - - 62 - 16 - - - - quarter - up - - 64 - 18 - - - - quarter - up - - 65 - 13 - - - - - - - - - - -1 - - - - - quarter - up - - 67 - 15 - - - - quarter - up - - 69 - 17 - - - - - 1 - - - - 1 - -1/2 - - - - - quarter - down - - 71 - 19 - - - - quarter - down - - 72 - 14 - - - - - - - - - - -1 - 1/2 - - - - - quarter - down - - 74 - 16 - - - - quarter - down - - 76 - 18 - - - - quarter - down - - 77 - 13 - - - - quarter - down - - 79 - 15 - - - - - - - - - 2 - - - - 3/4 - - - - - quarter - down - - 81 - 17 - - - - quarter - down - - 83 - 19 - - - - - 2 - 2 - - - - 1 - -1/4 - - - - - quarter - down - - 81 - 17 - - - - - - -3/4 - - - - - quarter - down - - 79 - 15 - - - - - - - - - 1 - 2 - - - - 1 - - - - - quarter - down - - 77 - 13 - - - - - - -1 - 1/4 - - - - - quarter - down - - 76 - 18 - - - - quarter - down - - 74 - 16 - - - - quarter - down - - 72 - 14 - - - - - - - - - - -1 - - - - - quarter - down - - 71 - 19 - - - - quarter - up - - 69 - 17 - - - - quarter - up - - 67 - 15 - - - - quarter - up - - 65 - 13 - - - - - - - - - 1 - - - - 1/1 - - - - - quarter - up - - 64 - 18 - - - - quarter - up - - 62 - 16 - - - - half - - - end - - - - - -1/1 - - - - - - - - diff --git a/src/importexport/musicxml/tests/musicxml_tests.cpp b/src/importexport/musicxml/tests/musicxml_tests.cpp index cf85348dd0809..aa5b8247e3c96 100644 --- a/src/importexport/musicxml/tests/musicxml_tests.cpp +++ b/src/importexport/musicxml/tests/musicxml_tests.cpp @@ -807,7 +807,7 @@ TEST_F(Musicxml_Tests, numberedLyrics) { mxmlIoTestRef("testNumberedLyrics"); } TEST_F(Musicxml_Tests, pedalChanges) { - mxmlImportTestRef("testPedalChanges"); + mxmlIoTest("testPedalChanges"); } TEST_F(Musicxml_Tests, pedalChangesBroken) { mxmlImportTestRef("testPedalChangesBroken");