本文整理汇总了C++中Chord::isGraceBefore方法的典型用法代码示例。如果您正苦于以下问题:C++ Chord::isGraceBefore方法的具体用法?C++ Chord::isGraceBefore怎么用?C++ Chord::isGraceBefore使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chord
的用法示例。
在下文中一共展示了Chord::isGraceBefore方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: searchTieNote
Note* searchTieNote(Note* note)
{
Note* note2 = 0;
Chord* chord = note->chord();
Segment* seg = chord->segment();
Part* part = chord->staff()->part();
int strack = part->staves()->front()->idx() * VOICES;
int etrack = strack + part->staves()->size() * VOICES;
if (chord->isGraceBefore()) {
chord = static_cast<Chord*>(chord->parent());
note2 = chord->findNote(note->pitch());
return note2;
}
QList<Chord*> gna;
if (chord->getGraceNotesAfter(&gna)) {
chord = gna[0];
note2 = chord->findNote(note->pitch());
return note2;
}
while ((seg = seg->next1(Segment::Type::ChordRest))) {
for (int track = strack; track < etrack; ++track) {
Chord* c = static_cast<Chord*>(seg->element(track));
if (c == 0 || c->type() != Element::Type::CHORD)
continue;
int staffIdx = c->staffIdx() + c->staffMove();
if (staffIdx != chord->staffIdx() + chord->staffMove()) // cannot happen?
continue;
for (Note* n : c->notes()) {
if (n->pitch() == note->pitch()) {
if (note2 == 0 || c->track() == chord->track())
note2 = n;
}
}
}
if (note2)
break;
}
return note2;
}
示例2: searchTieNote
Note* searchTieNote(Note* note)
{
Note* note2 = 0;
Chord* chord = note->chord();
Segment* seg = chord->segment();
Part* part = chord->part();
int strack = part->staves()->front()->idx() * VOICES;
int etrack = strack + part->staves()->size() * VOICES;
if (chord->isGraceBefore()) {
// grace before
// try to tie to note in parent chord
chord = toChord(chord->parent());
note2 = chord->findNote(note->pitch());
if (note2)
return note2;
}
else if (chord->isGraceAfter()) {
// grace after
// we will try to tie to note in next normal chord, below
// meanwhile, set chord to parent chord so the endTick calculation will make sense
chord = toChord(chord->parent());
}
else {
// normal chord
// try to tie to grace note after if present
QVector<Chord*> gna = chord->graceNotesAfter();
if (!gna.empty()) {
Chord* gc = gna[0];
note2 = gc->findNote(note->pitch());
if (note2)
return note2;
}
}
// at this point, chord is a regular chord, not a grace chord
// and we are looking for a note in the *next* chord (grace or regular)
// calculate end of current note duration
// but err on the safe side in case there is roundoff in tick count
int endTick = chord->tick() + chord->actualTicks() - 1;
while ((seg = seg->next1(Segment::Type::ChordRest))) {
// skip ahead to end of current note duration as calculated above
// but just in case, stop if we find element in current track
if (seg->tick() < endTick && !seg->element(chord->track()))
continue;
for (int track = strack; track < etrack; ++track) {
Element* e = seg->element(track);
if (e == 0 || !e->isChord())
continue;
Chord* c = toChord(e);
// if there are grace notes before, try to tie to first one
QVector<Chord*> gnb = c->graceNotesBefore();
if (!gnb.empty()) {
Chord* gc = gnb[0];
Note* gn2 = gc->findNote(note->pitch());
if (gn2)
return gn2;
}
int staffIdx = c->staffIdx() + c->staffMove();
if (staffIdx != chord->staffIdx() + chord->staffMove()) // cannot happen?
continue;
for (Note* n : c->notes()) {
if (n->pitch() == note->pitch()) {
if (note2 == 0 || c->track() == chord->track())
note2 = n;
}
}
}
if (note2)
break;
}
return note2;
}