add test fft back and forth
authorPaul Brossier <piem@piem.org>
Sat, 3 Nov 2007 16:38:45 +0000 (17:38 +0100)
committerPaul Brossier <piem@piem.org>
Sat, 3 Nov 2007 16:38:45 +0000 (17:38 +0100)
tests/python/fft.py

index 540a6c2a7a651a9b1a7dfd2efefcecdc97061ac5..d377e6fb72824334e217064719f0a9bf635a1c10 100644 (file)
@@ -14,8 +14,8 @@ class aubio_mfft_test_case(unittest.TestCase):
   def tearDown(self):
     del_aubio_mfft(self.o)
 
-  def test_aubio_mfft(self):
-    """ create and delete mfft """
+  def test_create(self):
+    """ test creation and deletion of fft object """
     pass
 
   def test_aubio_mfft_do_zeroes(self):
@@ -102,4 +102,20 @@ class aubio_mfft_test_case(unittest.TestCase):
     del fftgrain
     del output
 
+  def test_aubio_mfft_do_back_and_forth(self):
+    """ test aubio_mfft_rdo on a constant """
+    input    = new_fvec(buf_size, channels)
+    output   = new_fvec(buf_size, channels)
+    fftgrain = new_cvec(buf_size, channels)
+    for index in range(buf_size/2+1):
+      for channel in range(channels):
+        fvec_write_sample(input, 0.67, channel, index)
+    aubio_mfft_do(self.o, input, fftgrain)
+    aubio_mfft_rdo(self.o, fftgrain, output)
+    for index in range(buf_size/2+1):
+      for channel in range(channels):
+        self.assertAlmostEqual(fvec_read_sample(output, channel, index), 0.67, 7)
+    del fftgrain
+    del output
+
 if __name__ == '__main__': unittest.main()