«Confetti2X» by henk.lasschuit

on 10 Oct'12 23:53 in distributionxenakis

As Confetti2: http://sccode.org/1-31X in which you heard only one oscillator at the time. In SuperCollider it is easy to use 100 oscillators at the same time, so while a distribution is made, you can hear sounds that correspond with all the values in the box. That doesn't swing at all, instead it gives a kind of Xenakis-like experience.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
//Confetti 2, Xenakis-variant

Server.default.boot;
(
~red=0; 
~green=1;
~maxValue=32;  //change maxValue to 255 for the complete experience

(
/*There is a decreasing linear connection between log(freq) and value.
log(freq)=log(maxfreq)-((log(maxfreq)-log(minfreq))*value/maxValue), so
freq=exp(log(maxfreq)-((log(maxfreq)-log(minfreq))*value/maxValue))*/

SynthDef(\beeper, { arg value=150, pan=0;
	var maxfreq=10000, minfreq=50;
	Out.ar(0, Pan2.ar(SinOsc.ar(exp(log(maxfreq)-((log(maxfreq)-log(minfreq))*value/~maxValue)), 0, 0.01), pan, 1));
}).send(s);
);
)
(
~maxIndex=10;
z=40;

w=Window("Confetti2X", Rect(400, 300, z*~maxIndex, z*~maxIndex)).front;
w.view.background_(Color.white);
w.front;

//function for drawing array on screen

	w.drawHook = {
		for(0, ~maxIndex-1, { arg v;
			for(0, ~maxIndex-1, {arg h;
				~red=~tabel[v,h]/~maxValue;
				~green=1-(~tabel[v,h]/~maxValue);
				r = Rect(h*z+10, v*z, z,z); 					Pen.color=Color(~red, ~green, 0);
					Pen.addRect(Rect(h*z, v*z, z, z));
					Pen.fill;
				(~tabel[v,h]+32).asAscii.asString.drawInRect(r, Font("Times", 24));
					//remove "+32" when maxValue > 222, this may initially cause a blank window
			});
		});
	};


//initialize array and put on screen
(
Routine{
~tabel=Array2D(~maxIndex, ~maxIndex);
for(0, ~maxIndex-1, { arg v;
	for(0, ~maxIndex-1, {arg h;	
		~tabel.put(v, h,0);
	});		
});
{w.refresh}.defer;
}.play;);
//Initialize synths
(
Routine{
~syntabel=Array2D(~maxIndex, ~maxIndex);
for(0, ~maxIndex-1, { arg v;
	for(0, ~maxIndex-1, {arg h;	
		~syntabel.put(v, h,Synth(\beeper, [\value, 0, \pan, (2*h/~maxIndex)-1])); //pan corresponds with horizontal position in array
	});		
});
}.play;
);

Routine({
	v= ~maxIndex.rand;
	h= ~maxIndex.rand;
	while ({~tabel.at(v,h) <= ~maxValue}, {
		~tabel.put(v, h, ~tabel.at(v, h) + 1);
		~syntabel[v,h].set(\value, ~tabel.at(v,h));
		{w.refresh}.defer;
		v= ~maxIndex.rand;
		h= ~maxIndex.rand;
		0.125.wait
	});
	10.wait;
	for(0, ~maxIndex-1, { arg v;
		for(0, ~maxIndex-1, {arg h;	
			~syntabel[v,h].free;
		});
	});
}).play;
	
)
raw 2139 chars (focus & ctrl+a+c to copy)
reception
comments