«click clack toot // fm-grains» by _Lf0

on 18 Dec'16 18:12 in fm grains envelope modulation

/* clicks and ambience. click clack tooot..... partly loud clicks...

i tried to practice granular synthesis but failed in the end to make nice randomized modulation envelopes. */

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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
/*
 clicks and ambience. click clack tooot.....
   partly loud clicks...

 i tried to practice granular synthesis but failed in the end to make
 real nice randomized modulation envelopes. 

 flo.huth
 
*/

s.boot;

(
~r=Routine{
	1.do{

		~hall = Bus.audio(s,2);
		~main = Bus.audio(s,2);


		~a = Routine{ var n,i,a,b;

			n= 3;

			~arrays = Array.new(n);

			i = 0;

			n.do{

				i=i+1;

				a = Buffer.alloc(s,512);
				b = Array.fill(i,{1/i});


				a.sine1(b);

				~arrays.add(a);

			}
		}.play;

		0.5.wait;

		SynthDef(\mainOut,
			{
				arg gate,amp,ffreq=24000,q=0,dist=1;

				var in,mix,out;

				in = In.ar(~main,2);

				mix = in*amp;


				mix = CompanderD.ar(mix,0.92,0.9,1,0.1,0.1);

				mix = Limiter.ar(mix,1);

				OffsetOut.ar(0,mix);
				//OffsetOut.ar(3,mix);
			}
		).add;

		SynthDef(\hall,
			{
				arg t_gate=1,amp,size,t60,att,dec;

				var in,efx,mix,env;

				in = In.ar(~hall)*amp;

				//efx = FreeVerb1.ar(in,size);
				efx = JPverb.ar(in,t60,0,size);

				//env = EnvGen.kr(Env.asr(att,1,dec),gate:t_gate,doneAction:0);

				efx = efx;

				Out.ar(~main,efx);

			}
		).add;

		SynthDef(\fmGrain,
			{
				arg gate=1,trigger,dense,offset,freq,modFreq,size,wave,mul,index=1,
				gAtt=0.001,gDec=0.4,


				bPoints = #[0,1,1,1,1,1,1,1,1,1,1,0],
				bTimes = #[1,1,1,1,1,1,1,1,1,1,0],

				mPoints1 = #[1,1,1,1,1], mTimes1 = #[1,1,1,1],

				mPoints2 = #[1,1,1,1,1], mTimes2 = #[1,1,1,1];


				var rand1,rand2,imp, osc, win, env, mix;

				rand1 = EnvGen.kr(Env.new(mPoints1,mTimes1,\exp),gate:gate);

				rand2 = EnvGen.kr(Env.new(mPoints2,mTimes2,\exp),gate:gate);

				imp = Select.ar(K2A.ar(trigger),
					[
						Impulse.ar(dense*rand1,[0,offset]),
						Dust.ar(dense*rand1)
				]);

				win = EnvGen.ar(Env.new([0,1,0],[((dense.reciprocal/size)*rand1)*gAtt,
					((dense.reciprocal/size)*rand1)*gDec]),gate:imp);

				osc = Osc.ar(wave,modFreq);

				osc = Osc.ar(wave,freq,(osc*index*rand2));

				//osc = Mix.ar(osc);

				//osc = BPF.ar(osc,TRand.ar(60,12000,imp),LFNoise2.kr(1).linlin(-1,1,0.5,1));

				osc = Pan2.ar(osc,LFNoise2.kr(TRand.kr(0,4.0,gate)));

				env = EnvGen.ar(Env.new(bPoints,bTimes),gate:gate,doneAction:2);

				mix = (osc*win)*env;

				mix = HPF.ar(mix,90);


				OffsetOut.ar(~main,mix.scope);
				OffsetOut.ar(~hall,mix*0.2);
			}
		).add;

		0.5.wait;


		~c = Group.new;

		Synth(\mainOut,[\gate,1,\amp,0.2],~c,\addToTail);


		~verbos=Pmono(\hall,
			\gate,1,
			\amp,Pexprand(0.1,0.7,inf),
			\size,Pwhite(0.1,0.9,inf),
			\t60,Pexprand(0.1,12,inf),

			\dur,Pwhite(0.1,7.0,inf),

			\att,Pkey(\dur)/2,
			\dec,Pkey(\dur)/2,

			\group,~c,
			//\addAction,1
		).play;

		~tones=Routine{
			inf.do{

				var freq = ([0,2,3,7,9,10,12,15,19].choose+22).midicps;
				var dense =exprand(12,120);

				Synth(\fmGrain,
					[
						\trigger,2.rand,

						\gate,1,
						\freq,freq,

						\modFreq,freq*rrand(1,4)+rrand(-0.1,0.1),
						\index,1.0.rand,

						\dense,dense,
						\size,rrand(2,8.0),
						\offset,0.5,

						\gAtt,rrand(0.1,1),
						\gDec,1,

						\wave,~arrays[3.rand],
						\mul,exprand(0.2,1.0),


						//global Env
						\bPoints,Array.fill(9,{|a| a=a+rrand(-0.2,0.2); a.sin})++0,
						\bTimes,Array.exprand(10,3.01,1.0),

						//dense env
						\mPoints1, Array.exprand(5,0.01,16.0), //no zeroes
						\mTimes1, Array.exprand(4,0.01,6.0),        //no zeroes

						//index env
						\mPoints2, Array.exprand(4,0.01,6.0)++0, //no zeroes
						\mTimes2, Array.exprand(4,0.01,6.0),        //no zeroes

					],~c,\addToHead
				);

				8.wait;
			}
		}.play;
	}
};

AppClock.play(~r);
)


//kill the mess

[~verbos,~tones].stop;s.freeAll;

~arrays[0].plot
raw 3866 chars (focus & ctrl+a+c to copy)
reception
comments