Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
lvinken committed Feb 26, 2013
1 parent 6eabaf5 commit 13e10a6
Show file tree
Hide file tree
Showing 8 changed files with 441 additions and 7 deletions.
16 changes: 12 additions & 4 deletions mscore/importxml.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1964,12 +1964,13 @@ Measure* MusicXml::xmlMeasure(Part* part, QDomElement e, int number, int measure
if (implicit == "yes")
measure->setIrregular(true);

int cv = 0; // current voice for chords, default is 0

for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
if (e.tagName() == "attributes")
xmlAttributes(measure, staff, e.firstChildElement());
else if (e.tagName() == "note") {
xmlNote(measure, staff, part->id(), beam, e);
xmlNote(measure, staff, part->id(), beam, cv, e);
moveTick(measure->tick(), tick, maxtick, noteTypeTickFr, divisions, e);
#ifdef DEBUG_TICK
qDebug(" after inserting note tick=%d", tick);
Expand Down Expand Up @@ -4424,7 +4425,7 @@ static FiguredBass* findLastFiguredBass(int track, Segment* seg)
\a Staff is the number of first staff of the part this note belongs to.
*/

void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*& beam, QDomElement e)
void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*& beam, int& currentVoice, QDomElement e)
{
int ticks = 0;
#ifdef DEBUG_TICK
Expand All @@ -4433,8 +4434,8 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
QDomNode pn = e; // TODO remove pn
QDomElement org_e = e; // save e for later
QDomElement domElemNotations;
voice = 0;
move = 0;
int voice = 0;
int move = 0;

bool rest = false;
int relStaff = 0;
Expand Down Expand Up @@ -4480,6 +4481,13 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
// silently ignore others (will be handled later)
}

// Bug fix for Sibelius 7.1.3 which does not write <voice> for notes with <chord>
if (!chord)
// remember voice
currentVoice = voice;
else
// use voice from last note w/o <chord>
voice = currentVoice;

