WT_Onset Onset detection from wavelet coefficient change


WT_Onset(buffer, threshold=0.5, mingap=5, rawodf=0)


Uses summed change of wavelet coefficient moduli as a measure of change for onset detection. Outputs 0 for no detection, 1 for detection. 


buffer - dwt buffer.

threshold - Minimum detection threshold

mingap - Minimum number of frames required to wait before retriggering

rawodf - Output the detection function rather than the 0 (no onset) 1 (onset) triggers



s.boot;

(

b = Buffer.alloc(s,1024,1);

c = Buffer.read(s,"sounds/a11wlk01.wav");

//c = Buffer.read(s,"/data/audio/mirdata/qmulonsetMIREX05/solo_drums/hi_hat.wav");

)


(

SynthDef("help-Onset", { arg out=0, bufnum=0, soundBufnum=2;

var in, chain,onset;

in = PlayBuf.ar(1, soundBufnum, BufRateScale.kr(soundBufnum), loop: 1);

chain = DWT(bufnum, in);

onset = WT_Onset.kr(chain, MouseX.kr(0.0,0.1), MouseY.kr(1,20)); 

//Out.ar(0,in); 

//Out.ar(out, [in,SinOsc.ar(440,0,0.1*Trig1.ar(Impulse.kr(5),0.05))]);

Out.ar(out, [in,SinOsc.ar(440,0,0.1*Trig1.ar(onset,0.05))]);

}).play(s,[\out, 0, \bufnum, b, \soundBufnum, c]);

)



//raw detection function plotted


(

{

var in, chain;

in = PlayBuf.ar(1, c, BufRateScale.kr(c), loop: 1);

chain = DWT(b, in);

WT_Onset.kr(chain, rawodf:1)*20.0; 

}.plot(1.0)


)


b.free; c.free;