shithub: aubio

Download patch

ref: 5a93302d1307e92c952871de693ca9dc98595b1a
parent: 2672d67e4243a791b84fd6825d965ad38a9f651c
author: Paul Brossier <piem@piem.org>
date: Wed Oct 7 22:35:50 EDT 2009

tests/python/src/onset/peakpick.py: update to interpolated peak position

--- a/tests/python/src/onset/peakpick.py
+++ b/tests/python/src/onset/peakpick.py
@@ -20,7 +20,7 @@
 
   def test_peakpick_zeroes(self):
     """ check peakpick run on a vector full of zero returns no peak. """
-    self.assertEqual(0., aubio_peakpick_pimrt_getval(self.o))
+    self.assertEqual(0., aubio_peakpicker_get_thresholded_input(self.o))
 
   def test_peakpick_impulse(self):
     """ check peakpick detects a single impulse as a peak. """
@@ -30,7 +30,7 @@
       input = new_fvec(buf_size, channels)
       fvec_write_sample(input, 1000., 0, index)
       fvec_write_sample(input, 1000./2, 0, index+1)
-      #print "%2s" % index, aubio_peakpick_pimrt(input, self.o), "|",
+      #print "%2s" % index, aubio_peakpicker_do(self.o, input), "|",
       #for i in range(buf_size): print fvec_read_sample(input, 0, i),
       #print
       del_fvec(input)
@@ -44,20 +44,20 @@
       fvec_write_sample(input, 1000., 0, index+1)
       fvec_write_sample(input, 1000., 0, index+3)
       fvec_write_sample(input, 1000./2, 0, index+4)
-      peak_pick_result = aubio_peakpick_pimrt(input, self.o)
-      if index == 2: self.assertEqual(1., peak_pick_result)
+      peak_pick_result = aubio_peakpicker_do(self.o, input)
+      if index == 2:
+        # we are at the peak. check the result is after current sample,
+        # and not after next one
+        self.failIf( 1. >= peak_pick_result )
+        self.failIf( 2. < peak_pick_result )
       else: self.assertEqual(0., peak_pick_result)
-      #print "%2s" % index, peak_pick_result, "|",
-      #for i in range(buf_size): print fvec_read_sample(input, 0, i),
-      #print
       del_fvec(input)
     for index in range(buf_size-4,buf_size-1):
       input = new_fvec(buf_size, channels)
       fvec_write_sample(input, 1000./2, 0, index)
       fvec_write_sample(input, 1000., 0, index+1)
-      #print "%2s" % index, aubio_peakpick_pimrt(input, self.o), "|",
-      #for i in range(buf_size): print fvec_read_sample(input, 0, i),
-      #print
+      peak_pick_result = aubio_peakpicker_do(self.o, input)
+      self.assertEqual(0., peak_pick_result)
       del_fvec(input)
 
   def test_peakpick_set_threshold(self):