// Musicxml voices are counted for all staffs of an
// instrument. They are not limited. In mscore voices are associated
Expand Down
4 changes: 1 addition & 3 deletions mscore/musicxml.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,6 @@ class MusicXml {
TextLine* dashes[MAX_DASHES];

Tie* tie;
int voice;
int move;
Volta* lastVolta;

QDomDocument* doc;
Expand Down Expand Up @@ -228,7 +226,7 @@ class MusicXml {
QMap<int, Lyrics*>& defyLyrics,
QList<Lyrics*>& unNumbrdLyrics);
void xmlNotations(Note* note, ChordRest* cr, int trk, int ticks, QDomElement node);
void xmlNote(Measure*, int stave, const QString& partId, Beam*& beam, QDomElement node);
void xmlNote(Measure*, int stave, const QString& partId, Beam*& beam, int& currentVoice, QDomElement node);
void xmlHarmony(QDomElement node, int tick, Measure* m, int staff);
int xmlClef(QDomElement, int staffIdx, Measure*);

Expand Down
109 changes: 109 additions & 0 deletions mtest/musicxml/io/testChordNoVoice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
<work>
<work-number>MuseScore testfile</work-number>
<work-title>Chord (no voice)</work-title>
</work>
<identification>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
</encoding>
<miscellaneous>
<miscellaneous-field name="description">
Sibelius 7.1.3 leaves out the voice element for notes with a chord flag.
In this case, don't assume a missing voice means voice 1, but simply
attach the note to the previous note or chord.
</miscellaneous-field>
</miscellaneous>
</identification>
<part-list>
<score-part id="P1">
<part-name></part-name>
<score-instrument id="P1-I3">
<instrument-name></instrument-name>
</score-instrument>
<midi-instrument id="P1-I3">
<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>1</divisions>
<key>
<fifths>0</fifths>
<mode>major</mode>
</key>
<time>
<beats>1</beats>
<beat-type>4</beat-type>
</time>
<staves>2</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<chord/>
<pitch>
<step>G</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<backup>
<duration>1</duration>
</backup>
<note>
<pitch>
<step>G</step>
<octave>2</octave>
</pitch>
<duration>1</duration>
<voice>5</voice>
<type>quarter</type>
<stem>up</stem>
<staff>2</staff>
</note>
<note>
<chord/>
<pitch>
<step>G</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<type>quarter</type>
<stem>up</stem>
<staff>2</staff>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
104 changes: 104 additions & 0 deletions mtest/musicxml/io/testChordNoVoice_ref.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
<work>
<work-number>MuseScore testfile</work-number>
<work-title>Chord (no voice)</work-title>
</work>
<identification>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
</encoding>
</identification>
<part-list>
<score-part id="P1">
<part-name></part-name>
<score-instrument id="P1-I3">
<instrument-name></instrument-name>
</score-instrument>
<midi-instrument id="P1-I3">
<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>1</divisions>
<key>
<fifths>0</fifths>
<mode>major</mode>
</key>
<time>
<beats>1</beats>
<beat-type>4</beat-type>
</time>
<staves>2</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<chord/>
<pitch>
<step>G</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<backup>
<duration>1</duration>
</backup>
<note>
<pitch>
<step>G</step>
<octave>2</octave>
</pitch>
<duration>1</duration>
<voice>5</voice>
<type>quarter</type>
<stem>up</stem>
<staff>2</staff>
</note>
<note>
<chord/>
<pitch>
<step>G</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<voice>5</voice>
<type>quarter</type>
<stem>up</stem>
<staff>2</staff>
</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 @@ -52,6 +52,7 @@ private slots:
void arpGliss2() { mxmlIoTest("testArpGliss2"); }
void barStyles() { mxmlIoTest("testBarStyles"); }
void chordDiagrams1() { mxmlIoTest("testChordDiagrams1"); }
void chordNoVoice() { mxmlIoTestRef("testChordNoVoice"); }
void clefs1() { mxmlIoTest("testClefs1"); }
void completeMeasureRests() { mxmlIoTest("testCompleteMeasureRests"); }
void dalSegno() { mxmlIoTest("testDalSegno"); }
Expand Down
109 changes: 109 additions & 0 deletions test/musicxml/testChordNoVoice.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE score-partwise PUBLIC "-//Recordare//DTD MusicXML 3.0 Partwise//EN" "http://www.musicxml.org/dtds/partwise.dtd">
<score-partwise>
<work>
<work-number>MuseScore testfile</work-number>
<work-title>Chord (no voice)</work-title>
</work>
<identification>
<encoding>
<software>MuseScore 0.7.0</software>
<encoding-date>2007-09-10</encoding-date>
</encoding>
<miscellaneous>
<miscellaneous-field name="description">
Sibelius 7.1.3 leaves out the voice element for notes with a chord flag.
In this case, don't assume a missing voice means voice 1, but simply
attach the note to the previous note or chord.
</miscellaneous-field>
</miscellaneous>
</identification>
<part-list>
<score-part id="P1">
<part-name></part-name>
<score-instrument id="P1-I3">
<instrument-name></instrument-name>
</score-instrument>
<midi-instrument id="P1-I3">
<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>1</divisions>
<key>
<fifths>0</fifths>
<mode>major</mode>
</key>
<time>
<beats>1</beats>
<beat-type>4</beat-type>
</time>
<staves>2</staves>
<clef number="1">
<sign>G</sign>
<line>2</line>
</clef>
<clef number="2">
<sign>F</sign>
<line>4</line>
</clef>
</attributes>
<note>
<pitch>
<step>G</step>
<octave>4</octave>
</pitch>
<duration>1</duration>
<voice>1</voice>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<note>
<chord/>
<pitch>
<step>G</step>
<octave>5</octave>
</pitch>
<duration>1</duration>
<type>quarter</type>
<stem>up</stem>
<staff>1</staff>
</note>
<backup>
<duration>1</duration>
</backup>
<note>
<pitch>
<step>G</step>
<octave>2</octave>
</pitch>
<duration>1</duration>
<voice>5</voice>
<type>quarter</type>
<stem>up</stem>
<staff>2</staff>
</note>
<note>
<chord/>
<pitch>
<step>G</step>
<octave>3</octave>
</pitch>
<duration>1</duration>
<type>quarter</type>
<stem>up</stem>
<staff>2</staff>
</note>
<barline location="right">
<bar-style>light-heavy</bar-style>
</barline>
</measure>
</part>
</score-partwise>
Loading

0 comments on commit 13e10a6

Please sign in to comment.