«Custom event type for wiring up effects» by david_morgan

on 28 Apr'16 04:03 in event type
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
(
// add custom event
Event.addEventType(\nbind, {arg server;

	var id = (currentEnvironment[\ndef] ? currentEnvironment[\instrument]).asSymbol;
	var type = \note;

	if (Ndef(id).isPlaying.not) {
		Ndef(id).play;
	};

	~type = type;
	~group = Ndef(id).group;
	~out = Ndef(id).bus;

    currentEnvironment.play;
});

// synth
SynthDef(\synth1, {arg freq = 440, out = 0;
	
	var env = Env.perc.kr(doneAction:2);
	var sig = SinOscFB.ar(freq * [1, 1.01], 0.7);
	sig = sig * env;
	OffsetOut.ar(out, Splay.ar(sig));
	
}).add;

// set up first set of fx
Ndef(\fx1).play;
Ndef(\fx1)[0] = \filter -> {arg in;
	in.abs;
};

// set up additional fx
Ndef(\fx2).play;
Ndef(\fx2)[0] = \filter -> {arg in;
	in + AllpassC.ar(in, 0.2, 0.2, [3, 5]);
};

)

// play a pattern
Pbind(\instrument, \synth1, 
	// specify custom event type
	\type, \nbind, 
	// switch between fx
	\ndef, Pseq([\fx1, \fx2], inf),
	\degree, Pwhite(0, 5, inf)
).play;
raw 970 chars (focus & ctrl+a+c to copy)
reception
comments