«mutronome (brownian motion of beats)» by eli.rosenkim

on 20 Apr'22 13:23 in rhythmmetronomebrownianrelabi

beat absolute locations rather than deltas meander randomly each cycle

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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
//A metronome that mutates beat locations using something like Brownian Motion

(
SynthDef.new(\block, {
	arg freq=1000;
	var sig, env;
	sig = Impulse.ar(0)*10;
	sig = SVF.ar(sig, freq, 0.9);
	env = EnvGen.ar(Env.perc(0.01, 1), 1, doneAction: 2);
	sig = sig*env;
	sig = sig!2;
	Out.ar(0, sig);
}).add;
)

(
SynthDef.new(\clip, {
	arg freq=1000, res = 0.1;
	var sig, env;
	sig = ClipNoise.ar()*0.1;
	sig = SVF.ar(sig, freq, res);
	env = EnvGen.ar(Env.perc(0.01, 0.05), 1, doneAction: 2);
	sig = sig*env;
	sig = sig!2;
	Out.ar(0, sig);
}).add;
)


x = Synth.new(\block, [\freq, 1000]);
x = Synth.new(\block, [\freq, 800]);


//mutating 4/4 metronome
(
~mutro = {
	var  i = 0, deltas, randos, out, maxStep;
	deltas = List[0.7, 0.7, 0.7, 0.7]; //starting deltas for each beat
	randos = List[0, 0, 0, 0]; //random values for each beat, first bar plays straight as randos are all 0
	maxStep = deltas[0]/10;
	loop{
		out = ((deltas[i] - randos[(i-1)%(deltas.size)] + randos[i]).abs); //if the first beat is pushed back by 0.2s, the second beat is moved forward 0.2s to keep it in roughly the same position before rando is added
		out.yield;
		i = (i+1)%(deltas.size);
		if(i%(deltas.size) == 0, //adds random value to each term of random array on beat one of each bar after bar 1
			{randos = randos.collect({arg item, i; item+(rrand(-1* maxStep, maxStep))})}
			//{"test".postln}
		);
	};
};



Pbind(
	\instrument, \block,
	\freq, Pseq([1000, 800, 800, 800], inf),
	\dur, Prout(~mutro);
).play;

)


//mutating triplets
(
~mutroblock = {
	var  i = 0, deltas, randos, out, maxStep;
	deltas = List[0.8, 0.8, 0.8, 0.8]; //starting deltas for each beat
	randos = List[0, 0, 0, 0]; //random values for each beat, first bar plays straight as randos are all 0
	maxStep = deltas[0]/40;
	loop{
		out = ((deltas[i] - randos[(i-1)%(deltas.size)] + randos[i]).abs); //if the first beat is pushed back by 0.2s, the second beat is moved forward 0.2s to keep it in roughly the same position before rando is added
		out.yield;
		i = (i+1)%(deltas.size);
		if(i%(deltas.size) == 0, //adds random value to each term of random array on beat one of each bar after bar 1
			{randos = randos.collect({arg item, i; item+(rrand(-1* maxStep, maxStep))})}
			//{"test".postln}
		);
	};
};

~mutroclip = {
	var  i = 0, deltas, randos, out, maxStep;
	deltas = List[0.8*(1/3), 0.8*(1/3), 0.8*(1/3)];
	randos = List[0, 0, 0];
	maxStep = deltas[0]/40;
	loop{
		out = ((deltas[i] - randos[(i-1)%(deltas.size)] + randos[i]).abs);
		out.yield;
		i = (i+1)%(deltas.size);
		if(i%(deltas.size) == 0,
			{randos = randos.collect({arg item, i; item+(rrand(-1* maxStep, maxStep))})}
		);
	};
};



Pbind(
	\instrument, \block,
	\freq, Pseq([1000, 800, 800, 800], inf),
	\dur, Prout(~mutroblock);
).play;

Pbind(
	\instrument, \clip,
	\freq, Pseq([10000, 9000, 8000], inf),
	\res, Pseq([0.1, 0.2, 0.3, 0.1], inf),
	\dur, Prout(~mutroclip);
).play;


)
raw 3017 chars (focus & ctrl+a+c to copy)
reception
comments