«Simple Amplitude Trigger (language side)» by rukano

on 21 Oct'13 12:45 in amplitude trigger

Simple amplitude trigger using Onsets, Amplitude and SendReply for sending triggers to sclang from SoundIn.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
(
// Simple amplitude trigger
SynthDef(\ampTrigger, { |in|
	var snd = SoundIn.ar(in);
	var chain = FFT(LocalBuf(512), snd);

	// here tune the threshold and sensitivity:
	var trig = Onsets.kr(chain, 0.5);

	SendReply.kr(trig, '/ampTrigger', Amplitude.kr(snd));
}).add;
)

// start the tracker on scsynth
Synth(\ampTrigger);

(
// receive the values in sclang
OSCdef(\ampTrigger, { |m|
	m.postln;
	// now use m[3] for your purpose
	// or just fire up a synth from this function ;)
}, '/ampTrigger');
)
raw 523 chars (focus & ctrl+a+c to copy)
reception
comments