Skip to content

Commit

Permalink
Fix GH#24357: Fix XML import of tied tuplets
Browse files Browse the repository at this point in the history
Backport of musescore#24416
  • Loading branch information
miiizen authored and Jojo-Schmitz committed Sep 4, 2024
1 parent 60d1d05 commit 9ed6fea
Show file tree
Hide file tree
Showing 4 changed files with 291 additions and 1 deletion.
2 changes: 1 addition & 1 deletion importexport/musicxml/importmxmlpass2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7829,7 +7829,7 @@ static void addTie(const Notation& notation, Score* score, Note* note, const int
qInfo() << "endMeasure: " << endChord->measure();
qInfo() << "startChord->tick() + startChord->ticks(): " << (startChord->tick() + startChord->ticks()).toString();
qInfo() << "endChord->tick(): " << endChord->tick().toString();
if (startMeasure == endChord->measure() || startChord->tick() + startChord->ticks() == endChord->tick()) {
if (startMeasure == endChord->measure() || startChord->tick() + startChord->actualTicks() == endChord->tick()) {
// only connect if they're in the same bar, or there are no notes/rests in the same voice between them
qInfo() << "Connect";
currTie->setEndNote(note);
Expand Down
118 changes: 118 additions & 0 deletions mtest/musicxml/io/testTupletTie.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.1 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise version="3.1">
<identification>
<encoding>
<software>MuseScore 3.6.2</software>
<encoding-date>2024-09-01</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>
<part-group type="start" number="1">
<group-symbol>brace</group-symbol>
</part-group>
<score-part id="P1">
<part-name>Piano</part-name>
<part-abbreviation>Pno.</part-abbreviation>
<score-instrument id="P1-I1">
<instrument-name>Piano</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>1</midi-program>
<volume>78.7402</volume>
<pan>0</pan>
</midi-instrument>
</score-part>
</part-list>
<part id="P1">
<measure number="1">
<attributes>
<divisions>3</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>
<note>
<rest/>
<duration>6</duration>
<voice>1</voice>
<type>half</type>
</note>
<note>
<pitch>
<step>D</step>
<alter>1</alter>
<octave>4</octave>
</pitch>
<duration>4</duration>
<voice>1</voice>
<type>half</type>
<accidental>sharp</accidental>
<time-modification>
<actual-notes>3</actual-notes>
<normal-notes>2</normal-notes>
<normal-type>quarter</normal-type>
</time-modification>
<stem>up</stem>
<notations>
<tuplet type="start" bracket="yes"/>
</notations>
</note>
<note>
<pitch>
<step>D</step>
<alter>1</alter>
<octave>4</octave>
</pitch>
<duration>2</duration>
<tie type="start"/>
<voice>1</voice>
<type>quarter</type>
<time-modification>
<actual-notes>3</actual-notes>
<normal-notes>2</normal-notes>
<normal-type>quarter</normal-type>
</time-modification>
<stem>up</stem>
<notations>
<tied type="start"/>
<tuplet type="stop"/>
</notations>
</note>
</measure>
<measure number="2">
<note>
<pitch>
<step>D</step>
<alter>1</alter>
<octave>4</octave>
</pitch>
<duration>12</duration>
<tie type="stop"/>
<voice>1</voice>
<type>whole</type>
<notations>
<tied type="stop"/>
</notations>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
171 changes: 171 additions & 0 deletions mtest/musicxml/io/testTupletTie_ref.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.02">
<Score>
<LayerTag id="0" tag="default"></LayerTag>
<currentLayer>0</currentLayer>
<Division>480</Division>
<Style>
<Spatium>1.74978</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="lyricist"></metaTag>
<metaTag name="movementNumber"></metaTag>
<metaTag name="movementTitle"></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>
<hideWhenEmpty>3</hideWhenEmpty>
</Staff>
<trackName>Piano</trackName>
<Instrument id="piano">
<longName>Piano</longName>
<shortName>Pno.</shortName>
<trackName>Piano</trackName>
<minPitchP>21</minPitchP>
<maxPitchP>108</maxPitchP>
<minPitchA>21</minPitchA>
<maxPitchA>108</maxPitchA>
<instrumentId>keyboard.piano</instrumentId>
<clef staff="2">F</clef>
<Articulation>
<velocity>100</velocity>
<gateTime>95</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>
<program value="0"/>
<controller ctrl="10" value="63"/>
</Channel>
</Instrument>
</Part>
<Staff id="1">
<VBox>
<height>10</height>
</VBox>
<Measure>
<voice>
<Clef>
<concertClefType>G</concertClefType>
<transposingClefType>G</transposingClefType>
</Clef>
<TimeSig>
<sigN>4</sigN>
<sigD>4</sigD>
</TimeSig>
<Rest>
<durationType>half</durationType>
</Rest>
<Tuplet>
<normalNotes>2</normalNotes>
<actualNotes>3</actualNotes>
<baseNote>quarter</baseNote>
<Number>
<style>Tuplet</style>
<text>3</text>
</Number>
</Tuplet>
<Chord>
<durationType>half</durationType>
<StemDirection>up</StemDirection>
<Note>
<Accidental>
<subtype>accidentalSharp</subtype>
</Accidental>
<pitch>63</pitch>
<tpc>23</tpc>
</Note>
</Chord>
<Chord>
<durationType>quarter</durationType>
<StemDirection>up</StemDirection>
<Note>
<Spanner type="Tie">
<Tie>
</Tie>
<next>
<location>
<measures>1</measures>
<fractions>-5/6</fractions>
</location>
</next>
</Spanner>
<pitch>63</pitch>
<tpc>23</tpc>
</Note>
</Chord>
<endTuplet/>
</voice>
</Measure>
<Measure>
<voice>
<Chord>
<durationType>whole</durationType>
<Note>
<Spanner type="Tie">
<prev>
<location>
<measures>-1</measures>
<fractions>5/6</fractions>
</location>
</prev>
</Spanner>
<pitch>63</pitch>
<tpc>23</tpc>
</Note>
</Chord>
<BarLine>
<subtype>end</subtype>
</BarLine>
</voice>
</Measure>
</Staff>
</Score>
</museScore>
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 @@ -327,6 +327,7 @@ private slots:
void tuplets8() { mxmlMscxExportTestRef("testTuplets8"); }
void tuplets9() { mxmlIoTest("testTuplets9"); }
void tuplets10() { mxmlIoTest("testTuplets10"); }
void tupletTie() { mxmlImportTestRef("testTupletTie"); }
void twoNoteTremoloTuplet() { mxmlIoTest("testTwoNoteTremoloTuplet"); }
void uninitializedDivisions() { mxmlIoTestRef("testUninitializedDivisions"); }
void unnecessaryBarlines() { mxmlImportTestRef("testUnnecessaryBarlines"); }
Expand Down

0 comments on commit 9ed6fea

Please sign in to comment.