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

Re: [sc-dev] sample accurate scheduling and thisThread.time



Hi again,

 I think I  got sample accuracy to go  by wrapping the pattern in a
Routine and scheduling the Routine rather than the Pattern.  Why is this
necessary?

Below is the example, it relies on having the corrected OffsetOut and
having the wrapper class defined for the SC interpreter (included at the
end commented out) to get to it.

RJK

s = Server.default;
s.boot;
s.start;

SynthDef("tone", { arg freq=800, rate=8, amp=0.1, gate =1, offset = 0; 
        var  osc;
        osc = SinOsc.ar(freq);
        osc = EnvGen.kr(Env.adsr(0,0,0.5,0),gate) * osc;
        OffsetOut.ar(0,offset, osc) 
}).writeDefFile;

s.sendMsg("/d_load","engine/synthdefs/tone.scsyndef");

a = Pbind(
		\latency, 0.05,	
		\instrument,'tone', 
		\freq, Pfunc({ 882.5}), 
		\offset, Pfunc({ thisThread.time.postln; 
				(thisThread.time * 44100 % 64).asInteger; 
		}),
		\sustain,2,
		\dur,Pseq([1.00],2)		
		
);
b = Pevent(a, Event.protoEvent).asStream;
SystemClock.play(Routine({ loop({ b.next.yield })  }) );

/*
OffsetOut : UGen {
	*ar { arg bus, offset, chans;
		this.multiNewList(['audio', bus, offset] ++ chans.asArray)
		^0.0		// Out has no output
	}
	numOutputs { ^0 }
	writeOutputSpecs {}
 	checkInputs {
 		if (rate == 'audio', {
 			for(2, inputs.size - 1, { arg i;
 				if (inputs.at(i).rate != 'audio', { ^false
});
 			});
 		});
 		^true
 	}
}*/