Skip to content

Commit

Permalink
Fix #318085: [MusicXML export] figuredBass xml export (multiple figur…
Browse files Browse the repository at this point in the history
…es per note)

Backport of musescore#9730
  • Loading branch information
lvinken authored and Jojo-Schmitz committed Nov 28, 2021
1 parent feba735 commit 4f37845
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 11 deletions.
24 changes: 13 additions & 11 deletions importexport/musicxml/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1026,7 +1026,7 @@ static void divideBy(int d)

static void addInteger(int len)
{
if (!integers.contains(len)) {
if (len > 0 && !integers.contains(len)) {
integers.append(len);
}
}
Expand Down Expand Up @@ -1106,22 +1106,24 @@ void ExportMusicXml::calcDivisions()
Measure* m = (Measure*)mb;

for (int st = strack; st < etrack; ++st) {
// sstaff - xml staff number, counting from 1 for this
// instrument
// special number 0 -> don’t show staff number in
// xml output (because there is only one staff)

int sstaff = (staves > 1) ? st - strack + VOICES : 0;
sstaff /= VOICES;

for (Segment* seg = m->first(); seg; seg = seg->next()) {
for (const Element* e : seg->annotations()) {
if (e->track() == st && e->type() == ElementType::FIGURED_BASS) {
const FiguredBass* fb = toFiguredBass(e);
#ifdef DEBUG_TICK
qDebug("figuredbass tick %d duration %d", fb->tick().ticks(), fb->ticks().ticks());
#endif
addInteger(fb->ticks().ticks());
}
}


Element* el = seg->element(st);
if (!el)
continue;

// must ignore start repeat to prevent spurious backup/forward
if (el->type() == ElementType::BAR_LINE && static_cast<BarLine*>(el)->barLineType() == BarLineType::START_REPEAT)
if (el->type() == ElementType::BAR_LINE && toBarLine(el)->barLineType() == BarLineType::START_REPEAT)
continue;

if (_tick != seg->tick())
Expand All @@ -1134,7 +1136,7 @@ void ExportMusicXml::calcDivisions()
l = l * Fraction(1,2);
}
#ifdef DEBUG_TICK
qDebug("chordrest %d", l);
qDebug("chordrest tick %d duration %d", _tick.ticks(), l.ticks());
#endif
addInteger(l.ticks());
_tick += l;
Expand Down
79 changes: 79 additions & 0 deletions mtest/musicxml/io/testFiguredBassDivisions.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<?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">
<work>
<work-number>MuseScore testfile</work-number>
<work-title>Figured Bass Divisions</work-title>
</work>
<identification>
<creator type="composer">Leon Vinken</creator>
<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>1</beats>
<beat-type>4</beat-type>
</time>
<clef>
<sign>G</sign>
<line>2</line>
</clef>
</attributes>
<figured-bass>
<figure>
<figure-number>1</figure-number>
</figure>
<duration>1</duration>
</figured-bass>
<figured-bass>
<figure>
<figure-number>2</figure-number>
</figure>
<duration>1</duration>
</figured-bass>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>quarter</type>
<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 @@ -123,6 +123,7 @@ private slots:
void figuredBass1() { mxmlIoTest("testFiguredBass1"); }
void figuredBass2() { mxmlIoTest("testFiguredBass2"); }
void figuredBass3() { mxmlIoTest("testFiguredBass3"); }
void figuredBassDivisions() { mxmlIoTest("testFiguredBassDivisions"); }
// void formattedThings() { mxmlIoTest("testFormattedThings"); }
void fractionMinus() { mxmlIoTestRef("testFractionMinus"); }
void fractionPlus() { mxmlIoTestRef("testFractionPlus"); }
Expand Down

0 comments on commit 4f37845

Please sign in to comment.