Ejemplo n.º 1
0
void
CPlaybackTaskGroup::FlushEvents()
{
	LOCK_PLAYER;

	// Pop all events off of the stack!
	// But only execute the note-offs.
	CEvent ev;
	while (real.stack.Pop(ev))
	{
		if (ev.Command() == EvtType_NoteOff)
			_executeEvent(ev, real);
	}
	while (metered.stack.Pop(ev))
	{
		if (ev.Command() == EvtType_NoteOff)
			_executeEvent(ev, metered);
	}
}
Ejemplo n.º 2
0
void
CPlaybackTaskGroup::_flushNotes(
	CEventStack &stack)
{
	CEventStackIterator iter(stack);
	for (;;)
	{
		CEvent *ev = iter.Current();
		if (ev == NULL)
			break;
		if (ev->Command() == EvtType_NoteOff)
			_executeEvent(*ev, real);
		iter.Next();
	}
}
Ejemplo n.º 3
0
void
DualBendOffsetOp::operator()(
	CEvent &ev,
	TClockType clockType)
{
	if (ev.Command() == EvtType_PitchBend)
	{
		if (ev.Duration() > 0)
		{
			ev.pitchBend.startBend =
				(uint16)CLAMP(0, ((int16)ev.pitchBend.startBend) + delta,
							  0x3fff );
			ev.pitchBend.targetBend =
				(uint16)CLAMP(0, ((int16)ev.pitchBend.targetBend) + delta,
							  0x3fff);
		}
		else
		{
			ev.pitchBend.startBend = ev.pitchBend.targetBend = 
				(uint16)CLAMP(0, ((int16)ev.pitchBend.targetBend) + delta,
							  0x3fff );
		}
	}
}
Ejemplo n.º 4
0
void
CPlaybackTaskGroup::_executeEvent(
	CEvent &ev,
	TimeState &tState)
{
	D_INTERNAL(("CPlaybackTaskGroup::_executeEvent(%s)\n",
				ev.NameText()));

	switch (ev.Command())
	{
		case EvtType_TaskMarker:
		{
			if (ev.task.taskPtr->flags & CPlaybackTask::Task_Finished)
			{
				delete ev.task.taskPtr;
				if (tasks.Empty())
				{
					BMessage message(Player_ChangeTransportState);
					be_app->PostMessage(&message);
				}
			}
			else
			{
				ev.task.taskPtr->Play();
			}
			return;
		}
		case EvtType_Interpolate:
		{
			// I was originally supposed to have executed at ev.Start() + timeStep,
			// but I may be a bit later than that -- take the difference into account.
			// Here's how much time has elapsed since I was dispatched...
			int32 elapsed = tState.time - ev.Start()
							+ ev.interpolate.timeStep;

			// If we went past the end, then clip the time.
			if ((unsigned long)elapsed > ev.interpolate.duration)
				elapsed = ev.interpolate.duration;

			CDestination *dest = ev.common.destination;
			if (dest != NULL)
			{
				if (dest->ReadLock(500))
				{
					dest->Interpolate(ev, tState.stack, system_time(),
									  elapsed);
					dest->ReadUnlock();
				}
			}
			return;
		}
	}

	CDestination *dest = ev.common.destination;
	if (dest != NULL)
	{
		if (dest->ReadLock(500))
		{
			dest->Execute(ev, system_time());
			dest->ReadUnlock();
		}
	}
}