void TestMidi::midi3() { MCursor c; c.createScore("test3a"); c.addPart("voice"); c.move(0, 0); // move to track 0 tick 0 c.addKeySig(1); c.addTimeSig(Fraction(4,4)); c.addChord(60, TDuration(TDuration::V_QUARTER)); c.addChord(61, TDuration(TDuration::V_QUARTER)); c.addChord(62, TDuration(TDuration::V_QUARTER)); c.addChord(63, TDuration(TDuration::V_QUARTER)); Score* score = c.score(); score->doLayout(); score->rebuildMidiMapping(); c.saveScore(); saveMidi(score, "test3.mid"); Score* score2 = new Score(mscore->baseStyle()); score2->setName("test3b"); QVERIFY(importMidi(score2, "test3.mid")); score2->doLayout(); score2->rebuildMidiMapping(); MCursor c2(score2); c2.saveScore(); QVERIFY(compareScores(score, score2)); delete score; delete score2; }
void TestMidi::midi02() { MCursor c; c.setTimeSig(Fraction(3,4)); c.createScore("test2a"); c.addPart("voice"); c.move(0, 0); // move to track 0 tick 0 c.addKeySig(Key(2)); c.addTimeSig(Fraction(3,4)); c.addChord(60, TDuration(TDuration::DurationType::V_QUARTER)); c.addChord(61, TDuration(TDuration::DurationType::V_QUARTER)); c.addChord(62, TDuration(TDuration::DurationType::V_QUARTER)); Score* score = c.score(); score->doLayout(); score->rebuildMidiMapping(); c.saveScore(); saveMidi(score, "test2.mid"); Score* score2 = new Score(mscore->baseStyle()); score2->setName("test2b"); QCOMPARE(importMidi(score2, "test2.mid"), Score::FileError::FILE_NO_ERROR); score2->doLayout(); score2->rebuildMidiMapping(); MCursor c2(score2); c2.saveScore(); QVERIFY(compareScores(score, score2)); delete score; delete score2; }
Score* NoteGroups::createScore(int n, TDuration::DurationType t, std::vector<Chord*>* chords) { MCursor c; c.setTimeSig(_sig); c.createScore("score8"); c.addPart("voice"); c.move(0, 0); c.addKeySig(Key::C); TimeSig* nts = c.addTimeSig(_sig); GroupNode node {0, 0}; Groups ng; ng.push_back(node); nts->setGroups(ng); for (int i = 0; i < n; ++i) { Chord* chord = c.addChord(67, t); int tick = chord->rtick(); chord->setBeamMode(_groups.beamMode(tick, t)); chords->push_back(chord); } c.score()->pageFormat()->setEvenLeftMargin(0.0); c.score()->pageFormat()->setOddLeftMargin(0.0); c.score()->parts().front()->setLongName(""); c.score()->style().set(StyleIdx::linearStretch, 1.3); c.score()->style().set(StyleIdx::MusicalSymbolFont, QString("Bravura")); c.score()->style().set(StyleIdx::MusicalTextFont, QString("Bravura Text")); return c.score(); }
Score* NoteGroups::createScore(int n, TDuration::DurationType t, std::vector<Chord*>* chords) { MCursor c; c.setTimeSig(_sig); c.createScore("score8"); c.addPart("voice"); c.move(0, 0); c.addKeySig(0); TimeSig* nts = c.addTimeSig(_sig); GroupNode node {0, 0}; Groups ng; ng.push_back(node); nts->setGroups(ng); for (int i = 0; i < n; ++i) { Chord* chord = c.addChord(67, t); int tick = chord->rtick(); chord->setBeamMode(_groups.beamMode(tick, t)); chords->push_back(chord); } c.score()->parts().front()->setLongName(""); c.score()->style()->set(ST_linearStretch, 1.1); return c.score(); }
void TestLinks::test5LinkedParts_94911() { MCursor c; c.setTimeSig(Fraction(4,4)); c.createScore("test"); c.addPart("electric-guitar"); c.move(0, 0); // move to track 0 tick 0 c.addKeySig(Key(1)); c.addTimeSig(Fraction(4,4)); c.addChord(60, TDuration(TDuration::DurationType::V_WHOLE)); MasterScore* score = c.score(); score->addText("title", "Title"); score->doLayout(); // delete chord Measure* m = score->firstMeasure(); Segment* s = m->first(Segment::Type::ChordRest); Element* e = s->element(0); QVERIFY(e->type() == ElementType::CHORD); score->select(e); score->cmdDeleteSelection(); e = s->element(0); QVERIFY(e->type() == ElementType::REST); QVERIFY(e->links() == nullptr); // create parts// score->startCmd(); QList<Part*> parts; parts.append(score->parts().at(0)); Score* nscore = new Score(score); Excerpt ex(score); ex.setPartScore(nscore); ex.setTitle("Guitar"); ex.setParts(parts); Excerpt::createExcerpt(&ex); QVERIFY(nscore); score->undo(new AddExcerpt(&ex)); score->endCmd(); // we should have now 1 staff and 2 linked rests QVERIFY(score->staves().size() == 1); e = s->element(0); QVERIFY(e->type() == ElementType::REST); QVERIFY(e->links()->size() == 2); // add a linked staff score->startCmd(); Staff* oStaff = score->staff(0); Staff* staff = new Staff(score); staff->setPart(oStaff->part()); score->undoInsertStaff(staff, 1); Excerpt::cloneStaff(oStaff, staff); score->endCmd(); // we should have now 2 staves and 3 linked rests QCOMPARE(score->staves().size(), 2); QCOMPARE(nscore->staves().size(), 1); QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 3); e = s->element(0); QVERIFY(e->type() == ElementType::REST); QVERIFY(e->links()->size() == 3); e = s->element(4); QVERIFY(e->type() == ElementType::REST); QVERIFY(e->links()->size() == 3); QVERIFY(score->excerpts().size() == 1); // undo score->undoStack()->undo(); // we should have now 1 staves and 2 linked rests QVERIFY(score->staves().size() == 1); QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 2); e = s->element(0); QVERIFY(e->type() == ElementType::REST); QVERIFY(e->links()->size() == 2); QVERIFY(score->excerpts().size() == 1); // redo score->undoStack()->redo(); // we should have now 2 staves and 3 linked rests QVERIFY(score->staves().size() == 2); QVERIFY(score->staves()[0]->linkedStaves()->staves().size() == 3); e = s->element(0); QVERIFY(e->type() == ElementType::REST); QVERIFY(e->links()->size() == 3); e = s->element(4); QVERIFY(e->type() == ElementType::REST); QVERIFY(e->links()->size() == 3); QVERIFY(score->excerpts().size() == 1); }