hi all
I have 8 objects with contact mics and I want to find out when two of them collide with each other. Eg, object in channel 2 and object in channel 6 hit each other.
I thought I could use multichannel expansion with SoundIn.ar([0,1,2,3,4,5,6,7]) and that Onsets would report sometime like [0,0,0,1,0,0,1,0] with the onset situation of each channel but instead I am getting [1,1,1,1,1,1,1,1] being sent when any onset is detected. I am using sendReply to send the data back to the lang.
This is the code
o = Server.default.options;
o.numInputBusChannels = 8;
o.numOutputBusChannels = 8;
s.boot;
s.meter(8,8);
SynthDef(\onsets, {|gain=1, threshold=0.1, relaxtime=0.05|
var onsets, signals, levels;
signals = SoundIn.ar([0,1,2,3,4,5,6,7]) * gain;
levels = WAmp.kr(signals, 0.04);
onsets = Onsets.kr(FFT(LocalBuf(2048), signals, wintype:1), threshold, \rcomplex,
relaxtime:relaxtime, floor:0.1, mingap:1, medianspan:11, whtype:1, rawodf:0);
SendReply.kr(onsets, '/onset', [Sweep.ar.asArray++onsets++levels] );
}).add;
p.free;
p = Synth(\onsets);
OSCdef(\txalaonsetOSCdef).free;
OSCdef(\txalaonsetOSCdef, {|msg, time, addr, recvPort|
msg.postln;
}, '/onset');
thanks
enrike