本文整理汇总了C++中Composition::getRealTimeDifference方法的典型用法代码示例。如果您正苦于以下问题:C++ Composition::getRealTimeDifference方法的具体用法?C++ Composition::getRealTimeDifference怎么用?C++ Composition::getRealTimeDifference使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Composition
的用法示例。
在下文中一共展示了Composition::getRealTimeDifference方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void
Clipboard::newSegment(const Segment *copyFrom, timeT from, timeT to,
bool expandRepeats)
{
// create with copy ctor so as to inherit track, instrument etc
Segment *s = copyFrom->clone(false);
// If the segment is within the time range
if (from <= s->getStartTime() && to >= s->getEndMarkerTime()) {
// Insert the whole thing.
m_segments.insert(s);
// don't change m_partial as we are inserting a complete segment
return;
}
// Only a portion of the source segment will be used.
const timeT segStart = copyFrom->getStartTime();
const timeT segEndMarker = copyFrom->getEndMarkerTime();
timeT segDuration = segEndMarker - segStart;
// We can't copy starting prior to the start of the segment.
if (from < segStart)
from = segStart;
int firstRepeat = 0;
int lastRepeat = 0;
if (!copyFrom->isRepeating() || segDuration <= 0) {
expandRepeats = false;
}
if (expandRepeats) {
firstRepeat = (from - segStart) / segDuration;
to = std::min(to, copyFrom->getRepeatEndTime());
lastRepeat = (to - segStart) / segDuration;
}
s->setRepeating(false);
if (s->getType() == Segment::Audio) {
Composition *c = copyFrom->getComposition();
for (int repeat = firstRepeat; repeat <= lastRepeat; ++repeat) {
timeT wrappedFrom = segStart;
timeT wrappedTo = segEndMarker;
if (!expandRepeats) {
wrappedFrom = from;
wrappedTo = to;
} else {
if (repeat == firstRepeat) {
wrappedFrom = segStart + (from - segStart) % segDuration;
}
if (repeat == lastRepeat) {
wrappedTo = segStart + (to - segStart) % segDuration;
}
}
if (wrappedFrom > segStart) {
if (c) {
s->setAudioStartTime
(s->getAudioStartTime() +
c->getRealTimeDifference(segStart + repeat * segDuration,
from));
}
s->setStartTime(from);
} else {
s->setStartTime(segStart + repeat * segDuration);
}
if (wrappedTo < segEndMarker) {
s->setEndMarkerTime(to);
if (c) {
s->setAudioEndTime
(s->getAudioStartTime() +
c->getRealTimeDifference(segStart + repeat * segDuration,
to));
}
} else {
s->setEndMarkerTime(segStart + (repeat + 1) * segDuration);
}
m_segments.insert(s);
if (repeat < lastRepeat) {
s = copyFrom->clone(false);
s->setRepeating(false);
}
}
m_partial = true;
return;
}
// We have a normal (MIDI) segment.
//.........这里部分代码省略.........