tests/python/src/pitch/pitchdetection.py: update to latest pitch prototypes
authorPaul Brossier <piem@piem.org>
Thu, 8 Oct 2009 19:00:53 +0000 (21:00 +0200)
committerPaul Brossier <piem@piem.org>
Thu, 8 Oct 2009 19:00:53 +0000 (21:00 +0200)
tests/python/src/pitch/pitchdetection.py

index 69a467fb87726d8bbfcfe540c41f3385f70389f1..5c9fa3dc8091bbbd933e6a6f13827b4eb7d1d3b1 100644 (file)
@@ -27,49 +27,58 @@ class pitchdetection_test_case(unittest.TestCase):
   def test_pitchdetection_run_zeroes(self):
     """ run pitchdetection on an empty buffer """
     vec = new_fvec(buf_size, channels)
+    out = new_fvec(1, channels)
     for i in range(100):
-      self.assertEqual(aubio_pitchdetection_do(self.o,vec),0.)
+      aubio_pitchdetection_do(self.o,vec, out)
+      self.assertEqual(fvec_read_sample(out, 0, 0),0.)
     del vec
 
   def test_pitchdetection_run_4_impulses(self):
     """ run pitchdetection on a train of 4 impulses """
     vec = new_fvec(buf_size, channels)
+    out = new_fvec(1, channels)
     fvec_write_sample(vec,-1.,0,  0)
     fvec_write_sample(vec, 1.,0,  buf_size/4)
     fvec_write_sample(vec,-1.,0,  buf_size/2)
     fvec_write_sample(vec, 1.,0,3*buf_size/4)
     frequency = samplerate/2*4/buf_size
     for i in range(100):
-      self.assertEqual(aubio_pitchdetection_do(self.o,vec),frequency)
+      aubio_pitchdetection_do(self.o,vec, out)
+      self.assertEqual(fvec_read_sample(out, 0, 0),frequency)
     del vec
 
   def test_pitchdetection_run_4_positive_impulses(self):
     """ run pitchdetection on a train of 4 positive impulses of arbitrary size """
     vec = new_fvec(buf_size, channels)
+    out = new_fvec(1, channels)
     frequency = samplerate/2*8/buf_size
     for i in range(100):
       fvec_write_sample(vec, 2.-.01*i,0,  0)
       fvec_write_sample(vec, 2.-.01*i,0,  buf_size/4)
       fvec_write_sample(vec, 2.-.01*i,0,  buf_size/2)
       fvec_write_sample(vec, 2.-.01*i,0,3*buf_size/4)
-      self.assertAlmostEqual(aubio_pitchdetection_do(self.o,vec),frequency,1)
+      aubio_pitchdetection_do(self.o,vec, out)
+      self.assertAlmostEqual(fvec_read_sample(out, 0, 0),frequency,1)
     del vec
 
   def test_pitchdetection_run_4_negative_impulses(self):
     """ run pitchdetection on a train of 4 negative impulses of arbitrary size """
     vec = new_fvec(buf_size, channels)
+    out = new_fvec(1, channels)
     frequency = samplerate/2*8/buf_size
     for i in range(1,100):
       fvec_write_sample(vec,-.01*i,0,  0)
       fvec_write_sample(vec,-.01*i,0,  buf_size/4)
       fvec_write_sample(vec,-.01*i,0,  buf_size/2)
       fvec_write_sample(vec,-.01*i,0,3*buf_size/4)
-      self.assertAlmostEqual(aubio_pitchdetection_do(self.o,vec),frequency,1)
+      aubio_pitchdetection_do(self.o,vec, out)
+      self.assertAlmostEqual(fvec_read_sample(out, 0, 0),frequency,1)
     del vec
 
   def test_pitchdetection_run_8_impulses(self):
     """ run pitchdetection on a train of 8 impulses """
     vec = new_fvec(buf_size, channels)
+    out = new_fvec(1, channels)
     fvec_write_sample(vec, 1.,0,  0)
     fvec_write_sample(vec,-1.,0,  buf_size/8)
     fvec_write_sample(vec, 1.,0,  buf_size/4)
@@ -79,7 +88,8 @@ class pitchdetection_test_case(unittest.TestCase):
     fvec_write_sample(vec, 1.,0,3*buf_size/4)
     fvec_write_sample(vec,-1.,0,7*buf_size/8)
     for i in range(100):
-      self.assertAlmostEqual(aubio_pitchdetection_do(self.o,vec),
+      aubio_pitchdetection_do(self.o,vec, out)
+      self.assertAlmostEqual(fvec_read_sample(out, 0, 0),
         samplerate/2/buf_size*8, 1) 
     del vec