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

[sc-dev] In.kr only needed for multi-channel .kr ?



these examples use Synth and NodeControl which i posted the other day...
but which had a little bug.  new version at:
http://crucial-systems.com/code/sc3Synth


// i expect to take in a float value
SynthDef("moto-rev-kramp2", { arg amp=1.0;
	var x;
x = RLPF.ar(LFPulse.ar(SinOsc.kr(0.2, 0, 10, 21), [0,0.1], 0.1), 100, 0.3).clip2(0.4);
	Out.ar(0, x * amp);
}).writeDefFile;

// but i'm going to map it to the control bus this line is playing on
SynthDef("line", { arg krout=0;
	var line;
	line = Line.kr(1, 0, 10);
	Out.kr(krout,line);
}).writeDefFile;


(
	r = Routine({
		var line,motorev,motoControl;
		
		line = Synth.new;
		motorev = Synth.new;
		motoControl = NodeControl(motorev,0);
		
		3.do({	
					
			0.5.postln.wait;
line.playSynthDef("line",[3]); // line starts playing first on krbus 3
			motorev.playSynthDef("moto-rev-kramp2",[0.1]); // amp is 0.1
			
			4.wait;
			motoControl.readFromBus(3); // now listen to the buss
			8.wait;
			
			motoControl.value = 0.4; // back to a float
			2.wait;
			
			line.free;
			motorev.free;
	
			1.wait;
		});
						
	});
	SystemClock.play(r);
)


but if you wanted multi-channel .kr in you would have to definitely use an
In.kr(buss,numChannels)

otherwise your synth def is only going to be ready to handle a single channel. its going to have to know in advance precisely how many channels are in the control input.



example 2:




// i am expecting a stereo line, using In.kr
SynthDef("moto-rev-kramp3", { arg amp=0;
	var x;
x = RLPF.ar(LFPulse.ar(SinOsc.kr(0.2, 0, 10, 21), [0,0.1], 0.1), 100, 0.3).clip2(0.4);
	Out.ar(0, x * In.kr(amp,2));
}).writeDefFile;


SynthDef("stereo-line", { arg krout=0, start=1, end=0, dur=20;
	var line;
	line = Line.kr( [end,start],[start,end], dur);
	Out.kr(krout,line);
}).writeDefFile;


 (   // modulate by a stereo kr line playing in a different synth
	r = Routine({
		var line,motorev,motoControl;
		
		line = Synth.new;
		motorev = Synth.new;
		motoControl = NodeControl(motorev,0);
		
		2.do({	
					
			0.5.postln.wait;
line.playSynthDef("stereo-line",[0,1,0,25]); // play on krbus starting at 3 motorev.playSynthDef("moto-rev-kramp3",[0]); // start by reading from krbuss 3
			
			4.wait;
			15.do({
				motoControl.value = 0.1; // just sets the first channel
				0.3.wait;
				motoControl.value = 1.1;
// and the other channel gets left alone to read from the bus ? 0.3.wait;
			});
					
			motoControl.readFromBus(3); // now listen to the buss again
			8.wait;
			
			2.wait;
			
			line.free;
			motorev.free;
	
			1.wait;
		});
						
	});
	SystemClock.play(r);
)


so how can i set both of the values of a multi-channel control ?
if the SynthDef expects more than one channel because of an In.kr(buss,2)
how can /n_set be used to set both of those ?



-felix