View this PageEdit this PageUploads to this PageHistory of this PageTop of the SwikiRecent ChangesSearch the SwikiHelp Guide

building a bridge of peace between the client and the server

// building a bridge of peace between client and server
// rohrhuber 12/03



// preparations
(
b = 16; // scale buffer number
n = 6; // 6 tone scale
s.sendMsg("/b_alloc", b, n);// allocate scale buffer
)

// create a random scale
(
var steps, scale, sum=0; 
steps = Array.fill(n - 1, { [1, 2, 3].choose });
scale = Array.with(0);
steps.do { arg item, i; scale = scale.add(sum = item + sum) };
f = scale.postln;
s.sendBundle(nil, ["/b_setn", b, 0, f.size] ++ f);
)

// send synth definitions
(
SynthDef(\sinsin, { arg out=0, freq=440, amp=0.1, pan=0, gate=1;
			var z;
			z = SinOsc.ar(freq * Line.kr(1.5, 1, 0.01)) 
			* Line.kr(amp * 0.7, 0, ExpRand(0.1, 0.8), doneAction:2);
			Out.ar(out, Pan2.ar(z, pan));
		}).send(s);
		
SynthDef("wind", { arg out;
	var freq, z;
	freq = midicps(
			DegreeToKey.kr(b, LFNoise0.kr(7 / 8 * 1, n/2, n/2), f.last, 1, 72)
			+ LFNoise1.kr([1,1] * 8, 0.3)
		);
	z = Resonz.ar(PinkNoise.ar(LFNoise1.ar(freq *[1,1], 20).max(0)), freq, 0.01);
	Out.ar(out, z);
}).send(s)
)

// play server and client process together
(
Pbind(
	\instrument, \sinsin, 
	\scale, Pfunc({ f }), 
	\dur, 1/7 * Prand([Pn(1, 12), Pn(3, 4)], 24), 
	\octave, 6,
	\degree, Pfunc({ 10.rand }), 
	\amp, 0.2,
	\player, NoteDurPlayer.new
).play;
TempoClock.default.play({ s.sendBundle(s.latency, ["/s_new", "wind", 1345]); nil });
)


// evaluate this to create random scale
(
var steps, scale, sum=0; 
steps = Array.fill(n - 1, { [1, 2, 3].choose });
scale = Array.with(0);
steps.do { arg item, i; scale = scale.add(sum = item + sum) };
f = scale.postln;
s.sendBundle(nil, ["/b_setn", b, 0, f.size] ++ f);
)

// detune 
(
5.do { var x; x = f.size.rand; f[x] = f[x] + 1.0.rand2 };
s.sendBundle(nil, ["/b_setn", b, 0, f.size] ++ f);
)



***************
/*
authors so far:
jrh
*/


Links to this Page