«wiard noise ring variation using a ringbuffer instead of bitshifting, language implementation (task-based)» by LFSaw

on 20 Mar'13 20:02 in code forksequenceralgorithmic composing

wiard noise ring variation using a ringbuffer instead of bitshifting. Reimplemented according to Julian Parker's m4l patch.

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
q = ();

q.registerSize = 16;
q.rbuf = RingBuffer(q.registerSize);

// parameters, can be changed while playing
q.min = "C2".namemidi.asInteger;
q.max = "C6".namemidi.asInteger;
q.waitTime = 0.05; // in seconds

q.chance = 0.1;
q.change = 10; // step size


(
// initialise
q.registerSize.do{
	q.rbuf.overwrite(rrand(q.min, q.max));
};

// do one step
q.step = {|q, rbuf, chance, step, min, max|
	var item;
	item = rbuf.pop;
	(chance.coin).if{
		// apply brown noise, bounce back from constraints.
		//"+++++++ change! % >> ".postf(item);
		item = (item + step.xrand2).fold(min, max); 
		item; //.postln;
	};
	rbuf.add(item);
	item; // return (altered) item
};

(
Tdef(\steppr, {
	var midinote;
	loop{
		midinote = q.step(q.rbuf, q.chance, q.change, q.min, q.max); 
		
		// debug output
		// q.rbuf.asArray.postln;
		
		// play the current note, can be basically everything
		(
			midinote: midinote, 
			sustain:  0.05, 
			dur:      0.2, 
			amp:      0.2
		).play;
		
		q.waitTime.wait;
	}
})
);
)


// start
Tdef(\steppr).play

// stop
Tdef(\steppr).stop
raw 1120 chars (focus & ctrl+a+c to copy)
reception
comments