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

Re: [sc-users] Synth Definition Argument Control



James Harkins <jamshark70@xxxxxxxxx> writes:

> best technique is to write your control values onto control buses

Thank you. Works great. 

Here's what I did: 

//create a little cute control bus
y = Bus.control(s,1);
//set value
y.set(2300);

//bind a midi controller to it (channel 1, number 17)
MIDIIn.control = {arg src, chan, num, val;
			if(chan == 0,{
				if(num == 17,{
					y.set(val*10);					
				});
			});
};


//create synth

SynthDef("tutorial-sine", { arg out=0, amp=1.0, freq=140, i_dur=1.0;
	var env, sine;
	env = Line.kr(1, 0, i_dur, doneAction: 2, mul: amp);
	sine = SinOsc.ar(freq , mul: env);
	// output two channels on bus 0
	Out.ar(0, [sine, sine]);
}).send(s);

// I then make a task 
o = Task({
	var	startCycle;
	loop{
		startCycle = thisThread.clock.beats;
		0.15.wait;  
		//map variable to the y bus at each run
		w = Synth("tutorial-sine"); w.map(\freq, y.index);
		(startCycle + 8.0 - thisThread.clock.beats).wait;
	}
})

//transport
o.play(*~args);
o.stop;

-- 
Esben Stien is b0ef@e     s      a             
         http://www. s     t    n m
          irc://irc.  b  -  i  .   e/%23contact
          [sip|iax]:   e     e 
           jid:b0ef@    n     n