From e7cfc20f4cbad956caf4fe1610188a6f043c4d67 Mon Sep 17 00:00:00 2001 From: Leon Vinken Date: Tue, 30 Apr 2013 16:49:15 +0200 Subject: [PATCH] fix #20906 --- mscore/capella.cpp | 36 ++-- mtest/capella/io/iotest | 48 ++++++ mtest/capella/io/testTuplet1.capx | Bin 0 -> 629 bytes mtest/capella/io/testTuplet1.capx-ref.mscx | 187 +++++++++++++++++++++ mtest/capella/io/tst_capella_io.cpp | 21 +-- 5 files changed, 272 insertions(+), 20 deletions(-) create mode 100755 mtest/capella/io/iotest create mode 100644 mtest/capella/io/testTuplet1.capx create mode 100644 mtest/capella/io/testTuplet1.capx-ref.mscx diff --git a/mscore/capella.cpp b/mscore/capella.cpp index 6a70d39aa2..6770ffe31e 100644 --- a/mscore/capella.cpp +++ b/mscore/capella.cpp @@ -283,13 +283,12 @@ static int readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, int tick, else qDebug("Capella: unknown tuplet"); tuplet->setRatio(f); - tuplet->setBaseLen(d); + tuplet->setBaseLen(d); // TODO check if necessary (the MusicXML importer doesn't do this) tuplet->setTrack(track); tuplet->setTick(tick); - // tuplet->setParent(m); + tuplet->setParent(m); int nn = ((tupletCount * ticks) * f.denominator()) / f.numerator(); - tuplet->setDuration(Fraction::fromTicks(nn)); - m->add(tuplet); + tuplet->setDuration(Fraction::fromTicks(nn)); // TODO check if necessary (the MusicXML importer doesn't do this) } } @@ -311,6 +310,10 @@ static int readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, int tick, if (!o->invisible || voice == 0) { Segment* s = m->getSegment(Segment::SegChordRest, tick); Rest* rest = new Rest(score); + if (tuplet) { + rest->setTuplet(tuplet); + tuplet->add(rest); + } TDuration d; if (o->fullMeasures) { d.setType(TDuration::V_MEASURE); @@ -326,7 +329,18 @@ static int readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, int tick, s->add(rest); processBasicDrawObj(o->objects, s, track); } - tick += ticks; + + if (tuplet) { + if (++nTuplet >= tupletCount) { + tick = tupletTick + tuplet->actualTicks(); + tuplet = 0; + } + else { + tick += (ticks * tuplet->ratio().denominator()) / tuplet->ratio().numerator(); + } + } + else + tick += ticks; } break; case T_CHORD: @@ -357,13 +371,12 @@ static int readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, int tick, else qDebug("Capella: unknown tuplet"); tuplet->setRatio(f); - tuplet->setBaseLen(d); + tuplet->setBaseLen(d); // TODO check if necessary (the MusicXML importer doesn't do this) tuplet->setTrack(track); tuplet->setTick(tick); - // tuplet->setParent(m); + tuplet->setParent(m); int nn = ((tupletCount * ticks) * f.denominator()) / f.numerator(); - tuplet->setDuration(Fraction::fromTicks(nn)); - m->add(tuplet); + tuplet->setDuration(Fraction::fromTicks(nn)); // TODO check if necessary (the MusicXML importer doesn't do this) } qDebug("Tuplet at %d: count: %d tri: %d prolonging: %d ticks %d objects %d", tick, o->count, o->tripartite, o->isProlonging, ticks, @@ -371,7 +384,10 @@ static int readCapVoice(Score* score, CapVoice* cvoice, int staffIdx, int tick, } Chord* chord = new Chord(score); - chord->setTuplet(tuplet); + if (tuplet) { + chord->setTuplet(tuplet); + tuplet->add(chord); + } if (isgracenote) { // grace notes SetCapGraceDuration(chord,o); chord->setDuration(chord->durationType().fraction()); diff --git a/mtest/capella/io/iotest b/mtest/capella/io/iotest new file mode 100755 index 0000000000..5b6b7106ba --- /dev/null +++ b/mtest/capella/io/iotest @@ -0,0 +1,48 @@ +#!/bin/bash + +# simple standalone iotest for Capella import +# run mtest/capella/io directory as "./iotest" +# note that the debug build must be used with the -t option to get the beams right in the .mscx files + +MSCORE=../../../build.debug/mscore/mscore + +echo "---------------------------------------------" +echo "Regression Tests for MuseScore Capella import" +echo "---------------------------------------------" +echo +$MSCORE -v +echo + +capfiles=`cat tst_capella_io.cpp | grep "{ capReadTest" | awk -F\" '{print $2}' | sort` +capxfiles=`cat tst_capella_io.cpp | grep "{ capxReadTest" | awk -F\" '{print $2}' | sort` +testcount=0 +failures=0 + +captest() { + echo -n "testing load/save $1$2"; + $MSCORE -t $1$2 -o mops.mscx &> /dev/null + if diff -q $1$2-ref.mscx mops.mscx &> /dev/null; then + echo -e "\r\t\t\t\t\t\t...OK"; + else + echo -e "\r\t\t\t\t\t\t...FAILED"; + failures=$(($failures+1)); + echo "+++++++++DIFF++++++++++++++" + diff $1$2-ref.mscx mops.mscx + echo "+++++++++++++++++++++++++++" + fi + rm mops.mscx + testcount=$(($testcount+1)) + } + +echo "Capella files ..." +for f in $capfiles; do + captest ${f} .cap +done + +echo "CapellaXML files ..." +for f in $capxfiles; do + captest ${f} .capx +done + +echo +echo "$testcount test(s), $failures failure(s)" diff --git a/mtest/capella/io/testTuplet1.capx b/mtest/capella/io/testTuplet1.capx new file mode 100644 index 0000000000000000000000000000000000000000..98f5d5bc6026323b49878fda540f5668744ffc36 GIT binary patch literal 629 zcmWIWW@Zs#U|`^2*qS)cDVryEot$2mlbAZ}`GC7U? zD^iT--kAUU&?~1U30~LkryqV8{I1Q(z(#E1+2CW@&(H5IS>&WLWn*E3^>m4)QEI~B zj=PI{PyX^qQ4Fzk4)U5fDMhA&X$L(B{Zk-GUX&oc&vz6 zZ?$4$-(j}C*6JBYbRJ7e8BD%-?CUO1Db`yO5jU17YAa|6P3vdAv-_5+>?IR5(LZLTW`mRTbq{5yC)a8Vjus9zs~ks zmhGSR8TL-v4t(D^dJj(d-?06IU0hqhr47b)m#;ef@GXDx{v`9SyoD*%qTQ2XELTr| z?6FoZ{KbT;QcqW + + + + 0 + 480 + + 1 + 1 + 1 + 0 + + + + + + + + + + + + + + + + + 0 + + + + + +


