예제 #1
0
파일: audiotrack.cpp 프로젝트: 87maxi/oom
void AudioTrack::eraseRangeACEvents(int id, int frame1, int frame2)
{
	ciCtrlList icl = _controller.find(id);
	if (icl == _controller.end())
		return;

	CtrlList* cl = icl->second;
	if (cl->empty())
		return;

	iCtrl s = cl->lower_bound(frame1);
	iCtrl e = cl->lower_bound(frame2);
	cl->erase(s, e);
	return;
}
예제 #2
0
파일: audiotrack.cpp 프로젝트: 87maxi/oom
void AudioTrack::seekPrevACEvent(int id)
{
	ciCtrlList icl = _controller.find(id);
	if (icl == _controller.end())
		return;

	CtrlList* cl = icl->second;
	if (cl->empty())
		return;

	iCtrl s = cl->lower_bound(song->cPos().frame());
	if (s != cl->begin())
		--s;
	song->setPos(Song::CPOS, Pos(s->second.getFrame(), false), true, false, true);
	return;
}
예제 #3
0
파일: audiotrack.cpp 프로젝트: 87maxi/oom
void AudioTrack::processAutomationEvents()/*{{{*/
{
	if (_automationType != AUTO_TOUCH && _automationType != AUTO_WRITE)
		return;

	for (iCtrlList icl = _controller.begin(); icl != _controller.end(); ++icl)
	{
		CtrlList* cl = icl->second;
		int id = cl->id();

		// Remove old events from record region.
		if (_automationType == AUTO_WRITE)
		{
			int start = audio->getStartRecordPos().frame();
			int end = audio->getEndRecordPos().frame();
			iCtrl s = cl->lower_bound(start);
			iCtrl e = cl->lower_bound(end);

			// Erase old events only if there were recorded events.
			for (iCtrlRec icr = _recEvents.begin(); icr != _recEvents.end(); ++icr)
			{
				if (icr->id == id) // && icr->type == ARVT_VAL && icr->frame >= s->frame && icr->frame <= e->frame)
				{
					cl->erase(s, e);
					break;
				}
			}
		}
		else
		{ // type AUTO_TOUCH
			for (iCtrlRec icr = _recEvents.begin(); icr != _recEvents.end(); ++icr)
			{
				// Don't bother looking for start, it's OK, just take the first one.
				// Needed for mousewheel and paging etc.
				//if (icr->id == id && icr->type == ARVT_START)
				if (icr->id == id)
				{
					int start = icr->getFrame();

					if (icr == _recEvents.end())
					{
						int end = audio->getEndRecordPos().frame();
						iCtrl s = cl->lower_bound(start);
						iCtrl e = cl->lower_bound(end);
						cl->erase(s, e);
						break;
					}

					iCtrlRec icrlast = icr;
					++icr;
					for (;; ++icr)
					{
						if (icr == _recEvents.end())
						{
							int end = icrlast->getFrame();
							iCtrl s = cl->lower_bound(start);
							iCtrl e = cl->lower_bound(end);
							cl->erase(s, e);
							break;
						}

						if (icr->id == id && icr->type == ARVT_STOP)
						{
							int end = icr->getFrame();
							// Erase everything up to, not including, this stop event's frame.
							// Because an event was already stored directly when slider released.
							if (end > start)
								--end;

							iCtrl s = cl->lower_bound(start);
							iCtrl e = cl->lower_bound(end);

							cl->erase(s, e);

							break;
						}

						if (icr->id == id)
							icrlast = icr;
					}
					if (icr == _recEvents.end())
						break;
				}
			}
		}

		// Extract all recorded events for controller "id"
		//  from CtrlRecList and put into cl.
		for (iCtrlRec icr = _recEvents.begin(); icr != _recEvents.end(); ++icr)
		{
			if (icr->id == id && (icr->type == ARVT_VAL || icr->type == ARVT_START))
				cl->add(icr->getFrame(), icr->val);
		}
	}

	// Done with the recorded automation event list. Clear it.
	_recEvents.clear();

	// Try oom without this, so that the user can remain in automation write mode
	//  after a stop.
	/*
	if (automationType() == AUTO_WRITE)
	  {
		  setAutomationType(AUTO_READ);
		  song->update(SC_AUTOMATION);
	  }
	 */

}/*}}}*/