oneShot: free the responder before running user func (avoid error)
[supercollider.git] / HelpSource / Classes / PV_HainsworthFoote.schelp
blobf0f14322c3801a0e9ddb5404a9c74380d71907f7
1 class:: PV_HainsworthFoote
2 summary:: FFT onset detector.
3 related:: Classes/PV_JensenAndersen
4 categories::  UGens>FFT
7 Description::
9 FFT onset detector based on work described in emphasis:: Hainsworth, S. (2003) Techniques for the Automated Analysis of Musical Audio. PhD, University of Cambridge engineering dept. ::
10 See especially p128. The Hainsworth metric is a modification of the Kullback Liebler
11 distance.
14 The onset detector has general ability to spot spectral change, so may
15 have some ability to track chord changes  aside from obvious transient
16 jolts, but there's no guarantee it won't be confused by frequency
17 modulation artifacts.
20 Hainsworth metric on it's own gives good results but Foote might be
21 useful in some situations: experimental.
24 classmethods::
25 private:: categories
27 method::ar
29 argument::buffer
31 FFT buffer.
34 argument::proph
36 What strength of detection signal from Hainsworth metric to use.
39 argument::propf
41 What strength of detection signal from Foote metric to use. The
42 Foote metric is normalised to (0..1).
45 argument::threshold
47 Threshold hold level for allowing a detection.
50 argument::waittime
52 If triggered, minimum wait until a further frame can cause
53 another spot (useful to stop multiple detects on heavy signals).
56 Examples::
58 code::
60 //just Hainsworth metric with low threshold             
62 b=Buffer.alloc(s,2048,1);
63         
64 SynthDef(\fftod,
66  var source1, detect;
67         
68         source1= AudioIn.ar(1); 
69         
70         detect= PV_HainsworthFoote.ar(FFT(b.bufnum,source1), 1.0, 0.0);
71         
72         Out.ar(0,SinOsc.ar([440,445],0,Decay.ar(0.1*detect,0.1)));
73 }).play(s);     
74 )       
75         
77 //spot note transitions         
79 b=Buffer.alloc(s,2048,1);
80         
81 SynthDef(\fftod,
83  var source1, detect;
84         
85         source1= LFSaw.ar(LFNoise0.kr(1,90,400),0,0.5); 
86         
87         detect= PV_HainsworthFoote.ar(FFT(b.bufnum,source1), 1.0, 0.0, 0.9, 0.5);
88         
89         Out.ar(0,Pan2.ar(source1,-1.0)+ Pan2.ar(SinOsc.ar(440,0,Decay.ar(0.1*detect,0.1)),1.0));
90 }).play(s);     
91 )       
95 //Foote solo- never triggers with threshold over 1.0, threshold under mouse control     
97 b=Buffer.alloc(s,2048,1);
98         
99 SynthDef(\fftod,
101  var source1, detect;
102         
103         source1= AudioIn.ar(1); 
104         
105         detect= PV_HainsworthFoote.ar(FFT(b.bufnum,source1), 0.0, 1.0, MouseX.kr(0.0,1.1), 0.02);
106         
107         Out.ar(0,Pan2.ar(source1,-1.0)+ Pan2.ar(SinOsc.ar(440,0,Decay.ar(0.1*detect,0.1)),1.0));
108 }).play(s);     
112 //compare to Amplitude UGen
114 b=Buffer.alloc(s,2048,1);
115         
116 SynthDef(\fftod,
118  var source1, detect;
119         
120         source1= AudioIn.ar(1); 
121         
122         detect= (Amplitude.ar(source1)) > (MouseX.kr(0.0,1.1));
123         
124         Out.ar(0,Pan2.ar(source1,-1.0)+ Pan2.ar(SinOsc.ar(440,0,Decay.ar(0.1*detect,0.1)),1.0));
125 }).play(s);