+
+ + +


+
+ + + + +
+
+ + + 14 + + + + G + G + + + quarter + + 60 + 14 + + + + 7 + 7 + + + 2 + 3 + eighth + + + 3 + + + + 1 + eighth + 1 + + 62 + 16 + + + + 1 + eighth + 1 + + 62 + 16 + + + + 1 + eighth + 1 + + 62 + 16 + + + + quarter + + 64 + 18 + + + + + + line + 3 + + + quarter + + 60 + 14 + + + + 2 + 3 + eighth + + + 3 + + + + 2 + eighth + + 62 + 16 + + + + 2 + eighth + + + 2 + eighth + + 62 + 16 + + + + quarter + + 64 + 18 + + + + +
+
diff --git a/mtest/capella/io/tst_capella_io.cpp b/mtest/capella/io/tst_capella_io.cpp index 9b70624ad7..c2ce09a260 100644 --- a/mtest/capella/io/tst_capella_io.cpp +++ b/mtest/capella/io/tst_capella_io.cpp @@ -40,21 +40,22 @@ private slots: void capTest1() { capReadTest("test1"); } void capTest2() { capReadTest("test2"); } - // void capTest3() { capReadTest("test3"); } generates spurious natural accidental - // void capTest4() { capReadTest("test4"); } generates spurious natural accidental - // void capTest5() { capReadTest("test5"); } generates spurious natural accidental - // void capTest6() { capReadTest("test6"); } generates spurious natural accidental - // void capTest7() { capReadTest("test7"); } generates different (incorrect ?) l1 and l2 values in beams + // void capTest3() { capReadTest("test3"); } // generates spurious natural accidental + // void capTest4() { capReadTest("test4"); } // generates spurious natural accidental + // void capTest5() { capReadTest("test5"); } // generates spurious natural accidental + // void capTest6() { capReadTest("test6"); } // generates spurious natural accidental + // void capTest7() { capReadTest("test7"); } // generates different (incorrect ?) l1 and l2 values in beams void capTest8() { capReadTest("test8"); } void capxTest1() { capxReadTest("test1"); } void capxTest2() { capxReadTest("test2"); } - // void capxTest3() { capxReadTest("test3"); } generates spurious natural accidental - // void capxTest4() { capxReadTest("test4"); } generates spurious natural accidental - // void capxTest5() { capxReadTest("test5"); } generates spurious natural accidental - // void capxTest6() { capxReadTest("test6"); } generates spurious natural accidental - // void capxTest7() { capxReadTest("test7"); } generates different (incorrect ?) l1 and l2 values in beams + // void capxTest3() { capxReadTest("test3"); } // generates spurious natural accidental + // void capxTest4() { capxReadTest("test4"); } // generates spurious natural accidental + // void capxTest5() { capxReadTest("test5"); } // generates spurious natural accidental + // void capxTest6() { capxReadTest("test6"); } // generates spurious natural accidental + // void capxTest7() { capxReadTest("test7"); } // generates different (incorrect ?) l1 and l2 values in beams void capxTestPianoG4G5() { capxReadTest("testPianoG4G5"); } void capxTestScaleC4C5() { capxReadTest("testScaleC4C5"); } + // void capxTestTuplet1() { capxReadTest("testTuplet1"); } // generates different (incorrect ?) l1 and l2 values in beams }; //---------------------------------------------------------