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

Re: [sc-users] recording mouse gestures



// and here an example with 8 synths ktlloops and guis:

(
s.scope(8); 

SynthDef(\spat, { |out, amp = 0.2, dens = 300, freq = 600, rq = 0.01, azim = 0, dist = 1|
	var snd = Ringz.ar(Dust2.ar(300), freq, 0.01) * amp;
	var ring = PanAz.ar(8, snd, azim); 
	var panned = (snd * (1/8)).blend(ring, dist);
	Out.ar(out, panned);
}).add;

// make an 8 8chan pannable synths
~spats = 8.collect { 
	Synth(\spat, [
		\freq, exprand(300, 3000), \dens, exprand(50, 500),
		\azim, 2.0.rand;
	]);
};

// make 8 ktlloops for them
~ktlps = ~spats.collect { |sp, i| 
	var ktlname = ("sp" ++ i).asSymbol;
	var ktloop = KtlLoop(ktlname, { |ev| sp.set(\azim, ev.azim, \dist, ev.dist) });
	ktloop.object = sp;
};

~wins = ~ktlps.collect { |kl, i|
	var w, sl2d;
	w = Window("KtlLoop.help", Rect(320 * (i % 4), 380 * (i div: 4), 320, 380).postln).front;
	w.view.addFlowLayout;
	sl2d = Slider2D(w, Rect(5,5,190,190))
	.action_({ |sl|
		var polar = Polar(sl.x * 2 - 1, sl.y * 2 - 1);
		var azim = polar.angle / pi; // scale to 0, 2
		var dist = polar.magnitude; 
	
		var event = (azim: azim, dist: dist);
        // store it,
		kl.recordEvent(event.put(\type, \set));
        // and set the object from it
		kl.object.set(\azim, azim, \dist, dist);
	});

	// make an eventloopgui for KtlLoop
	KtlLoopGui(kl, parent: w, bounds: 310@180).skipjack.dt_(0.05);
};
)

> On 29/12/2015, at 13:53 , alberto.decampo <alberto.decampo@xxxxxxxxx> wrote:
> 
> Hi Ian, 
> 
>> On 29/12/2015, at 12:22 , Iain Mott <mott@xxxxxxxxxxxxxxx> wrote:
>> 
>> A question about KtlLoop: 
>> 
>> in the sample code in the help file for KtlLoop, the sound to be
>> controlled is defined within a node proxy definition (ndef). 
> 
> yes. should also work with plain synths, example below.
> Ndefs are really convenient placeholders for single synths, 
> which are easy to control, modify, play, pause, stop, 
> they remember their settings etc. etc., so I tend to use them 
> rather than raw synths most of the time. 
> 
> Also, I just updated some things in the KtlLoop quarks, so please update.
> 
>> 
>> The thing or things that I'm wishing to control are instances of a
>> synthdef that perform 2D spatialisation. These receive their audio input
>> via busses and perform ambisonic encoding and other steps in response to
>> distance and azimuth data received via the "set" method. So it's the
>> distance and azimuth data for each sound source that I wish to record
>> and play back (rather than x and y coords from the mouse directly). 
> 
> what you want to control is freely definable, so distance and azimuth should also work. 
> 
> for rescaling movements in space, using x y and converting to azim/dist in the synth func 
> may actually work nicely :-)
> 
>> 
>> What I was thinking of doing was to create an array of KtlLoop objects
>> for each of the instances synthdef. Something like this:
> 
> 
>> number_of_sound_sources.do { arg i;	
>> 
>> k[i] = KtlLoop(2Dspatializerinstances[i]);
>> 
>> };
>> 
>> 
>> This however gives a "wrong type" error.
>> 
>> Can synthdef instances be controlled by KtlLoop and if so how?
> 
> yes, based on your question, something like this:
> 
> SynthDef(\spat, { |out, amp = 0.2, dens = 300, freq = 600, rq = 0.01, azim = 0, dist = 1|
> 	var snd = Ringz.ar(Dust2.ar(300), freq, 0.01) * amp;
> 	var ring = PanAz.ar(8, snd, azim); 
> 	var panned = (snd * (1/8)).blend(ring, dist);
> 	Out.ar(out, panned);
> }).add;
> 
> s.scope(8); 
> 
> // make an 8chan pannable sound
> ~sp1 = Synth(\spat, [\freq, 600]);
> 
> // move ~sp1 - azim goes from 0..2, because it uses PanAz
> ~sp1.set(\azim, 0.5);
> ~sp1.set(\azim, 1);
> 
> ~sp1.set(\dist, 0); // in center of all 8
> ~sp1.set(\dist, 0.5); // centered on chans 5, 6, but present in all
> ~sp1.set(\dist, 1.0); // just on chans 5, 6
> 
> // a KtlLoop for sp1
> k = KtlLoop(\sp1, { |ev| ~sp1.set(\azim, ev.azim, \dist, ev.dist) });
> k.object = ~sp1;
> k.func.postcs;
> (
> w = Window("KtlLoop.help", Rect(0,500, 400, 550)).front;
> w.view.addFlowLayout;
> ~sl2d = Slider2D(w, Rect(0,0,190,190))
>    .action_({ |sl|
> 	var polar = Polar(sl.x * 2 - 1, sl.y * 2 - 1);
> 	var azim = polar.angle / pi; // scale to 0, 2
> 	var dist = polar.magnitude; 
> 	
> 	var event = (azim: azim, dist: dist);
>        // store it,
>    k.recordEvent(event.put(\type, \set));
>        // and set the object from it
>    k.object.set(\azim, azim, \dist, dist);
> });
> 
> // make an eventloopgui for KtlLoop
> KtlLoopGui(k, parent: w, bounds: 310@180).skipjack.dt_(0.05);
> )
> // a second synth would be
> ~sp2 = Synth(\spat, [\freq, 800, \dens, 200]);
> 
> // or make an array of synths 
> ~spats = 8.collect {  Synth(\spat, [\freq, exrand(300, 3000), \dens, 200]); };
> 
> …
> but that will need a lot more admin by hand that Ndefs can take care of very easily. 
> 
>> I did try entering the name of the synthdef itself as an argument to
>> KtlLoop and this produced no error, but I didn't go any further with
>> this. Not understanding ndef, I also tried redefining a synthdef
>> instance within an ndef - this produced a string of errors. 
> 
> Try going thru the Ndef helpfile, it has lots of examples :-)
> 
> best adc


_______________________________________________
sc-users mailing list

info (subscription, etc.): http://www.birmingham.ac.uk/facilities/ea-studios/research/supercollider/mailinglist.aspx
archive: https://listarc.bham.ac.uk/marchives/sc-users/
search: https://listarc.bham.ac.uk/lists/sc-users/search/