本文整理汇总了C++中Chord::graceIndex方法的典型用法代码示例。如果您正苦于以下问题:C++ Chord::graceIndex方法的具体用法?C++ Chord::graceIndex怎么用?C++ Chord::graceIndex使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Chord
的用法示例。
在下文中一共展示了Chord::graceIndex方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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()) {
chord = toChord(chord->parent());
// try to tie to next grace note
int index = chord->graceIndex();
for (Chord* c : chord->graceNotes()) {
if (c->graceIndex() == index + 1) {
note2 = c->findNote(note->pitch());
if (note2) {
printf("found grace-grace tie\n");
return note2;
}
}
}
// try to tie to note in parent chord
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(SegmentType::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;
}