Permalink
Browse files

fix #23852, #24232 and #24234

  • Loading branch information...
1 parent 2902cf6 commit 5ac3daa429220942cf87ec0495eca7a7dcd1b6bf @lvinken lvinken committed Jan 12, 2014
View
@@ -3,7 +3,7 @@
// Linux Music Score Editor
// $Id: importxml.cpp 5653 2012-05-19 20:19:58Z lvinken $
//
-// Copyright (C) 2002-2013 Werner Schweer and others
+// Copyright (C) 2002-2014 Werner Schweer and others
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License version 2.
@@ -409,7 +409,6 @@ MusicXml::MusicXml(QDomDocument* d, MxmlReaderFirstPass const& p1)
lastVolta(0),
doc(d),
pass1(p1),
- maxLyrics(0),
beamMode(BeamMode::NONE),
pageWidth(0),
pageHeight(0)
@@ -657,7 +656,7 @@ Score::FileError importMusicXml(Score* score, const QString& name)
QFile xmlFile(name);
if (!xmlFile.exists())
return Score::FILE_NOT_FOUND;
- if (!xmlFile.open(QIODevice::ReadOnly | QIODevice::Text)) {
+ if (!xmlFile.open(QIODevice::ReadOnly)) {
qDebug("importMusicXml() could not open MusicXML file '%s'", qPrintable(name));
MScore::lastError = QT_TRANSLATE_NOOP("file", "could not open MusicXML file\n");
return Score::FILE_OPEN_ERROR;
@@ -1312,21 +1311,19 @@ void MusicXml::scorePartwise(QDomElement ee)
// partGroupStart
//---------------------------------------------------------
+typedef std::map<int,MusicXmlPartGroup*> MusicXmlPartGroupMap;
+
/**
Store part-group start with number \a n, first part \a p and symbol / \a s in the partGroups
- array for later reference, as at this time insufficient information is available to be able
+ map \a pgs for later reference, as at this time insufficient information is available to be able
to generate the brackets.
*/
-static void partGroupStart(MusicXmlPartGroup* (&pgs)[MAX_PART_GROUPS], int n, int p, QString s, bool barlineSpan)
+static void partGroupStart(MusicXmlPartGroupMap& pgs, int n, int p, QString s, bool barlineSpan)
{
// qDebug("partGroupStart number=%d part=%d symbol=%s\n", n, p, s.toLatin1().data());
- if (n < 0 || n >= MAX_PART_GROUPS) {
- qDebug("illegal part-group number: %d", n);
- return;
- }
- if (pgs[n]) {
+ if (pgs.count(n) > 0) {
qDebug("part-group number=%d already active", n);
return;
}
@@ -1368,16 +1365,10 @@ static void partGroupStart(MusicXmlPartGroup* (&pgs)[MAX_PART_GROUPS], int n, in
To generate brackets, the span in staves must also be known.
*/
-static void partGroupStop(MusicXmlPartGroup* (&pgs)[MAX_PART_GROUPS], int n, int p,
- std::vector<MusicXmlPartGroup*>& pgl)
+static void partGroupStop(MusicXmlPartGroupMap& pgs, int n, int p,
+ MusicXmlPartGroupList& pgl)
{
- // qDebug("partGroupStop number=%d part=%d\n", n, p);
- if (n < 0 || n >= MAX_PART_GROUPS) {
- qDebug("illegal part-group number: %d", n);
- return;
- }
-
- if (!pgs[n]) {
+ if (pgs.count(n) == 0) {
qDebug("part-group number=%d not active", n);
return;
}
@@ -1386,7 +1377,7 @@ static void partGroupStop(MusicXmlPartGroup* (&pgs)[MAX_PART_GROUPS], int n, int
// qDebug("part-group number=%d start=%d span=%d type=%d",
// n, pgs[n]->start, pgs[n]->span, pgs[n]->type);
pgl.push_back(pgs[n]);
- pgs[n] = 0;
+ pgs.erase(n);
}
//---------------------------------------------------------
@@ -1401,9 +1392,7 @@ void MusicXml::xmlPartList(QDomElement e)
{
int scoreParts = 0;
bool barlineSpan = false;
- MusicXmlPartGroup* partGroups[MAX_PART_GROUPS];
- for (int i = 0; i < MAX_PART_GROUPS; ++i)
- partGroups[i] = 0;
+ MusicXmlPartGroupMap partGroups;
for (; !e.isNull(); e = e.nextSiblingElement()) {
if (e.tagName() == "score-part")
@@ -1507,7 +1496,9 @@ void MusicXml::xmlScorePart(QDomElement e, QString id, int& parts)
else if (e.tagName() == "midi-instrument") {
QString instrId = e.attribute("id");
for (QDomElement ee = e.firstChildElement(); !ee.isNull(); ee = ee.nextSiblingElement()) {
- if (ee.tagName() == "midi-channel")
+ if (ee.tagName() == "midi-bank")
+ domNotImplemented(e);
+ else if (ee.tagName() == "midi-channel")
part->setMidiChannel(ee.text().toInt() - 1);
else if (ee.tagName() == "midi-program")
part->setMidiProgram(ee.text().toInt() - 1);
@@ -4150,7 +4141,7 @@ void MusicXml::xmlNotations(Note* note, ChordRest* cr, int trk, int ticks, QDomE
qDebug("unknown slur type %s", qPrintable(slurType));
}
else
- qDebug("ignoring duplicate '%s'", qPrintable(slurId));
+ qDebug("ignoring duplicate slur '%s'", qPrintable(slurId));
}
else if (ee.tagName() == "tied") {
@@ -4494,7 +4485,6 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
#endif
QDomNode pn = e; // TODO remove pn
QDomElement org_e = e; // save e for later
- QDomElement domElemNotations;
QString strVoice = "1";
int voice = 0;
int move = 0;
@@ -4521,6 +4511,7 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
int velocity = -1;
bool unpitched = false;
QString instrId;
+ QList<QDomElement> notations;
// first read all elements required for voice mapping
QDomElement e2 = e.firstChildElement();
@@ -4717,7 +4708,8 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
}
else if (tag == "notations") {
// save the QDomElement representing <notations> for later
- domElemNotations = e;
+ // note that multiple notations elements may be present
+ notations << e;
}
else if (tag == "tie") {
QString tieType = e.attribute(QString("type"));
@@ -4967,8 +4959,9 @@ void MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam*
xmlTuplet(tuplets[voice + relStaff * VOICES], cr, ticks, org_e);
}
- if (!domElemNotations.isNull())
- xmlNotations(note, cr, trk, ticks, domElemNotations);
+ foreach(QDomElement de, notations) {
+ xmlNotations(note, cr, trk, ticks, de);
+ }
// add lyrics found by xmlLyric
addLyrics(cr, numberedLyrics, defaultyLyrics, unNumberedLyrics);
View
@@ -146,6 +146,8 @@ struct GraceNoteInfo {
// MusicXml
//---------------------------------------------------------
+typedef std::vector<MusicXmlPartGroup*> MusicXmlPartGroupList;
+
/**
The MusicXML importer.
*/
@@ -174,15 +176,13 @@ class MusicXml {
int multiMeasureRestCount; ///< Remaining measures in a multi measure rest
bool startMultiMeasureRest; ///< Multi measure rest started in this measure
- int maxLyrics;
-
int divisions; ///< Current MusicXML divisions
QVector<Tuplet*> tuplets; ///< Current tuplet for each track in the current part
CreditWordsList credits;
JumpMarkerDescList jumpsMarkers;
- std::vector<MusicXmlPartGroup*> partGroupList;
+ MusicXmlPartGroupList partGroupList;
QMap<Spanner*, QPair<int, int> > spanners;
Ottava* ottava; ///< Current ottava
@@ -0,0 +1,116 @@
+<?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>Multiple notations</work-title>
+ </work>
+ <identification>
+ <creator type="composer">Leon Vinken</creator>
+ <encoding>
+ <software>MuseScore 0.7.0</software>
+ <encoding-date>2007-09-10</encoding-date>
+ </encoding>
+ <miscellaneous>
+ <miscellaneous-field name="description">
+ Test multiple notations elements within a note.
+
+ PriMus Music-Notation by Columbussoft (build 13055) generates this,
+ leading to slur issues.
+ </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>74</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>4</beats>
+ <beat-type>4</beat-type>
+ </time>
+ <clef>
+ <sign>G</sign>
+ <line>2</line>
+ </clef>
+ </attributes>
+ <note>
+ <pitch>
+ <step>F</step>
+ <octave>4</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ <stem>up</stem>
+ <notations>
+ <slur type="start" number="1"/>
+ </notations>
+ </note>
+ <note>
+ <pitch>
+ <step>A</step>
+ <octave>4</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ <stem>up</stem>
+ <notations>
+ <slur type="stop" number="1"/>
+ </notations>
+ <notations>
+ <articulations>
+ <staccato/>
+ </articulations>
+ </notations>
+ </note>
+ <note>
+ <pitch>
+ <step>C</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ <stem>up</stem>
+ <notations>
+ <slur type="start" number="1"/>
+ </notations>
+ </note>
+ <note>
+ <pitch>
+ <step>E</step>
+ <octave>5</octave>
+ </pitch>
+ <duration>1</duration>
+ <voice>1</voice>
+ <type>quarter</type>
+ <stem>up</stem>
+ <notations>
+ <slur type="stop" number="1"/>
+ </notations>
+ </note>
+ <barline location="right">
+ <bar-style>light-heavy</bar-style>
+ </barline>
+ </measure>
+ </part>
+ </score-partwise>
Oops, something went wrong.

0 comments on commit 5ac3daa

Please sign in to comment.