linux: shared memory interface - link with librt
[supercollider.git] / HelpSource / Classes / PV_HainsworthFoote.schelp
blob7f4099c122f6336467cb74525a411aea80a84700
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 SynthDef(\fftod, {
63         var source1, detect;
64         source1= AudioIn.ar(1);
65         detect= PV_HainsworthFoote.ar(FFT(LocalBuf(2048),source1), 1.0, 0.0);
66         Out.ar(0,SinOsc.ar([440,445],0,Decay.ar(0.1*detect,0.1)));
67 }).play(s);
71 //spot note transitions
73 SynthDef(\fftod, {
74         var source1, detect;
75         source1= LFSaw.ar(LFNoise0.kr(1,90,400),0,0.5);
76         detect= PV_HainsworthFoote.ar(FFT(LocalBuf(2048),source1), 1.0, 0.0, 0.9, 0.5);
77         Out.ar(0,Pan2.ar(source1,-1.0)+ Pan2.ar(SinOsc.ar(440,0,Decay.ar(0.1*detect,0.1)),1.0));
78 }).play(s);
83 //Foote solo- never triggers with threshold over 1.0, threshold under mouse control
85 SynthDef(\fftod, {
86         var source1, detect;
87         source1= AudioIn.ar(1);
88         detect= PV_HainsworthFoote.ar(FFT(LocalBuf(2048),source1), 0.0, 1.0, MouseX.kr(0.0,1.1), 0.02);
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);
94 //compare to Amplitude UGen
96 SynthDef(\fftod, {
97                 var source1, detect;
98                 source1= AudioIn.ar(1);
99                 detect= (Amplitude.ar(source1)) > (MouseX.kr(0.0,1.1));
100                 Out.ar(0,Pan2.ar(source1,-1.0)+ Pan2.ar(SinOsc.ar(440,0,Decay.ar(0.1*detect,0.1)),1.0));
101         }).play(s);