Skip to content

Commit

Permalink
Correct dynamics on import from Finale
Browse files Browse the repository at this point in the history
Backport of musescore#23207
  • Loading branch information
miiizen authored and Jojo-Schmitz committed Jun 15, 2024
1 parent 2b45591 commit 00eb102
Show file tree
Hide file tree
Showing 4 changed files with 574 additions and 1 deletion.
13 changes: 12 additions & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3842,10 +3842,21 @@ void MusicXMLParserDirection::textToDynamic(QString& text) const
{
if (!preferences.getBool(PREF_IMPORT_MUSICXML_IMPORTINFERTEXTTYPE))
return;
QString simplifiedText = text.simplified();
QString simplifiedText = MScoreTextToMXML::toPlainText(text).simplified();
// Correct finale's incorrect dynamic export
if (_pass1.exporterString().contains("finale")) {
static const std::map<QString, QString> finaleDynamicSubs = { { "π", "pp" }, { "P", "mp" }, { "F", "mf" }, { "ƒ", "ff" } };
for (const auto& sub : finaleDynamicSubs) {
if (simplifiedText == sub.first) {
simplifiedText = sub.second;
break;
}
}
}
for (auto dyn : dynList) {
if (dyn.tag == simplifiedText) {
text = text.replace(simplifiedText, dyn.text);
break;
}
}
}
Expand Down
275 changes: 275 additions & 0 deletions mtest/musicxml/io/testFinaleDynamics.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,275 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 4.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="4.0">
<work>
<work-title>Untitled score</work-title>
</work>
<identification>
<creator type="composer">Composer / arranger</creator>
<encoding>
<software>Finale v27.4 for Windows</software>
<encoding-date>2024-05-20</encoding-date>
<supports attribute="new-system" element="print" type="yes" value="yes"/>
<supports attribute="new-page" element="print" type="yes" value="yes"/>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<defaults>
<scaling>
<millimeters>6.99911</millimeters>
<tenths>40</tenths>
</scaling>
<page-layout>
<page-height>1696.94</page-height>
<page-width>1200.48</page-width>
<page-margins type="even">
<left-margin>85.7252</left-margin>
<right-margin>85.7252</right-margin>
<top-margin>85.7252</top-margin>
<bottom-margin>85.7252</bottom-margin>
</page-margins>
<page-margins type="odd">
<left-margin>85.7252</left-margin>
<right-margin>85.7252</right-margin>
<top-margin>85.7252</top-margin>
<bottom-margin>85.7252</bottom-margin>
</page-margins>
</page-layout>
<appearance>
<line-width type="light barline">1.8</line-width>
<line-width type="heavy barline">5.5</line-width>
<line-width type="beam">5</line-width>
<line-width type="bracket">4.5</line-width>
<line-width type="dashes">1</line-width>
<line-width type="enclosure">1</line-width>
<line-width type="ending">1.1</line-width>
<line-width type="extend">1</line-width>
<line-width type="leger">1.6</line-width>
<line-width type="pedal">1.1</line-width>
<line-width type="octave shift">1.1</line-width>
<line-width type="slur middle">2.1</line-width>
<line-width type="slur tip">0.5</line-width>
<line-width type="staff">1.1</line-width>
<line-width type="stem">1</line-width>
<line-width type="tie middle">2.1</line-width>
<line-width type="tie tip">0.5</line-width>
<line-width type="tuplet bracket">1</line-width>
<line-width type="wedge">1.2</line-width>
<note-size type="cue">70</note-size>
<note-size type="grace">70</note-size>
<note-size type="grace-cue">49</note-size>
</appearance>
<music-font font-family="Leland"/>
<word-font font-family="Edwin" font-size="10"/>
<lyric-font font-family="Edwin" font-size="10"/>
</defaults>
<part-list>
<score-part id="P1">
<part-name>Flute</part-name>
<part-abbreviation>Fl.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Flute</instrument-name>
<instrument-sound>wind.flutes.flute</instrument-sound>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<midi-program>74</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1" width="368.09">
<print>
<system-layout>
<system-margins>
<left-margin>50</left-margin>
<right-margin>-0</right-margin>
</system-margins>
<top-system-distance>70</top-system-distance>
</system-layout>
</print>
<attributes>
<divisions>1</divisions>
<key>
<fifths>0</fifths>
</key>
<time>
<beats>4</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<direction placement="below">
<direction-type>
<words default-y="-63" font-family="Scarlatti" font-size="14.4">π</words>
</direction-type>
<sound dynamics="36.67"/>
</direction>
<note default-x="80.22" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<note default-x="151.73" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<direction placement="below">
<direction-type>
<words default-y="-63" font-family="Scarlatti" font-size="14.4">p</words>
</direction-type>
<sound dynamics="54.44"/>
</direction>
<note default-x="223.25" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<note default-x="294.77" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
</measure>
<measure number="2" width="300.87">
<direction placement="below">
<direction-type>
<words default-y="-63" font-family="Scarlatti" font-size="14.4">P</words>
</direction-type>
<sound dynamics="71.11"/>
</direction>
<note default-x="13" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<note default-x="84.52" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<direction placement="below">
<direction-type>
<words default-y="-62" font-family="Scarlatti" font-size="14.4" relative-x="-9">F</words>
</direction-type>
<sound dynamics="88.89"/>
</direction>
<note default-x="156.04" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<note default-x="227.55" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
</measure>
<measure number="3" width="310.07">
<direction placement="below">
<direction-type>
<words default-y="-63" font-family="Scarlatti" font-size="14.4">f</words>
</direction-type>
<sound dynamics="106.67"/>
</direction>
<note default-x="13" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<note default-x="84.52" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<direction placement="below">
<direction-type>
<words default-y="-63" font-family="Scarlatti" font-size="14.4">ƒ</words>
</direction-type>
<sound dynamics="124.44"/>
</direction>
<note default-x="156.04" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<note default-x="227.55" default-y="-20">
<pitch>
<step>B</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>down</stem>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
Loading

0 comments on commit 00eb102

Please sign in to comment.