python/demos/demo_onset*: remove di, moved to C
authorPaul Brossier <piem@piem.org>
Fri, 15 Mar 2013 22:49:29 +0000 (17:49 -0500)
committerPaul Brossier <piem@piem.org>
Fri, 15 Mar 2013 22:49:29 +0000 (17:49 -0500)
python/demos/demo_onset.py
python/demos/demo_onset_plot.py

index d921724e3bf66c16f32acc4c5d68f30f31407e33..170326fc5e3c426f82a7f58414f0c993f64a459a 100755 (executable)
@@ -20,10 +20,6 @@ samplerate = s.samplerate
 
 o = onset("default", win_s, hop_s, samplerate)
 
-# onset detection delay, in samples
-# default to 4 blocks delay to catch up with
-delay = 4. * hop_s
-
 # list of onsets, in samples
 onsets = []
 
@@ -31,11 +27,9 @@ onsets = []
 total_frames = 0
 while True:
     samples, read = s()
-    is_onset = o(samples)
-    if is_onset:
-        this_onset = int(total_frames - delay + is_onset[0] * hop_s)
-        print "%f" % (this_onset / float(samplerate))
-        onsets.append(this_onset)
+    if o(samples):
+        print "%f" % o.get_last_onset_s()
+        onsets.append(o.get_last_onset())
     total_frames += read
     if read < hop_s: break
 #print len(onsets)
index 513c579d9028fe70ddccbee26b421af25dee4730..246b5b1491e41bf78273e12191d7f79202439bc9 100755 (executable)
@@ -20,10 +20,6 @@ s = source(filename, samplerate, hop_s)
 samplerate = s.samplerate
 o = onset("default", win_s, hop_s, samplerate)
 
-# onset detection delay, in samples
-# default to 4 blocks delay to catch up with
-delay = 4. * hop_s
-
 # list of onsets, in samples
 onsets = []
 
@@ -39,7 +35,7 @@ while True:
     samples, read = s()
     is_onset = o(samples)
     if is_onset:
-        this_onset = int(total_frames - delay + is_onset[0] * hop_s)
+        this_onset = o.get_last_onset()
         print "%f" % (this_onset / float(samplerate))
         onsets.append(this_onset)
     # keep some data to plot it later