本文整理汇总了C++中MasterScore类的典型用法代码示例。如果您正苦于以下问题:C++ MasterScore类的具体用法?C++ MasterScore怎么用?C++ MasterScore使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了MasterScore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: readScore
void TestMeasure::spanner_C()
{
MasterScore* score = readScore(DIR + "measure-8.mscx");
Measure* m = score->firstMeasure()->nextMeasure();
score->select(m);
score->startCmd();
score->localTimeDelete();
score->endCmd();
QVERIFY(saveCompareScore(score, "measure-8.mscx", DIR + "measure-8-ref.mscx"));
delete score;
}
示例2: test_pre
void TestInstrumentChange::testMixer()
{
MasterScore* score = test_pre("mixer");
Measure* m = score->firstMeasure()->nextMeasure();
Segment* s = m->first(Segment::Type::ChordRest);
InstrumentChange* ic = static_cast<InstrumentChange*>(s->annotations()[0]);
int idx = score->staff(0)->channel(s->tick(), 0);
Channel* c = score->staff(0)->part()->instrument(s->tick())->channel(idx);
MidiPatch* mp = new MidiPatch;
mp->bank = 0;
mp->drum = false;
mp->name = "Viola";
mp->prog = 41;
mp->synti = "Fluid";
score->startCmd();
ic->setXmlText("Mixer Viola");
score->undo(new ChangePatch(score, c, mp));
score->endCmd();
score->doLayout();
test_post(score, "mixer");
}
示例3: readScore
void TestMeasure::deleteLast()
{
MasterScore* score = readScore(DIR + "measure-10.mscx");
Measure* m = score->lastMeasure();
score->select(m);
score->startCmd();
score->localTimeDelete();
score->endCmd();
QVERIFY(saveCompareScore(score, "measure-10.mscx", DIR + "measure-10-ref.mscx"));
delete score;
}
示例4: readScore
void TestBarline::deleteSkipBarlines()
{
MasterScore* score = readScore(DIR + "barlinedelete.mscx");
Measure* m1 = score->firstMeasure();
QVERIFY(m1);
score->startCmd();
score->cmdSelectAll();
score->cmdDeleteSelection();
score->endCmd();
score->doLayout();
QVERIFY(saveCompareScore(score, QString("barlinedelete.mscx"),
DIR + QString("barlinedelete-ref.mscx")));
delete score;
}
示例5: readScore
void TestSpanners::spanners12()
{
MasterScore* score = readScore(DIR + "lyricsline05.mscx");
QVERIFY(score);
score->doLayout();
// DELETE SECOND MEASURE AND VERIFY
Measure* msr = score->firstMeasure();
QVERIFY(msr);
msr = msr->nextMeasure();
QVERIFY(msr);
score->startCmd();
score->select(msr);
score->cmdTimeDelete();
score->endCmd();
QVERIFY(saveCompareScore(score, "lyricsline05.mscx", DIR + "lyricsline05-ref.mscx"));
// UNDO AND VERIFY
score->undoStack()->undo();
QVERIFY(saveCompareScore(score, "lyricsline05.mscx", DIR + "lyricsline05.mscx"));
delete score;
}
示例6: MasterScore
MasterScore* MTest::readCreatedScore(const QString& name)
{
MasterScore* score = new MasterScore(mscore->baseStyle());
QFileInfo fi(name);
score->setName(fi.completeBaseName());
QString csl = fi.suffix().toLower();
ScoreLoad sl;
Score::FileError rv;
if (csl == "cap") {
rv = importCapella(score, name);
score->setMetaTag("originalFormat", csl);
}
else if (csl == "capx") {
rv = importCapXml(score, name);
score->setMetaTag("originalFormat", csl);
}
else if (csl == "ove")
rv = importOve(score, name);
else if (csl == "sgu")
rv = importBB(score, name);
else if (csl == "mscz" || csl == "mscx")
rv = score->loadMsc(name, false);
else if (csl == "mxl")
rv = importCompressedMusicXml(score, name);
#ifdef OMR
else if (csl == "pdf")
rv = importPdf(score, name);
#endif
else if (csl == "xml" || csl == "musicxml")
rv = importMusicXml(score, name);
else if (csl == "gp3" || csl == "gp4" || csl == "gp5" || csl == "gpx")
rv = importGTP(score, name);
else
rv = Score::FileError::FILE_UNKNOWN_TYPE;
if (rv != Score::FileError::FILE_NO_ERROR) {
QWARN(qPrintable(QString("readScore: cannot load <%1> type <%2>\n").arg(name).arg(csl)));
delete score;
score = 0;
}
else {
for (Score* s : score->scoreList())
s->doLayout();
}
return score;
}
示例7: addNewClicked
void AlbumManager::addNewClicked()
{
MasterScore* score = mscore->getNewFile();
if (!score)
return;
delete score->movements();
MasterScore* topScore = album->front();
scoreList->blockSignals(true);
topScore->addMovement(score);
QString name = getScoreTitle(score);
QListWidgetItem* li = new QListWidgetItem(name, scoreList);
li->setFlags(Qt::ItemFlags(Qt::ItemIsSelectable | Qt::ItemIsEditable | Qt::ItemIsEnabled));
scoreList->blockSignals(false);
topScore->setLayoutAll();
topScore->update();
}
示例8: MasterScore
Score* QmlPlugin::newScore(const QString& /*name*/, const QString& /*part*/, int /*measures*/)
{
#if 0 // TODO
if (msc->currentScore())
msc->currentScore()->endCmd();
MasterScore* score = new MasterScore(MScore::defaultStyle());
score->setName(name);
score->appendPart(part);
score->appendMeasures(measures);
score->doLayout();
int view = msc->appendScore(score);
msc->setCurrentView(0, view);
qApp->processEvents();
// tell QML not to garbage collect this score
QQmlEngine::setObjectOwnership(score, QQmlEngine::CppOwnership);
score->startCmd();
return score;
#endif
return 0;
}
示例9: readFile
void TestTools::undoResequencePart()
{
QString readFile(DIR + "undoResequencePart.mscx");
QString writeFile1("undoResequencePart01-test.mscx");
QString reference1(DIR + "undoResequencePart01-ref.mscx");
QString writeFile2("undoResequencePart02-test.mscx");
QString reference2(DIR + "undoResequencePart02-ref.mscx");
MasterScore* score = readScore(readFile);
score->doLayout();
// do
score->startCmd();
score->cmdResequenceRehearsalMarks();
score->endCmd();
QVERIFY(saveCompareScore(score, writeFile1, reference1));
// undo
score->undoStack()->undo();
QVERIFY(saveCompareScore(score, writeFile2, reference2));
delete score;
}
示例10: readScore
void TestMeasure::undoDelInitialVBox_269919()
{
MasterScore* score = readScore(DIR + "undoDelInitialVBox_269919.mscx");
// 1. delete initial VBox
score->startCmd();
MeasureBase* initialVBox = score->measure(0);
score->select(initialVBox);
score->cmdDeleteSelection();
score->endCmd();
// 2. change duration of first chordrest
score->startCmd();
Measure* m = score->firstMeasure();
ChordRest* cr = m->findChordRest(Fraction(0,1), 0);
Fraction quarter(4, 1);
score->changeCRlen(cr, quarter);
score->endCmd();
// 3. Undo to restore first chordrest
score->undoRedo(true, 0);
// 4. Undo to restore initial VBox resulted in assert failure crash
score->undoRedo(true, 0);
QVERIFY(saveCompareScore(score, "undoDelInitialVBox_269919.mscx", DIR + "undoDelInitialVBox_269919-ref.mscx"));
delete score;
}
示例11: while
//.........这里部分代码省略.........
else if (tag == "movement-title")
setMetaTag("movementTitle", e.readElementText());
else if (tag == "work-number")
setMetaTag("workNumber", e.readElementText());
else if (tag == "work-title")
setMetaTag("workTitle", e.readElementText());
else if (tag == "source")
setMetaTag("source", e.readElementText());
else if (tag == "metaTag") {
QString name = e.attribute("name");
setMetaTag(name, e.readElementText());
}
else if (tag == "Part") {
Part* part = new Part(this);
part->read(e);
_parts.push_back(part);
}
else if ((tag == "HairPin")
|| (tag == "Ottava")
|| (tag == "TextLine")
|| (tag == "Volta")
|| (tag == "Trill")
|| (tag == "Slur")
|| (tag == "Pedal")) {
Spanner* s = toSpanner(Element::name2Element(tag, this));
s->read(e);
addSpanner(s);
}
else if (tag == "Excerpt") {
if (MScore::noExcerpts)
e.skipCurrentElement();
else {
if (isMaster()) {
Excerpt* ex = new Excerpt(static_cast<MasterScore*>(this));
ex->read(e);
excerpts().append(ex);
}
else {
qDebug("Score::read(): part cannot have parts");
e.skipCurrentElement();
}
}
}
else if (e.name() == "Tracklist") {
int strack = e.intAttribute("sTrack", -1);
int dtrack = e.intAttribute("dstTrack", -1);
if (strack != -1 && dtrack != -1)
e.tracks().insert(strack, dtrack);
e.skipCurrentElement();
}
else if (tag == "Score") { // recursion
if (MScore::noExcerpts)
e.skipCurrentElement();
else {
e.tracks().clear(); // ???
MasterScore* m = masterScore();
Score* s = new Score(m, MScore::baseStyle());
Excerpt* ex = new Excerpt(m);
ex->setPartScore(s);
e.setLastMeasure(nullptr);
s->read(e);
ex->setTracks(e.tracks());
m->addExcerpt(ex);
}
}
示例12: InstrumentsDialog
void MuseScore::editInstrList()
{
if (cs == 0)
return;
if (!instrList)
instrList = new InstrumentsDialog(this);
else if (instrList->isVisible()) {
instrList->done(0);
return;
}
instrList->init();
MasterScore* masterScore = cs->masterScore();
instrList->genPartList(masterScore);
masterScore->startCmd();
masterScore->deselectAll();
int rv = instrList->exec();
if (rv == 0) {
masterScore->endCmd();
return;
}
ScoreView* csv = currentScoreView();
if (csv && csv->noteEntryMode()) {
csv->cmd(getAction("escape"));
qApp->processEvents();
updateInputState(csv->score());
}
masterScore->inputState().setTrack(-1);
// keep the keylist of the first pitched staff to apply it to new ones
KeyList tmpKeymap;
Staff* firstStaff = 0;
for (Staff* s : masterScore->staves()) {
KeyList* km = s->keyList();
if (!s->isDrumStaff(Fraction(0,1))) { // TODO
tmpKeymap.insert(km->begin(), km->end());
firstStaff = s;
break;
}
}
Key normalizedC = Key::C;
// normalize the keyevents to concert pitch if necessary
if (firstStaff && !masterScore->styleB(Sid::concertPitch) && firstStaff->part()->instrument()->transpose().chromatic ) {
int interval = firstStaff->part()->instrument()->transpose().chromatic;
normalizedC = transposeKey(normalizedC, interval);
for (auto i = tmpKeymap.begin(); i != tmpKeymap.end(); ++i) {
int tick = i->first;
Key oKey = i->second.key();
tmpKeymap[tick].setKey(transposeKey(oKey, interval));
}
}
// create initial keyevent for transposing instrument if necessary
auto i = tmpKeymap.begin();
if (i == tmpKeymap.end() || i->first != 0)
tmpKeymap[0].setKey(normalizedC);
//
// process modified partitur list
//
QTreeWidget* pl = instrList->partiturList();
Part* part = 0;
int staffIdx = 0;
QTreeWidgetItem* item = 0;
for (int idx = 0; (item = pl->topLevelItem(idx)); ++idx) {
PartListItem* pli = static_cast<PartListItem*>(item);
// check if the part contains any remaining staves
// mark to remove part if not
QTreeWidgetItem* ci = 0;
int staves = 0;
for (int cidx = 0; (ci = pli->child(cidx)); ++cidx) {
StaffListItem* sli = static_cast<StaffListItem*>(ci);
if (sli->op() != ListItemOp::I_DELETE)
++staves;
}
if (staves == 0)
pli->op = ListItemOp::I_DELETE;
}
item = 0;
for (int idx = 0; (item = pl->topLevelItem(idx)); ++idx) {
int rstaff = 0;
PartListItem* pli = static_cast<PartListItem*>(item);
if (pli->op == ListItemOp::I_DELETE)
masterScore->cmdRemovePart(pli->part);
else if (pli->op == ListItemOp::ADD) {
const InstrumentTemplate* t = ((PartListItem*)item)->it;
part = new Part(masterScore);
part->initFromInstrTemplate(t);
masterScore->undo(new InsertPart(part, staffIdx));
pli->part = part;
QList<Staff*> linked;
for (int cidx = 0; pli->child(cidx); ++cidx) {
StaffListItem* sli = static_cast<StaffListItem*>(pli->child(cidx));
Staff* staff = new Staff(masterScore);
staff->setPart(part);
sli->setStaff(staff);
staff->init(t, sli->staffType(), cidx);
//.........这里部分代码省略.........
示例13: itemChanged
void AlbumManager::itemChanged(QListWidgetItem* item)
{
int row = scoreList->row(item);
MasterScore* ms = *(album->begin() + row);
ms->undo(new ChangeMetaText(ms, "movementTitle", item->text()));
}
示例14: TDuration
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);
}
示例15: readScore
void TestNote::noteLimits()
{
MasterScore* score = readScore(DIR + "empty.mscx");
score->inputState().setTrack(0);
score->inputState().setSegment(score->tick2segment(0, false, Segment::Type::ChordRest));
score->inputState().setDuration(TDuration::DurationType::V_QUARTER);
score->inputState().setNoteEntryMode(true);
// over 127 shouldn't crash
score->cmdAddPitch(140, false, false);
// below 0 shouldn't crash
score->cmdAddPitch(-40, false, false);
// stack chords
score->cmdAddPitch(42, false, false);
for (int i = 1; i < 20; i++)
score->cmdAddPitch(42 + i * 7, true, false);
// interval below
score->cmdAddPitch(42, false, false);
for (int i = 0; i < 20; i++) {
std::vector<Note*> nl = score->selection().noteList();
score->cmdAddInterval(-8, nl);
}
// interval above
score->cmdAddPitch(42, false, false);
for (int i = 0; i < 20; i++) {
std::vector<Note*> nl = score->selection().noteList();
score->cmdAddInterval(8, nl);
}
QVERIFY(saveCompareScore(score, "notelimits-test.mscx", DIR + "notelimits-ref.mscx"));
}