本文整理汇总了C++中KeySigEvent类的典型用法代码示例。如果您正苦于以下问题:C++ KeySigEvent类的具体用法?C++ KeySigEvent怎么用?C++ KeySigEvent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了KeySigEvent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: KeySig
Palette* MuseScore::newKeySigPalette(bool basic)
{
Palette* sp = new Palette;
sp->setName(QT_TRANSLATE_NOOP("Palette", "Key Signatures"));
sp->setMag(1.0);
sp->setGrid(56, 64);
sp->setYOffset(0.0);
for (int i = 0; i < 7; ++i) {
KeySig* k = new KeySig(gscore);
k->setKey(Key(i + 1));
sp->append(k, qApp->translate("MuseScore", keyNames[i*2]));
}
for (int i = -7; i < 0; ++i) {
KeySig* k = new KeySig(gscore);
k->setKey(Key(i));
sp->append(k, qApp->translate("MuseScore", keyNames[(7 + i) * 2 + 1]));
}
KeySig* k = new KeySig(gscore);
k->setKey(Key::C);
sp->append(k, qApp->translate("MuseScore", keyNames[14]));
if (!basic) {
// atonal key signature
KeySigEvent nke;
nke.setKey(Key::C);
nke.setCustom(true);
nke.setMode(KeyMode::NONE);
KeySig* nk = new KeySig(gscore);
nk->setKeySigEvent(nke);
sp->append(nk, qApp->translate("MuseScore", keyNames[15]));
}
return sp;
}
示例2: key
KeySigEvent KeyList::key(int tick) const
{
KeySigEvent ke;
ke.setKey(Key::C);
if (empty())
return ke;
auto i = upper_bound(tick);
if (i == begin())
return ke;
return (--i)->second;
}
示例3: setKeySigEvent
void KeySig::changeKeySigEvent(const KeySigEvent& t)
{
if (_sig == t)
return;
if (t.custom()) {
KeySig* ks = _score->customKeySig(t.customType());
if (!ks)
return;
keySymbols = ks->keySymbols;
}
setKeySigEvent(t);
}
示例4: prevKey
KeySigEvent KeyList::prevKey(int tick) const
{
KeySigEvent kc;
kc.setKey(Key::C);
if (empty())
return kc;
auto i = upper_bound(tick);
if (i == begin())
return kc;
--i;
if (i == begin())
return kc;
return (--i)->second;
}
示例5: while
void KeyList::read(XmlReader& e, Score* cs)
{
while (e.readNextStartElement()) {
if (e.name() == "key") {
KeySigEvent ke;
int tick = e.intAttribute("tick", 0);
if (e.hasAttribute("custom"))
ke.setCustomType(e.intAttribute("custom"));
else
ke.setAccidentalType(e.intAttribute("idx"));
(*this)[cs->fileDivision(tick)] = ke;
e.readNext();
}
else
e.unknown();
}
}
示例6: tag
void KeyList::read(QDomElement e, Score* cs)
{
for (e = e.firstChildElement(); !e.isNull(); e = e.nextSiblingElement()) {
QString tag(e.tagName());
if (tag == "key") {
KeySigEvent ke;
int tick = e.attribute("tick", "0").toInt();
if (e.hasAttribute("custom"))
ke.setCustomType(e.attribute("custom").toInt());
else
ke.setAccidentalType(e.attribute("idx").toInt());
(*this)[cs->fileDivision(tick)] = ke;
}
else
domError(e);
}
}
示例7: init
void AccidentalState::init(const KeySigEvent& keySig, ClefType clef)
{
if (keySig.custom()) {
memset(state, 2, MAX_ACC_STATE);
for (const KeySym& s : keySig.keySymbols()) {
AccidentalVal a = sym2accidentalVal(s.sym);
int line = int(s.spos.y() * 2);
int idx = relStep(line, clef) % 7;
for (int octave = 0; octave < (11 * 7); octave += 7) {
int i = idx + octave ;
if (i >= MAX_ACC_STATE)
break;
state[i] = int(a) + 2;
}
}
}
else {
init(keySig.key());
}
}
示例8: while
void StaffTypeList::read(XmlReader& /*e*/, Score* /*cs*/)
{
#if 0
while (e.readNextStartElement()) {
if (e.name() == "key") {
Key k;
int tick = e.intAttribute("tick", 0);
if (e.hasAttribute("custom"))
k = Key::C; // ke.setCustomType(e.intAttribute("custom"));
else
k = Key(e.intAttribute("idx"));
KeySigEvent ke;
ke.setKey(k);
(*this)[cs->fileDivision(tick)] = ke;
e.readNext();
}
else
e.unknown();
}
#endif
}
示例9: recognizeMainKeySig
void recognizeMainKeySig(QList<MTrack> &tracks)
{
bool needToFindKey = false;
const auto &opers = preferences.midiImportOperations;
const bool isHuman = opers.data()->trackOpers.isHumanPerformance.value();
if (isHuman)
needToFindKey = true;
if (!needToFindKey) {
for (const MTrack &track: tracks) {
if (track.mtrack->drumTrack())
continue;
if (!track.hasKey) {
needToFindKey = true;
break;
}
}
}
if (!needToFindKey)
return;
const Key key = findKey(tracks);
for (MTrack &track: tracks) {
if (track.mtrack->drumTrack())
continue;
if (!track.hasKey || isHuman) {
KeySigEvent ke;
ke.setKey(key);
KeyList &staffKeyList = *track.staff->keyList();
staffKeyList[0] = ke;
assignKeyListToStaff(staffKeyList, track.staff);
}
}
}
示例10: readScore
void TestSpanners::spanners04()
{
MasterScore* score = readScore(DIR + "glissando-cloning01.mscx");
QVERIFY(score);
score->doLayout();
// add a linked staff to the existing staff
// (copied and adapted from void MuseScore::editInstrList() in mscore/instrdialog.cpp)
Staff* oldStaff = score->staff(0);
Staff* newStaff = new Staff(score);
newStaff->setPart(oldStaff->part());
newStaff->initFromStaffType(oldStaff->staffType());
newStaff->setDefaultClefType(ClefTypeList(ClefType::G));
KeySigEvent ke;
ke.setKey(Key::C);
newStaff->setKey(0, ke);
score->undoInsertStaff(newStaff, 1, false);
cloneStaff(oldStaff, newStaff);
QVERIFY(saveCompareScore(score, "glissando-cloning01.mscx", DIR + "glissando-cloning01-ref.mscx"));
delete score;
}
示例11: drop
Element* KeySig::drop(const DropData& data)
{
KeySig* ks = static_cast<KeySig*>(data.element);
if (ks->type() != Element::Type::KEYSIG) {
delete ks;
return 0;
}
KeySigEvent k = ks->keySigEvent();
if (k.custom() && (score()->customKeySigIdx(ks) == -1))
score()->addCustomKeySig(ks);
else
delete ks;
if (data.modifiers & Qt::ControlModifier) {
// apply only to this stave
if (k != keySigEvent())
score()->undoChangeKeySig(staff(), tick(), k.key());
}
else {
// apply to all staves:
foreach(Staff* s, score()->rootScore()->staves())
score()->undoChangeKeySig(s, tick(), k.key());
}
return this;
}
示例12: init
void AccidentalState::init(const KeySigEvent& ks)
{
int type = ks.accidentalType();
memset(state, 0, 74);
for (int octave = 0; octave < 11; ++octave) {
if (type > 0) {
for (int i = 0; i < type; ++i) {
int idx = tpc2step(20 + i) + octave * 7;
if (idx < 74)
state[idx] = 1;
}
}
else {
for (int i = 0; i > type; --i) {
int idx = tpc2step(12 + i) + octave * 7;
if (idx < 74)
state[idx] = -1;
}
}
}
}
示例13: InstrumentsDialog
//.........这里部分代码省略.........
Staff* linkedStaff = part->staves()->front();
if (sli->linked() && linkedStaff != staff) {
Excerpt::cloneStaff(linkedStaff, staff);
linked.append(staff);
}
}
//insert keysigs
int sidx = masterScore->staffIdx(part);
int eidx = sidx + part->nstaves();
if (firstStaff)
masterScore->adjustKeySigs(sidx, eidx, tmpKeymap);
}
else {
part = pli->part;
if (part->show() != pli->visible())
part->undoChangeProperty(Pid::VISIBLE, pli->visible());
for (int cidx = 0; pli->child(cidx); ++cidx) {
StaffListItem* sli = static_cast<StaffListItem*>(pli->child(cidx));
if (sli->op() == ListItemOp::I_DELETE) {
Staff* staff = sli->staff();
int sidx = staff->idx();
masterScore->cmdRemoveStaff(sidx);
}
else if (sli->op() == ListItemOp::ADD) {
Staff* staff = new Staff(masterScore);
staff->setPart(part);
staff->initFromStaffType(sli->staffType());
sli->setStaff(staff);
staff->setDefaultClefType(sli->defaultClefType());
if (staffIdx > 0)
staff->setBarLineSpan(masterScore->staff(staffIdx - 1)->barLineSpan());
KeySigEvent ke;
if (part->staves()->empty())
ke.setKey(Key::C);
else
ke = part->staff(0)->keySigEvent(Fraction(0,1));
staff->setKey(Fraction(0,1), ke);
Staff* linkedStaff = 0;
if (sli->linked()) {
if (rstaff > 0)
linkedStaff = part->staves()->front();
else {
for (Staff* st : *part->staves()) {
if (st != staff) {
linkedStaff = st;
break;
}
}
}
}
if (linkedStaff) {
// do not create a link if linkedStaff will be removed,
for (int k = 0; pli->child(k); ++k) {
StaffListItem* li = static_cast<StaffListItem*>(pli->child(k));
if (li->op() == ListItemOp::I_DELETE && li->staff() == linkedStaff) {
linkedStaff = 0;
break;
}
}
}
masterScore->undoInsertStaff(staff, rstaff, linkedStaff == 0);
if (linkedStaff)
示例14: qDebug
void MTrack::processMeta(int tick, const MidiEvent& mm)
{
if (!staff) {
qDebug("processMeta: no staff");
return;
}
const uchar* data = (uchar*)mm.edata();
int staffIdx = staff->idx();
Score* cs = staff->score();
switch (mm.metaType()) {
case META_TEXT:
case META_LYRIC: {
QString s((char*)data);
cs->addLyrics(tick, staffIdx, s);
}
break;
case META_TRACK_NAME:
name = (const char*)data;
break;
case META_TEMPO:
{
unsigned tempo = data[2] + (data[1] << 8) + (data[0] <<16);
double t = 1000000.0 / double(tempo);
cs->setTempo(tick, t);
// TODO: create TempoText
}
break;
case META_KEY_SIGNATURE:
{
int key = ((const char*)data)[0];
if (key < -7 || key > 7) {
qDebug("ImportMidi: illegal key %d", key);
break;
}
KeySigEvent ks;
ks.setAccidentalType(key);
(*staff->keymap())[tick] = ks;
hasKey = true;
}
break;
case META_COMPOSER: // mscore extension
case META_POET:
case META_TRANSLATOR:
case META_SUBTITLE:
case META_TITLE:
{
Text* text = new Text(cs);
switch(mm.metaType()) {
case META_COMPOSER:
text->setTextStyleType(TEXT_STYLE_COMPOSER);
break;
case META_TRANSLATOR:
text->setTextStyleType(TEXT_STYLE_TRANSLATOR);
break;
case META_POET:
text->setTextStyleType(TEXT_STYLE_POET);
break;
case META_SUBTITLE:
text->setTextStyleType(TEXT_STYLE_SUBTITLE);
break;
case META_TITLE:
text->setTextStyleType(TEXT_STYLE_TITLE);
break;
}
text->setText((const char*)(mm.edata()));
MeasureBase* measure = cs->first();
if (measure->type() != Element::VBOX) {
measure = new VBox(cs);
measure->setTick(0);
measure->setNext(cs->first());
cs->add(measure);
}
measure->add(text);
}
break;
case META_COPYRIGHT:
cs->setMetaTag("Copyright", QString((const char*)(mm.edata())));
break;
case META_TIME_SIGNATURE:
qDebug("midi: meta timesig: %d, division %d", tick, MScore::division);
cs->sigmap()->add(tick, Fraction(data[0], 1 << data[1]));
break;
default:
if (MScore::debugMode)
qDebug("unknown meta type 0x%02x", mm.metaType());
break;
}
}
示例15: findKey
void MTrack::convertTrack(const Fraction &lastTick)
{
Score* score = staff->score();
int key = 0; // TODO-LIB findKey(mtrack, score->sigmap());
int track = staff->idx() * VOICES;
int voices = VOICES;
for (int voice = 0; voice < voices; ++voice) {
// startChordTick is onTime value of all simultaneous notes
// chords here are consist of notes with equal durations
// several chords may have the same onTime value
Fraction startChordTick;
QList<MidiChord> midiChords;
for (auto it = chords.begin(); it != chords.end();) {
const Fraction &nextChordTick = it->first;
const MidiChord& midiChord = it->second;
if (midiChord.voice != voice) {
++it;
continue;
}
processPendingNotes(midiChords, voice, startChordTick, nextChordTick);
// now 'midiChords' list is empty
// so - fill it:
// collect all midiChords on current tick position
startChordTick = nextChordTick; // debug
for (;it != chords.end(); ++it) {
const MidiChord& midiChord = it->second;
if (it->first != startChordTick)
break;
if (midiChord.voice != voice)
continue;
midiChords.append(midiChord);
}
if (midiChords.isEmpty())
break;
}
// process last chords at the end of the score
processPendingNotes(midiChords, voice, startChordTick, lastTick);
}
createTuplets(track, score);
KeyList* km = staff->keymap();
if (!hasKey && !mtrack->drumTrack()) {
KeySigEvent ks;
ks.setAccidentalType(key);
(*km)[0] = ks;
}
for (auto it = km->begin(); it != km->end(); ++it) {
int tick = it->first;
KeySigEvent key = it->second;
KeySig* ks = new KeySig(score);
ks->setTrack(track);
ks->setGenerated(false);
ks->setKeySigEvent(key);
ks->setMag(staff->mag());
Measure* m = score->tick2measure(tick);
Segment* seg = m->getSegment(ks, tick);
seg->add(ks);
}
#if 0 // TODO
ClefList* cl = staff->clefList();
for (ciClefEvent i = cl->begin(); i != cl->end(); ++i) {
int tick = i.key();
Clef* clef = new Clef(score);
clef->setClefType(i.value());
clef->setTrack(track);
clef->setGenerated(false);
clef->setMag(staff->mag());
Measure* m = score->tick2measure(tick);
Segment* seg = m->getSegment(clef, tick);
seg->add(clef);
}
#endif
}