Skip to content

Commit

Permalink
Merge pull request #18110 from Jojo-Schmitz/musicxml-chord-symbols-bass
Browse files Browse the repository at this point in the history
Fix #320818: Chord symbols with a bass extension don't export to MusicXML correctly (nor import back)
  • Loading branch information
RomanPudashkin committed Jun 22, 2023
2 parents a8d4af4 + 39183b5 commit 7d15ce0
Show file tree
Hide file tree
Showing 4 changed files with 313 additions and 9 deletions.
31 changes: 22 additions & 9 deletions src/importexport/musicxml/internal/musicxml/exportxml.cpp
Expand Up @@ -7758,6 +7758,18 @@ void ExportMusicXml::harmony(Harmony const* const h, FretDiagram const* const fd
s += " parentheses-degrees=\"yes\"";
}
_xml.tagRaw(s, h->xmlKind());

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

StringList l = h->xmlDegrees();
if (!l.empty()) {
for (const String& _tag : qAsConst(l)) {
Expand Down Expand Up @@ -7806,18 +7818,19 @@ void ExportMusicXml::harmony(Harmony const* const h, FretDiagram const* const fd
} else {
_xml.tag("kind", { { "text", h->extensionName() } }, "");
}
}

int baseTpc = h->baseTpc();
if (baseTpc != Tpc::TPC_INVALID) {
_xml.startElement("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.startElement("bass");
_xml.tag("bass-step", tpc2stepName(baseTpc));
alter = int(tpc2alter(baseTpc));
if (alter) {
_xml.tag("bass-alter", alter);
}
_xml.endElement();
}
_xml.endElement();
}

if (offset > 0) {
_xml.tag("offset", offset);
}
Expand Down
171 changes: 171 additions & 0 deletions src/importexport/musicxml/tests/data/testChordSymbols.mscx
@@ -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 src/importexport/musicxml/tests/data/testChordSymbols_ref.xml
@@ -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>
3 changes: 3 additions & 0 deletions src/importexport/musicxml/tests/musicxml_tests.cpp
Expand Up @@ -433,6 +433,9 @@ TEST_F(Musicxml_Tests, chordDiagrams1) {
TEST_F(Musicxml_Tests, chordNoVoice) {
mxmlIoTestRef("testChordNoVoice");
}
TEST_F(Musicxml_Tests, chordSymbols) {
mxmlMscxExportTestRef("testChordSymbols");
}
TEST_F(Musicxml_Tests, clefs1) {
mxmlIoTest("testClefs1");
}
Expand Down

0 comments on commit 7d15ce0

Please sign in to comment.