本文整理汇总了C++中Segment::elementAt方法的典型用法代码示例。如果您正苦于以下问题:C++ Segment::elementAt方法的具体用法?C++ Segment::elementAt怎么用?C++ Segment::elementAt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Segment
的用法示例。
在下文中一共展示了Segment::elementAt方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: layout
void LyricsLine::layout()
{
if (lyrics()->ticks() > 0) { // melisma
setLineWidth(Spatium(MELISMA_DEFAULT_LINE_THICKNESS));
// Lyrics::_ticks points to the beginning of the last spanned segment,
// but the line shall include it:
// include the duration of this last segment in the melisma duration
bool ticksSet = false;
Segment* lastSeg = score()->tick2segment(lyrics()->endTick(), false, Segment::Type::ChordRest, false);
if (lastSeg) {
// if last segment found, locate the first non-empty ChordRest
// in the same staff of this LyricsLine and use its duration
int firstTrack = (track() >> 2) << 2;
int lastTrack = firstTrack + VOICES;
for (int i = firstTrack; i < lastTrack; i++) {
ChordRest* cr = static_cast<ChordRest*>(lastSeg->elementAt(i));
if (cr) {
setTicks(lyrics()->ticks() + cr->durationTicks());
ticksSet = true;
break;
}
}
}
// no suitable ChordRest found? go to the end of the last known segment
if (!ticksSet)
setTicks(lyrics()->ticks());
}
示例2: nextChordNote
Note* nextChordNote(Note* note)
{
int track = note->track();
int fromTrack = (track / VOICES) * VOICES;
int toTrack = fromTrack + VOICES;
// TODO : limit to same instrument, not simply to same staff!
Segment* seg = note->chord()->segment()->nextCR(track, true);
while (seg) {
Element* targetElement = seg->elementAt(track);
// if a chord exists in the same track, return its top note
if (targetElement && targetElement->isChord())
return toChord(targetElement)->upNote();
// if not, return topmost chord in track range
for (int i = fromTrack ; i < toTrack; i++) {
targetElement = seg->elementAt(i);
if (targetElement && targetElement->isChord())
return toChord(targetElement)->upNote();
}
seg = seg->nextCR(track, true);
}
return nullptr;
}
示例3: prevChordNote
Note* prevChordNote(Note* note)
{
int track = note->track();
int fromTrack = (track / VOICES) * VOICES;
int toTrack = fromTrack + VOICES;
// TODO : limit to same instrument, not simply to same staff!
Segment* seg = note->chord()->segment()->prev1();
while (seg) {
if (seg->segmentType() == Segment::Type::ChordRest) {
Element* targetElement = seg->elementAt(track);
// if a chord exists in the same track, return its top note
if (targetElement != nullptr && targetElement->type() == Element::Type::CHORD)
return static_cast<Chord*>(targetElement)->upNote();
// if not, return topmost chord in track range
for (int i = fromTrack ; i < toTrack; i++) {
targetElement = seg->elementAt(i);
if (targetElement != nullptr && targetElement->type() == Element::Type::CHORD)
return static_cast<Chord*>(targetElement)->upNote();
}
}
seg = seg->prev1();
}
return nullptr;
}