From 103308867659fd31e18f451af3155597747a164f Mon Sep 17 00:00:00 2001 From: Leon Vinken Date: Wed, 3 Sep 2014 22:00:27 +0200 Subject: [PATCH 1/2] fix MusicXML import of pedal type change --- mscore/importxml.cpp | 10 +++++++++- mscore/musicxml.h | 1 + 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/mscore/importxml.cpp b/mscore/importxml.cpp index 859f3034dbc9b..63f35c4338cb7 100644 --- a/mscore/importxml.cpp +++ b/mscore/importxml.cpp @@ -733,6 +733,7 @@ void MusicXml::import(Score* s) ottava = 0; trill = 0; pedal = 0; + pedalContinue = 0; harmony = 0; tremStart = 0; hairpin = 0; @@ -2930,9 +2931,9 @@ void MusicXml::direction(Measure* measure, int staff, QDomElement e) else if (type == "change") { // pedal change is implemented as two separate pedals // first stop the first one - // TODO: this is not yet correct, the spanner must be stopped after the NEXT note pedal->setEndHookType(HookType::HOOK_45); handleSpannerStop(pedal, "pedal", tick, spanners); + pedalContinue = pedal; // mark for later fixup pedal = 0; // then start a new one pedal = static_cast(checkSpannerOverlap(pedal, new Pedal(score), "pedal")); @@ -5235,6 +5236,13 @@ Note* MusicXml::xmlNote(Measure* measure, int staff, const QString& partId, Beam } figBassExtend = false; + // fixup pedal type="change" to end at the end of this note + // note tick is still at note start + if (pedalContinue) { + handleSpannerStop(pedalContinue, "pedal", tick + ticks, spanners); + pedalContinue = 0; + } + if (!chord) prevtick = tick; // remember tick where last chordrest was inserted diff --git a/mscore/musicxml.h b/mscore/musicxml.h index 638837dd98186..bce488ec3fbf9 100644 --- a/mscore/musicxml.h +++ b/mscore/musicxml.h @@ -182,6 +182,7 @@ class MusicXml { Ottava* ottava; ///< Current ottava Trill* trill; ///< Current trill Pedal* pedal; ///< Current pedal + Pedal* pedalContinue; ///< Current pedal type="change" requiring fixup Harmony* harmony; ///< Current harmony Hairpin* hairpin; ///< Current hairpin (obsoletes wedgelist) Chord* tremStart; ///< Starting chord for current tremolo From aafac2efdc0933f32fdfef0a8c38715b66fed2ec Mon Sep 17 00:00:00 2001 From: Leon Vinken Date: Tue, 9 Sep 2014 21:54:11 +0200 Subject: [PATCH 2/2] fix #32026 and #32691 --- mscore/importxml.cpp | 50 +++++++++++++++++++++++++++++--------------- mscore/musicxml.h | 1 + 2 files changed, 34 insertions(+), 17 deletions(-) diff --git a/mscore/importxml.cpp b/mscore/importxml.cpp index 63f35c4338cb7..23054dd0eb786 100644 --- a/mscore/importxml.cpp +++ b/mscore/importxml.cpp @@ -723,6 +723,36 @@ void MusicXml::import(Score* s) { tupletAssert(); score = s; + + // TODO only if multi-measure rests used ??? + // score->style()->set(StyleIdx::createMultiMeasureRests, true); + + for (QDomElement e = doc->documentElement(); !e.isNull(); e = e.nextSiblingElement()) { + if (e.tagName() == "score-partwise") + scorePartwise(e.firstChildElement()); + else + domError(e); + } + } + +//--------------------------------------------------------- +// initPartState +//--------------------------------------------------------- + +/** + Initialize members as required for reading the MusicXML part element. + TODO: factor out part reading into a separate + */ + +void MusicXml::initPartState() + { + fractionTSig = Fraction(0, 1); + tick = 0; + maxtick = 0; + prevtick = 0; + lastMeasureLen = 0; + multiMeasureRestCount = -1; + startMultiMeasureRest = false; tie = 0; for (int i = 0; i < MAX_NUMBER_LEVEL; ++i) slur[i] = 0; @@ -739,16 +769,6 @@ void MusicXml::import(Score* s) hairpin = 0; figBass = 0; figBassExtend = false; - - // TODO only if multi-measure rests used ??? - // score->style()->set(StyleIdx::createMultiMeasureRests, true); - - for (QDomElement e = doc->documentElement(); !e.isNull(); e = e.nextSiblingElement()) { - if (e.tagName() == "score-partwise") - scorePartwise(e.firstChildElement()); - else - domError(e); - } } //--------------------------------------------------------- @@ -1714,13 +1734,9 @@ void MusicXml::xmlPart(QDomElement e, QString id) qDebug("Import MusicXml:xmlPart: cannot find part %s", id.toLatin1().data()); return; } - fractionTSig = Fraction(0, 1); - tick = 0; - maxtick = 0; - prevtick = 0; - lastMeasureLen = 0; - multiMeasureRestCount = -1; - startMultiMeasureRest = false; + + initPartState(); + KeySigEvent ev; KeySig currKeySig; currKeySig.setKeySigEvent(ev); diff --git a/mscore/musicxml.h b/mscore/musicxml.h index bce488ec3fbf9..38150e86a2f7c 100644 --- a/mscore/musicxml.h +++ b/mscore/musicxml.h @@ -216,6 +216,7 @@ class MusicXml { void readPageFormat(PageFormat* pf, QDomElement de, qreal conversion); QList findSlurElements(QDomElement); void addGraceNoteAfter(Chord*, Segment*); + void initPartState(); public: MusicXml(QDomDocument* d, MxmlReaderFirstPass const& p1); void import(Score*);