当前位置: 首页>>代码示例>>C++>>正文


C++ MidiEvent::getTick方法代码示例

本文整理汇总了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));
}
开发者ID:Geromatic,项目名称:Midi-Unreal,代码行数:9,代码来源:MidiTrack.cpp

示例2: getLengthInTicks

long MidiTrack::getLengthInTicks() {
	if (mEvents.size() == 0) {
		return 0;
	}

	// get the last note
	MidiEvent * E = *(--mEvents.end());
	return E->getTick();
}
开发者ID:Geromatic,项目名称:Midi-Unreal,代码行数:9,代码来源:MidiTrack.cpp

示例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;
	}
}
开发者ID:Geromatic,项目名称:Midi-Unreal,代码行数:51,代码来源:MidiTrack.cpp

示例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;
}
开发者ID:Geromatic,项目名称:Midi-Unreal,代码行数:43,代码来源:MidiTrack.cpp


注:本文中的MidiEvent::getTick方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。