Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lvinken committed Aug 13, 2012
1 parent 211d812 commit 8f6b31d
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 13 deletions.
24 changes: 12 additions & 12 deletions mscore/exportxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1291,25 +1291,25 @@ void ExportMusicXml::timesig(TimeSig* tsig)
{
int st = tsig->subtype();
Fraction ts = tsig->sig();
int z1 = ts.numerator();
int n = ts.denominator();
if (st == TSIG_ALLA_BREVE) {
// MuseScore calls this 2+2/4, MusicXML 2/2
n = 2;
//z2 = 0;
}
int z = ts.numerator();
int n = ts.denominator();
QString ns = tsig->numeratorString();

attr.doAttr(xml, true);
if (st == TSIG_FOUR_FOUR)
xml.stag("time symbol=\"common\"");
else if (st == TSIG_ALLA_BREVE)
xml.stag("time symbol=\"cut\"");
else
xml.stag("time");
QString z = QString("%1").arg(z1);
// if (z2) z += QString("+%1").arg(z2); // TODO TS
// if (z3) z += QString("+%1").arg(z3);
// if (z4) z += QString("+%1").arg(z4);
xml.tag("beats", z);

QRegExp rx("^\\d+(\\+\\d+)+$"); // matches a compound numerator
if (rx.exactMatch(ns))
// if compound numerator, exported as is
xml.tag("beats", ns);
else
// else fall back and use the numerator as integer
xml.tag("beats", z);
xml.tag("beat-type", n);
xml.etag();
}
Expand Down
3 changes: 2 additions & 1 deletion mscore/importxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -276,8 +276,9 @@ static Fraction calculateFraction(QString type, int dots, int normalNotes, int a
Fraction f = noteTypeToFraction(type);
if (f.isValid()) {
// dot(s)
Fraction f_no_dots = f;
for (int i = 0; i < dots; ++i)
f += (f / (2 << i));
f += (f_no_dots / (2 << i));
// tuplet
if (actualNotes > 0 && normalNotes > 0) {
f *= normalNotes;
Expand Down
24 changes: 24 additions & 0 deletions test/musicxml/testNotesRests2.xml
Original file line number Diff line number Diff line change
Expand Up @@ -375,6 +375,30 @@
<voice>1</voice>
<type>half</type>
</note>
</measure>
<measure number="5">
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>14</duration>
<voice>1</voice>
<type>half</type>
<dot/>
<dot/>
<stem>up</stem>
</note>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>2</duration>
<voice>1</voice>
<type>eighth</type>
<stem>up</stem>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
Expand Down

0 comments on commit 8f6b31d

Please sign in to comment.