I'm trying to write some code that triggers three different BufRecs, alternately, based on an amplitude trigger.
I was thinking the way to do it would involve using a SynthDef that toggled outputs to 3 different OSCDefs.. The code seems to send to all three OSCDefs at once, though - the "Select.kr" doesn't seem to cut it..
b=Buffer.alloc(s, 512);
(
SynthDef(\amptrack, {
arg in=0, thresh=0.1;
var sig, amp, rms, chain;
sig = SoundIn.ar(in);
chain = FFT(b, sig);
amp = Onsets.kr(chain, threshold: 4, relaxtime:0.2 );
Select.kr(2, [
SendReply.kr(amp, '/one', [1]),
SendReply.kr(amp, '/two', [2]),
SendReply.kr(amp, '/three', [3])
]);
}).play;
OSCdef.new(\why, {
arg msg, amp;
var counter = 0;
"one".postln;
msg[3].postln;
}, '/one');
OSCdef.new(\why2, {
arg msg, amp;
var counter = 0;
"two".postln;
msg[3].postln;
}, '/two');
OSCdef.new(\why3, {
arg msg, amp;
var counter = 0;
"three".postln;
msg[3].postln;
}, '/three');
)