[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [sc-users] OSC Pattern Scheduling



BTW, there are some problems using Routine and Task, if you need to start and stop them in rapid succession (see posts from earlier this year concerning "routine buildup"). James Harkins provided a wonderful solution for this called BetterTask, which I attach to this message.

LF

Esben Stien wrote:
tom tlalim <ttlalim@xxxxxxxxx> writes:

  
s.stop
s.reset
s.play;
    

Nice;). 

I use r.play(TempoClock.default, [4.0, -0.15]);

I have two routines. One routine contains the snare and the other, the
big drum. Each routine contains 8 beats. When I start the routine, is
there any way to have them start counting at the same relative beat?. 

Now the snare end on top of the big drum for some reason. 

Entire code is:

Tempo.bpm = 90;
r = Routine({
	var	startCycle;
	loop{
		startCycle = thisThread.clock.beats;
		//		Synth.new(\DrumSineBass);
		//1-0.1
		Synth("kickDrum",[\gate,1,\vol,0.4]);  
		0.15.wait;  
		
		// 1
		//		Synth("kickDrum3",[\gate,1]);
		Synth("bd4",[\gate,1]);
		0.5.wait;  
		
		// 1.5
		Synth("bd4",[\gate,1]);  
		1.5.wait;  
 		// 3.0
		Synth("bd4",[\gate,1]);  
		0.5.wait;  
		//3.5
		Synth("bd4",[\gate,1]);  
		1.5.wait;
		// 5.0
		Synth("bd4",[\gate,1]);  
		0.48.wait;  
		// 5.48
		Synth("bd4",[\gate,1]);  
		0.52.wait;
		//6.0
		0.89.wait;
		//6.89
		Synth("bd4",[\gate,1,\vol,0.6]);  
		0.11.wait;
		//7.00
		Synth("bd4",[\gate,1,\vol,0.9]);  
		0.538.wait;
		//7.538
		Synth("bd4",[\gate,1,\vol,0.9]);  
		0.462.wait;
		//8.0
		0.38.wait;
		//8.38
		Synth("bd4",[\gate,1,\vol,0.9]);  
		// we know exactly when the cycle started, so we can add 4 and subtract the current logical time
		(startCycle + 8.0 - thisThread.clock.beats).wait;
		// now we're at the original integer beat + 4.9 (or 8.9, etc.)
	}
})
r.play(TempoClock.default, [4.0, -0.15]);
r.stop;
r.reset;

s = Routine({
	var	startCycle;
	loop{
		startCycle = thisThread.clock.beats;
		//1-0.1
		2.15.wait;  
		// 2.0
		Synth("snare909ish");
		2.0.wait;  
		// 4.0
		Synth("snare909ish");
		2.0.wait;  
		//6.0
		Synth("snare909ish");
		2.0.wait;
		//8.0
		Synth("snare909ish2");

		// we know exactly when the cycle started, so we can add 4 and subtract the current logical time
		(startCycle + 8.0 - thisThread.clock.beats).wait;
		// now we're at the original integer beat + 4.9 (or 8.9, etc.)
	}
})
//.play(TempoClock.default, [4.0, -0.15]);

s.play(TempoClock.default, [4.0, -0.15]);
s.stop;
s.reset;

  
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf110
{\fonttbl\f0\fnil\fcharset77 Monaco;\f1\fswiss\fcharset77 Helvetica;}
{\colortbl;\red255\green255\blue255;}
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f0\fs18 \cf0 \
////BettetTask by James Harkins\
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural\pardirnatural

\f1\fs24 \cf0 BetterTask : Task \{\
	var	<isWaiting = false;\
\
	play \{ arg argClock, doReset = (false), quant=0.0;\
		if (stream.notNil, \{ "already playing".postln; ^this \});\
		if (doReset, \{ this.reset \});\
		clock = argClock ? clock ? TempoClock.default;\
		streamHasEnded = false;\
		stream = originalStream;\
		isWaiting = true;\
		clock.play(\{\
			if(isWaiting and: \{ nextBeat.isNil \}) \{\
				clock.sched(0, this);\
				isWaiting = false;\
			\};\
			nil\
		\}, quant);\
		^this\
	\}\
\
	stop \{\
		stream = nil;\
		isWaiting = false;\
	\}\
\
	pause \{ this.stop \}\
\}
\f0\fs18 \
\
}