«Red alert» by DSastre

on 22 Nov'12 17:21 in alarmsiren

Based on pure data code from the book "Designing Sound" by Andy Farnell. (Chapter 58)

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
//Fig 58.7: Red alert
//Complete patch, saw + second harmonic, resonators, distortion and post filters to create 
//fixed resonance. Contains the subpatch shown in fig 58.6.

(
	SynthDef(\red, {
 
	var env, redAlert, dfbe, aIn, bIn, cIn, aOut, bOut, cOut;
 
	# aIn, bIn, cIn = LocalIn.ar(7).clumps([5,1,1]);
 
	env = [
		EnvGen.ar(Env.new([0,1,1,0], [0.9, 0.3, 0.0])), 
		EnvGen.ar(Env.new([0,1,1,0], [0.01, 0.88, 0.01]))
	];
	env[0] = LFSaw.ar(env[0].sqrt * 487 + 360, 1, 0.5, 0.5);
	env[0] = (env[0] - 0.5) + ((env[0] * 2 * 2pi).cos * 0.3);
	redAlert = (env[0] - OnePole.ar(env[0], exp(-2pi * (1 * SampleDur.ir)))) * env[1];
	redAlert = redAlert + (cIn * 0.006) * 0.2;
 
 
	// fig 58.6: Delay feedback element
	dfbe = 0!6;
	redAlert = redAlert + (aIn * 0.7);
	5.do{|i| dfbe[i] = DelayN.ar(redAlert[i], 0.1, [0.015, 0.022, 0.035, 0.024, 0.011][i])};
	aOut = dfbe[0..4]; 
 
	redAlert = redAlert[0..4].sum;
	redAlert = (redAlert - OnePole.ar(redAlert, exp(-2pi * (12 * SampleDur.ir))));
 
	dfbe[5] = redAlert + (bIn * 0.7);
	dfbe[5] = DelayN.ar(dfbe[5], 0.1, 0.061);
	# bOut, cOut = dfbe[5]!2;
	LocalOut.ar(aOut ++ bOut ++ cOut);
 
	redAlert = Clip.ar(redAlert * 4, -1, 1);
	redAlert = BPF.ar(redAlert, [740, 1400, 1500, 1600], (12!4).reciprocal) ++ (redAlert * 0.5);
	Out.ar(0, (redAlert.sum * 0.2)!2);
 
}).add;
)
 
// ALL HANDS!! BATTLESTATIONS!
e = Synth(\red);



// code also available here: 
// http://en.wikibooks.org/wiki/Designing_Sound_in_SuperCollider/Red_alert
raw 1520 chars (focus & ctrl+a+c to copy)
reception
comments