Skip to content

Commit

Permalink
Fix #320818: Chord symbols with a bass extension don't export to Musi…
Browse files Browse the repository at this point in the history
…cXML correctly (nor import back)

Backport of musescore#17693
  • Loading branch information
Jojo-Schmitz committed Jun 22, 2023
1 parent 5ca2b43 commit 7250ef5
Show file tree
Hide file tree
Showing 4 changed files with 311 additions and 9 deletions.
31 changes: 22 additions & 9 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7029,6 +7029,18 @@ void ExportMusicXml::harmony(Harmony const* const h, FretDiagram const* const fd
if (h->xmlParens() == "yes")
s += " parentheses-degrees=\"yes\"";
_xml.tag(s, h->xmlKind());

int baseTpc = h->baseTpc();
if (baseTpc != Tpc::TPC_INVALID) {
_xml.stag("bass");
_xml.tag("bass-step", tpc2stepName(baseTpc));
alter = int(tpc2alter(baseTpc));
if (alter) {
_xml.tag("bass-alter", alter);
}
_xml.etag();
}

QStringList l = h->xmlDegrees();
if (!l.isEmpty()) {
for (QString tag : qAsConst(l)) {
Expand Down Expand Up @@ -7074,18 +7086,19 @@ void ExportMusicXml::harmony(Harmony const* const h, FretDiagram const* const fd
_xml.tag("kind", "");
else
_xml.tag(QString("kind text=\"%1\"").arg(h->extensionName()), "");
}

int baseTpc = h->baseTpc();
if (baseTpc != Tpc::TPC_INVALID) {
_xml.stag("bass");
_xml.tag("bass-step", tpc2stepName(baseTpc));
alter = int(tpc2alter(baseTpc));
if (alter) {
_xml.tag("bass-alter", alter);
int baseTpc = h->baseTpc();
if (baseTpc != Tpc::TPC_INVALID) {
_xml.stag("bass");
_xml.tag("bass-step", tpc2stepName(baseTpc));
alter = int(tpc2alter(baseTpc));
if (alter) {
_xml.tag("bass-alter", alter);
}
_xml.etag();
}
_xml.etag();
}

if (offset > 0)
_xml.tag("offset", offset);
if (fd)
Expand Down
171 changes: 171 additions & 0 deletions mtest/musicxml/io/testChordSymbols.mscx
Original file line number Diff line number Diff line change
@@ -0,0 +1,171 @@
<?xml version="1.0" encoding="UTF-8"?>
<museScore version="3.01">
<programVersion>3.5.0</programVersion>
<programRevision>3543170</programRevision>
<Score>
<Division>480</Division>
<Style>
<pageWidth>8.27</pageWidth>
<pageHeight>11.69</pageHeight>
<pagePrintableWidth>7.4826</pagePrintableWidth>
<Spatium>1.76389</Spatium>
</Style>
<showInvisible>1</showInvisible>
<showUnprintable>1</showUnprintable>
<showFrames>1</showFrames>
<showMargins>0</showMargins>
<metaTag name="arranger"></metaTag>
<metaTag name="composer"></metaTag>
<metaTag name="copyright"></metaTag>
<metaTag name="creationDate">2020-02-24</metaTag>
<metaTag name="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></metaTag>
<metaTag name="platform">Apple Macintosh</metaTag>
<metaTag name="poet"></metaTag>
<metaTag name="source"></metaTag>
<metaTag name="translator"></metaTag>
<metaTag name="workNumber"></metaTag>
<metaTag name="workTitle"></metaTag>
<Part>
<Staff id="1">
<StaffType group="pitched">
<name>stdNormal</name>
</StaffType>
</Staff>
<trackName>Voice</trackName>
<Instrument>
<longName>Voice</longName>
<shortName>Vo.</shortName>
<trackName>Voice</trackName>
<minPitchP>36</minPitchP>
<maxPitchP>94</maxPitchP>
<minPitchA>40</minPitchA>
<maxPitchA>79</maxPitchA>
<instrumentId>voice.vocals</instrumentId>
<Articulation>
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="staccatissimo">
<velocity>100</velocity>
<gateTime>33</gateTime>
</Articulation>
<Articulation name="staccato">
<velocity>100</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="portato">
<velocity>100</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="tenuto">
<velocity>100</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="marcato">
<velocity>120</velocity>
<gateTime>67</gateTime>
</Articulation>
<Articulation name="sforzato">
<velocity>150</velocity>
<gateTime>100</gateTime>
</Articulation>
<Articulation name="sforzatoStaccato">
<velocity>150</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoStaccato">
<velocity>120</velocity>
<gateTime>50</gateTime>
</Articulation>
<Articulation name="marcatoTenuto">
<velocity>120</velocity>
<gateTime>100</gateTime>
</Articulation>
<Channel>
<controller ctrl="32" value="17"/>
<program value="52"/>
<synti>Fluid</synti>
</Channel>
<Channel name="harmony">
<controller ctrl="0" value="0"/>
<controller ctrl="32" value="17"/>
<program value="0"/>
<synti>Fluid</synti>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<Measure>
<voice>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Harmony>
<root>11</root>
<name>m(add9)</name>
<base>13</base>
</Harmony>
<Chord>
<durationType>quarter</durationType>
<StemDirection>down</StemDirection>
<Note>
<Accidental>
<subtype>accidentalFlat</subtype>
</Accidental>
<Spanner type="Tie">
<Tie>
</Tie>
<next>
<location>
<fractions>1/4</fractions>
</location>
</next>
</Spanner>
<pitch>75</pitch>
<tpc>11</tpc>
<velocity>80</velocity>
<veloType>user</veloType>
</Note>
</Chord>
<Chord>
<dots>1</dots>
<durationType>quarter</durationType>
<StemDirection>down</StemDirection>
<Note>
<Spanner type="Tie">
<prev>
<location>
<fractions>-1/4</fractions>
</location>
</prev>
</Spanner>
<pitch>75</pitch>
<tpc>11</tpc>
<velocity>80</velocity>
<veloType>user</veloType>
</Note>
</Chord>
<Rest>
<durationType>eighth</durationType>
</Rest>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<Accidental>
<subtype>accidentalFlat</subtype>
</Accidental>
<pitch>68</pitch>
<tpc>10</tpc>
<velocity>80</velocity>
<veloType>user</veloType>
</Note>
</Chord>
</voice>
</Measure>
</Staff>
</Score>
</museScore>
117 changes: 117 additions & 0 deletions mtest/musicxml/io/testChordSymbols_ref.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
<?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">
<identification>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
<supports element="accidental" type="yes"/>
<supports element="beam" type="yes"/>
<supports element="print" attribute="new-page" type="no"/>
<supports element="print" attribute="new-system" type="no"/>
<supports element="stem" type="yes"/>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name>Voice</part-name>
<part-abbreviation>Vo.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Voice</instrument-name>
</score-instrument>
<midi-device id="P1-I1" port="1"></midi-device>
<midi-instrument id="P1-I1">
<midi-channel>1</midi-channel>
<midi-program>53</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>2</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>
<harmony print-frame="no">
<root>
<root-step>E</root-step>
<root-alter>-1</root-alter>
</root>
<kind text="m" parentheses-degrees="yes">minor</kind>
<bass>
<bass-step>F</bass-step>
</bass>
<degree>
<degree-value>9</degree-value>
<degree-alter>0</degree-alter>
<degree-type>add</degree-type>
</degree>
</harmony>
<note dynamics="88.89">
<pitch>
<step>E</step>
<alter>-1</alter>
<octave>5</octave>
</pitch>
<duration>2</duration>
<tie type="start"/>
<voice>1</voice>
<type>quarter</type>
<accidental>flat</accidental>
<stem>down</stem>
<notations>
<tied type="start"/>
</notations>
</note>
<note dynamics="88.89">
<pitch>
<step>E</step>
<alter>-1</alter>
<octave>5</octave>
</pitch>
<duration>3</duration>
<tie type="stop"/>
<voice>1</voice>
<type>quarter</type>
<dot/>
<stem>down</stem>
<notations>
<tied type="stop"/>
</notations>
</note>
<note>
<rest/>
<duration>1</duration>
<voice>1</voice>
<type>eighth</type>
</note>
<note dynamics="88.89">
<pitch>
<step>A</step>
<alter>-1</alter>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>quarter</type>
<accidental>flat</accidental>
<stem>up</stem>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
1 change: 1 addition & 0 deletions mtest/musicxml/io/tst_mxml_io.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ private slots:
void changeTransposeNoDiatonic() { mxmlIoTestRef("testChangeTranspose-no-diatonic"); }
void chordDiagrams1() { mxmlIoTest("testChordDiagrams1"); }
void chordNoVoice() { mxmlIoTestRef("testChordNoVoice"); }
void chordSymbols() { mxmlMscxExportTestRef("testChordSymbols"); }
void clefs1() { mxmlIoTest("testClefs1"); }
void clefs2() { mxmlIoTest("testClefs2"); }
void completeMeasureRests() { mxmlIoTest("testCompleteMeasureRests"); }
Expand Down

0 comments on commit 7250ef5

Please sign in to comment.