void TestSpanners::spanners07() { DropData dropData; Glissando* gliss; MasterScore* score = readScore(DIR + "glissando-cloning04.mscx"); QVERIFY(score); score->doLayout(); // DROP A GLISSANDO ON FIRST NOTE Measure* msr = score->firstMeasure(); QVERIFY(msr); Segment* seg = msr->findSegment(Segment::Type::ChordRest, 0); QVERIFY(seg); Ms::Chord* chord = static_cast<Ms::Chord*>(seg->element(0)); QVERIFY(chord && chord->type() == Element::Type::CHORD); Note* note = chord->upNote(); QVERIFY(note); // drop a glissando on note gliss = new Glissando(score); dropData.pos = note->pagePos(); dropData.element = gliss; note->drop(dropData); QVERIFY(saveCompareScore(score, "glissando-cloning04.mscx", DIR + "glissando-cloning04-ref.mscx")); delete score; }
void TestTools::undoChangeVoice() { QString readFile(DIR + "undoChangeVoice.mscx"); QString writeFile1("undoChangeVoice01-test.mscx"); QString reference1(DIR + "undoChangeVoice01-ref.mscx"); QString writeFile2("undoChangeVoice02-test.mscx"); QString reference2(DIR + "undoChangeVoice02-ref.mscx"); Score* score = readScore(readFile); score->doLayout(); // do score->deselectAll(); // select bottom note of all voice 1 chords for (Segment* s = score->firstSegment(Segment::Type::ChordRest); s; s = s->next1()) { ChordRest* cr = static_cast<ChordRest*>(s->element(0)); if (cr && cr->type() == Element::Type::CHORD) { Ms::Chord* c = static_cast<Ms::Chord*>(cr); score->select(c->downNote(), SelectType::ADD); } } // change voice score->changeVoice(1); QVERIFY(saveCompareScore(score, writeFile1, reference1)); // undo score->undo()->undo(); QVERIFY(saveCompareScore(score, writeFile2, reference2)); delete score; }
void TestSpanners::spanners08() { MasterScore* score = readScore(DIR + "lyricsline01.mscx"); QVERIFY(score); score->doLayout(); // verify initial LyricsLine setup System* sys = score->systems().at(0); QVERIFY(sys->spannerSegments().size() == 1); QVERIFY(score->unmanagedSpanners().size() == 1); // DELETE LYRICS Measure* msr = score->firstMeasure(); QVERIFY(msr); Segment* seg = msr->findSegment(Segment::Type::ChordRest, 0); QVERIFY(seg); Ms::Chord* chord = static_cast<Ms::Chord*>(seg->element(0)); QVERIFY(chord && chord->type() == Element::Type::CHORD); QVERIFY(chord->lyrics().size() > 0); Lyrics* lyr = chord->lyrics(0, Element::Placement::BELOW); score->startCmd(); score->undoRemoveElement(lyr); score->endCmd(); // verify setup after deletion QVERIFY(sys->spannerSegments().size() == 0); QVERIFY(score->unmanagedSpanners().size() == 0); // save and verify score after deletion QVERIFY(saveCompareScore(score, "lyricsline01.mscx", DIR + "lyricsline01-ref.mscx")); // UNDO score->undoStack()->undo(); score->doLayout(); // verify setup after undo QVERIFY(sys->spannerSegments().size() == 1); QVERIFY(score->unmanagedSpanners().size() == 1); // save and verify score after undo QVERIFY(saveCompareScore(score, "lyricsline01.mscx", DIR + "lyricsline01.mscx")); delete score; }
void TestNote::grace() { Score* score = readScore(DIR + "grace.mscx"); score->doLayout(); Ms::Chord* chord = score->firstMeasure()->findChord(0, 0); Note* note = chord->upNote(); // create score->setGraceNote(chord, note->pitch(), NoteType::APPOGGIATURA, MScore::division/2); Ms::Chord* gc = chord->graceNotes().first(); Note* gn = gc->notes().first(); // Note* n = static_cast<Note*>(writeReadElement(gn)); // QCOMPARE(n->noteType(), NoteType::APPOGGIATURA); // delete n; // tie score->select(gn); score->cmdAddTie(); // n = static_cast<Note*>(writeReadElement(gn)); // QVERIFY(n->tieFor() != 0); // delete n; // tremolo score->startCmd(); Tremolo* tr = new Tremolo(score); tr->setTremoloType(TremoloType::R16); tr->setParent(gc); tr->setTrack(gc->track()); score->undoAddElement(tr); score->endCmd(); // Ms::Chord* c = static_cast<Ms::Chord*>(writeReadElement(gc)); // QVERIFY(c->tremolo() != 0); // delete c; // articulation score->startCmd(); Articulation* ar = new Articulation(score); ar->setArticulationType(ArticulationType::Sforzatoaccent); ar->setParent(gc); ar->setTrack(gc->track()); score->undoAddElement(ar); score->endCmd(); // c = static_cast<Ms::Chord*>(writeReadElement(gc)); // QVERIFY(c->articulations().size() == 1); // delete c; QVERIFY(saveCompareScore(score, "grace-test.mscx", DIR + "grace-ref.mscx")); }
void TestSpanners::spanners03() { DropData dropData; Glissando* gliss; MasterScore* score = readScore(DIR + "glissando-graces01.mscx"); QVERIFY(score); score->doLayout(); // GLISSANDO FROM MAIN NOTE TO AFTER-GRACE // go to top note of first chord Measure* msr = score->firstMeasure(); QVERIFY(msr); Segment* seg = msr->findSegment(Segment::Type::ChordRest, 0); QVERIFY(seg); Ms::Chord* chord = static_cast<Ms::Chord*>(seg->element(0)); QVERIFY(chord && chord->type() == Element::Type::CHORD); Note* note = chord->upNote(); QVERIFY(note); // drop a glissando on note gliss = new Glissando(score); // create a new element each time, as drop() will eventually delete it dropData.pos = note->pagePos(); dropData.element = gliss; note->drop(dropData); // GLISSANDO FROM AFTER-GRACE TO BEFORE-GRACE OF NEXT CHORD // go to last after-grace of chord and drop a glissando on it Ms::Chord* grace = chord->graceNotesAfter().last(); QVERIFY(grace && grace->type() == Element::Type::CHORD); note = grace->upNote(); QVERIFY(note); gliss = new Glissando(score); dropData.pos = note->pagePos(); dropData.element = gliss; note->drop(dropData); // GLISSANDO FROM MAIN NOTE TO BEFORE-GRACE OF NEXT CHORD // go to next chord seg = seg->nextCR(0); QVERIFY(seg); chord = static_cast<Ms::Chord*>(seg->element(0)); QVERIFY(chord && chord->type() == Element::Type::CHORD); note = chord->upNote(); QVERIFY(note); gliss = new Glissando(score); dropData.pos = note->pagePos(); dropData.element = gliss; note->drop(dropData); // GLISSANDO FROM BEFORE-GRACE TO MAIN NOTE // go to next chord seg = seg->nextCR(0); QVERIFY(seg); chord = static_cast<Ms::Chord*>(seg->element(0)); QVERIFY(chord && chord->type() == Element::Type::CHORD); // go to its last before-grace note grace = chord->graceNotesBefore().last(); QVERIFY(grace && grace->type() == Element::Type::CHORD); note = grace->upNote(); QVERIFY(note); gliss = new Glissando(score); dropData.pos = note->pagePos(); dropData.element = gliss; note->drop(dropData); QVERIFY(saveCompareScore(score, "glissando-graces01.mscx", DIR + "glissando-graces01-ref.mscx")); delete score; }
void MsScWriter::note(const QString pitch, const QVector<Bww::BeamType> beamList, const QString type, const int dots, bool tieStart, bool /*TODO tieStop */, StartStop triplet, bool grace) { qDebug() << "MsScWriter::note()" << "type:" << type << "dots:" << dots << "grace" << grace ; if (!stepAlterOctMap.contains(pitch) || !typeMap.contains(type)) { // TODO: error message return; } StepAlterOct sao = stepAlterOctMap.value(pitch); int ticks = 4 * Ms::MScore::division / type.toInt(); if (dots) ticks = 3 * ticks / 2; qDebug() << "ticks:" << ticks; Ms::TDuration durationType(Ms::TDuration::DurationType::V_INVALID); durationType.setVal(ticks); qDebug() << "duration:" << durationType.name(); if (triplet != ST_NONE) ticks = 2 * ticks / 3; Ms::Beam::Mode bm = (beamList.at(0) == Bww::BM_BEGIN) ? Ms::Beam::Mode::BEGIN : Ms::Beam::Mode::AUTO; Ms::Direction sd = Ms::Direction::AUTO; // create chord Ms::Chord* cr = new Ms::Chord(score); //ws cr->setTick(tick); cr->setBeamMode(bm); cr->setTrack(0); if (grace) { cr->setNoteType(Ms::NoteType::GRACE32); cr->setDurationType(Ms::TDuration::DurationType::V_32ND); sd = Ms::Direction::UP; } else { if (durationType.type() == Ms::TDuration::DurationType::V_INVALID) durationType.setType(Ms::TDuration::DurationType::V_QUARTER); cr->setDurationType(durationType); sd = Ms::Direction::DOWN; } cr->setDuration(durationType.fraction()); cr->setDots(dots); cr->setStemDirection(sd); // add note to chord Ms::Note* note = new Ms::Note(score); note->setTrack(0); xmlSetPitch(note, sao.s.toLatin1(), sao.a, sao.o); if (tieStart) { Ms::Tie* tie = new Ms::Tie(score); note->setTieFor(tie); tie->setStartNote(note); tie->setTrack(0); } cr->add(note); // add chord to measure if (!grace) { Ms::Segment* s = currentMeasure->getSegment(cr, tick); s->add(cr); if (!currentGraceNotes.isEmpty()) { for (int i = currentGraceNotes.size() - 1; i >=0; i--) cr->add(currentGraceNotes.at(i)); currentGraceNotes.clear(); } doTriplet(cr, triplet); int tickBefore = tick; tick += ticks; Ms::Fraction nl(Ms::Fraction::fromTicks(tick - currentMeasure->tick())); currentMeasure->setLen(nl); qDebug() << "MsScWriter::note()" << "tickBefore:" << tickBefore << "tick:" << tick << "nl:" << nl.print() ; } else { currentGraceNotes.append(cr); } }