本文整理汇总了C++中MidiEvent::getTick方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiEvent::getTick方法的具体用法?C++ MidiEvent::getTick怎么用?C++ MidiEvent::getTick使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MidiEvent
的用法示例。
在下文中一共展示了MidiEvent::getTick方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: closeTrack
void MidiTrack::closeTrack() {
long lastTick = 0;
if (mEvents.size() > 0) {
MidiEvent * last = *(--mEvents.end());
lastTick = last->getTick() + 1;
}
insertEvent(new EndOfTrack(lastTick, 0));
}
示例2: getLengthInTicks
long MidiTrack::getLengthInTicks() {
if (mEvents.size() == 0) {
return 0;
}
// get the last note
MidiEvent * E = *(--mEvents.end());
return E->getTick();
}
示例3: insertEvent
void MidiTrack::insertEvent(MidiEvent * newEvent) {
if (newEvent == NULL) {
return;
}
if (mClosed) {
cerr << "Error: Cannot add an event to a closed track.";
return;
}
MidiEvent * prev = NULL, *next = NULL;
std::vector<MidiEvent*>::iterator it;
for (it = mEvents.begin();
it != mEvents.end();
it++) {
next = *it;
if (next->getTick() > newEvent->getTick()) {
break;
}
prev = next;
next = NULL;
}
mEvents.insert(it, newEvent);
mSizeNeedsRecalculating = true;
// Set its delta time based on the previous event (or itself if no previous event exists)
if (prev != NULL) {
newEvent->setDelta(newEvent->getTick() - prev->getTick());
}
else {
newEvent->setDelta(newEvent->getTick());
}
// Update the next event's delta time relative to the new event.
if (next != NULL) {
next->setDelta(next->getTick() - newEvent->getTick());
}
mSize += newEvent->getSize();
if (newEvent->getType() == MetaEvent::END_OF_TRACK) {
if (next != NULL) {
cerr << "Attempting to insert EndOfTrack before an existing event. Use closeTrack() when finished with MidiTrack.";
return;
}
mClosed = true;
}
}
示例4: removeEvent
bool MidiTrack::removeEvent(MidiEvent * E) {
bool isRemoved = false;
MidiEvent * prev = NULL, *curr = NULL, *next = NULL;
std::vector<MidiEvent*>::iterator it;
for (it = mEvents.begin();
it != mEvents.end();
it++) {
next = *it;
if (E == curr) {
mEvents.erase(--it);
isRemoved = true;
delete curr;
break;
}
prev = curr;
curr = next;
next = NULL;
}
if (next == NULL) {
// Either the event was not found in the track,
// or this is the last event in the track.
// Either way, we won't need to update any delta times
return isRemoved;
}
if (!isRemoved) {
return false;
}
if (prev != NULL) {
next->setDelta(next->getTick() - prev->getTick());
}
else {
next->setDelta(next->getTick());
}
return true;
}