Index: python/tests/test_aubio.py
===================================================================
--- python/tests/test_aubio.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_aubio.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,14 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, run_module_suite
+
+class aubiomodule_test_case(TestCase):
+
+  def test_import(self):
+    """ try importing aubio """
+    import aubio 
+
+if __name__ == '__main__':
+  from unittest import main
+  main()
+
Index: python/tests/test_cvec.py
===================================================================
--- python/tests/test_cvec.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_cvec.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,50 @@
+from numpy.testing import TestCase, run_module_suite
+from numpy.testing import assert_equal, assert_almost_equal
+from aubio import cvec
+from numpy import array, shape, pi
+
+class aubio_cvec_test_case(TestCase):
+
+    def test_vector_created_with_zeroes(self):
+        a = cvec(10)
+        a
+        shape(a.norm)
+        shape(a.phas)
+        a.norm[0]
+        assert_equal(a.norm, 0.)
+        assert_equal(a.phas, 0.)
+
+    def test_vector_assign_element(self):
+        a = cvec()
+        a.norm[0] = 1
+        assert_equal(a.norm[0], 1)
+        a.phas[0] = 1
+        assert_equal(a.phas[0], 1)
+
+    def test_vector_assign_element_end(self):
+        a = cvec()
+        a.norm[-1] = 1
+        assert_equal(a.norm[-1], 1)
+        assert_equal(a.norm[len(a.norm)-1], 1)
+        a.phas[-1] = 1
+        assert_equal(a.phas[-1], 1)
+        assert_equal(a.phas[len(a.phas)-1], 1)
+
+    def test_assign_cvec_norm_slice(self):
+        spec = cvec(1024)
+        spec.norm[40:100] = 100
+        assert_equal (spec.norm[0:40], 0)
+        assert_equal (spec.norm[40:100], 100)
+        assert_equal (spec.norm[100:-1], 0)
+        assert_equal (spec.phas, 0)
+
+    def test_assign_cvec_phas_slice(self):
+        spec = cvec(1024)
+        spec.phas[39:-1] = -pi
+        assert_equal (spec.phas[0:39], 0)
+        assert_equal (spec.phas[39:-1], -pi)
+        assert_equal (spec.norm, 0)
+
+if __name__ == '__main__':
+    from unittest import main
+    main()
Index: python/tests/test_fft.py
===================================================================
--- python/tests/test_fft.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_fft.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,113 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, run_module_suite
+from numpy.testing import assert_equal, assert_almost_equal
+# WARNING: numpy also has an fft object
+from aubio import fvec, fft, cvec
+from numpy import array, shape
+from math import pi
+
+class aubio_fft_test_case(TestCase):
+
+  def test_members(self):
+    f = fft()
+    assert_equal (f.win_s, 1024)
+
+  def test_output_dimensions(self):
+    """ check the dimensions of output """
+    win_s = 1024
+    timegrain = fvec(win_s)
+    f = fft(win_s)
+    fftgrain = f (timegrain)
+    assert_equal (fftgrain.norm, 0)
+    assert_equal (shape(fftgrain.norm), (win_s/2+1,))
+    assert_equal (fftgrain.phas, 0)
+    assert_equal (shape(fftgrain.phas), (win_s/2+1,))
+
+  def test_zeros(self):
+    """ check the transform of zeros """
+    win_s = 512
+    timegrain = fvec(win_s)
+    f = fft(win_s)
+    fftgrain = f(timegrain)
+    assert_equal ( fftgrain.norm == 0, True )
+    assert_equal ( fftgrain.phas == 0, True )
+
+  def test_impulse(self):
+    """ check the transform of one impulse at a random place """
+    from random import random
+    from math import floor
+    win_s = 256
+    i = floor(random()*win_s)
+    impulse = pi * random() 
+    f = fft(win_s)
+    timegrain = fvec(win_s)
+    timegrain[i] = impulse 
+    fftgrain = f ( timegrain )
+    #self.plot_this ( fftgrain.phas )
+    assert_almost_equal ( fftgrain.norm, impulse, decimal = 6 )
+    assert_equal ( fftgrain.phas <= pi, True)
+    assert_equal ( fftgrain.phas >= -pi, True)
+
+  def test_impulse_negative(self):
+    """ check the transform of one impulse at a random place """
+    from random import random
+    from math import floor
+    win_s = 256
+    i = 0 
+    impulse = -10. 
+    f = fft(win_s)
+    timegrain = fvec(win_s)
+    timegrain[i] = impulse 
+    fftgrain = f ( timegrain )
+    #self.plot_this ( fftgrain.phas )
+    assert_almost_equal ( fftgrain.norm, abs(impulse), decimal = 6 )
+    if impulse < 0:
+      # phase can be pi or -pi, as it is not unwrapped
+      assert_almost_equal ( abs(fftgrain.phas[1:-1]) , pi, decimal = 6 )
+      assert_almost_equal ( fftgrain.phas[0], pi, decimal = 6)
+      assert_almost_equal ( fftgrain.phas[-1], pi, decimal = 6)
+    else:
+      assert_equal ( fftgrain.phas[1:-1] == 0, True)
+      assert_equal ( fftgrain.phas[0] == 0, True)
+      assert_equal ( fftgrain.phas[-1] == 0, True)
+    # now check the resynthesis
+    synthgrain = f.rdo ( fftgrain )
+    #self.plot_this ( fftgrain.phas.T )
+    assert_equal ( fftgrain.phas <= pi, True)
+    assert_equal ( fftgrain.phas >= -pi, True)
+    #self.plot_this ( synthgrain - timegrain )
+    assert_almost_equal ( synthgrain, timegrain, decimal = 6 )
+
+  def test_impulse_at_zero(self):
+    """ check the transform of one impulse at a index 0 """
+    win_s = 1024
+    impulse = pi
+    f = fft(win_s)
+    timegrain = fvec(win_s)
+    timegrain[0] = impulse 
+    fftgrain = f ( timegrain )
+    #self.plot_this ( fftgrain.phas )
+    assert_equal ( fftgrain.phas[0], 0)
+    # could be 0 or -0 depending on fft implementation (0 for fftw3, -0 for ooura)
+    assert_almost_equal ( fftgrain.phas[1], 0)
+    assert_almost_equal ( fftgrain.norm[0], impulse, decimal = 6 )
+
+  def test_rdo_before_do(self):
+    """ check running fft.rdo before fft.do works """
+    win_s = 1024
+    impulse = pi
+    f = fft(win_s)
+    fftgrain = cvec(win_s)
+    t = f.rdo( fftgrain )
+    assert_equal ( t, 0 )
+
+  def plot_this(self, this):
+    from pylab import plot, show
+    plot ( this )
+    show ()
+
+if __name__ == '__main__':
+  from unittest import main
+  main()
+
Index: python/tests/test_filter.py
===================================================================
--- python/tests/test_filter.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_filter.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,68 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+from aubio import fvec, digital_filter
+from numpy import array
+
+def array_from_text_file(filename, dtype = 'float'):
+  return array([line.split() for line in open(filename).readlines()], 
+      dtype = dtype)
+
+class aubio_filter_test_case(TestCase):
+
+  def test_members(self):
+    f = digital_filter()
+    assert_equal (f.order, 7)
+    f = digital_filter(5)
+    assert_equal (f.order, 5)
+    f(fvec())
+  
+  def test_cweighting_error(self):
+    f = digital_filter (2)
+    self.assertRaises ( ValueError, f.set_c_weighting, 44100 )
+    f = digital_filter (8)
+    self.assertRaises ( ValueError, f.set_c_weighting, 44100 )
+    f = digital_filter (5)
+    self.assertRaises ( ValueError, f.set_c_weighting, 4000 )
+    f = digital_filter (5)
+    self.assertRaises ( ValueError, f.set_c_weighting, 193000 )
+    f = digital_filter (7)
+    self.assertRaises ( ValueError, f.set_a_weighting, 193000 )
+    f = digital_filter (5)
+    self.assertRaises ( ValueError, f.set_a_weighting, 192000 )
+
+  def test_c_weighting(self):
+    expected = array_from_text_file('c_weighting_test_simple.expected')
+    f = digital_filter(5)
+    f.set_c_weighting(44100)
+    v = fvec(32)
+    v[12] = .5
+    u = f(v)
+    assert_almost_equal (expected[1], u)
+
+  def test_a_weighting(self):
+    expected = array_from_text_file('a_weighting_test_simple.expected')
+    f = digital_filter(7)
+    f.set_a_weighting(44100)
+    v = fvec(32)
+    v[12] = .5
+    u = f(v)
+    assert_almost_equal (expected[1], u)
+
+  def test_a_weighting_parted(self):
+    expected = array_from_text_file('a_weighting_test_simple.expected')
+    f = digital_filter(7)
+    f.set_a_weighting(44100)
+    v = fvec(16)
+    v[12] = .5
+    u = f(v)
+    assert_almost_equal (expected[1][:16], u)
+    # one more time
+    v = fvec(16)
+    u = f(v)
+    assert_almost_equal (expected[1][16:], u)
+
+if __name__ == '__main__':
+  from unittest import main
+  main()
+
Index: python/tests/test_filterbank.py
===================================================================
--- python/tests/test_filterbank.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_filterbank.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,23 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, run_module_suite
+from numpy.testing import assert_equal, assert_almost_equal
+from numpy import random
+from aubio import cvec, filterbank
+
+class aubio_filterbank_test_case(TestCase):
+
+  def test_members(self):
+    f = filterbank(40, 512)
+    assert_equal ([f.n_filters, f.win_s], [40, 512])
+
+  def test_set_coeffs(self):
+    f = filterbank(40, 512)
+    r = random.random([40, 512 / 2 + 1]).astype('float32')
+    f.set_coeffs(r)
+    assert_equal (r, f.get_coeffs())
+
+if __name__ == '__main__':
+  from unittest import main
+  main()
+
Index: python/tests/test_filterbank_mel.py
===================================================================
--- python/tests/test_filterbank_mel.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_filterbank_mel.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,51 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, run_module_suite
+from numpy.testing import assert_equal, assert_almost_equal
+from numpy import array, shape
+from aubio import cvec, filterbank
+
+class aubio_filterbank_mel_test_case(TestCase):
+
+  def test_slaney(self):
+    f = filterbank(40, 512)
+    f.set_mel_coeffs_slaney(16000)
+    a = f.get_coeffs()
+    assert_equal(shape (a), (40, 512/2 + 1) )
+
+  def test_other_slaney(self):
+    f = filterbank(40, 512*2)
+    f.set_mel_coeffs_slaney(44100)
+    a = f.get_coeffs()
+    #print "sum is", sum(sum(a))
+    for win_s in [256, 512, 1024, 2048, 4096]:
+      f = filterbank(40, win_s)
+      f.set_mel_coeffs_slaney(320000)
+      a = f.get_coeffs()
+      #print "sum is", sum(sum(a))
+
+  def test_triangle_freqs_zeros(self):
+    f = filterbank(9, 1024)
+    freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
+    freqs = array(freq_list, dtype = 'float32')
+    f.set_triangle_bands(freqs, 48000)
+    f.get_coeffs().T
+    assert_equal ( f(cvec(1024)), 0)
+
+  def test_triangle_freqs_ones(self):
+    f = filterbank(9, 1024)
+    freq_list = [40, 80, 200, 400, 800, 1600, 3200, 6400, 12800, 15000, 24000]
+    freqs = array(freq_list, dtype = 'float32')
+    f.set_triangle_bands(freqs, 48000)
+    f.get_coeffs().T
+    spec = cvec(1024)
+    spec.norm[:] = 1
+    assert_almost_equal ( f(spec),
+            [ 0.02070313,  0.02138672,  0.02127604,  0.02135417, 
+        0.02133301, 0.02133301,  0.02133311,  0.02133334,  0.02133345])
+
+if __name__ == '__main__':
+  from unittest import main
+  main()
+
+
Index: python/tests/test_fvec.py
===================================================================
--- python/tests/test_fvec.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_fvec.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,135 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, run_module_suite
+from numpy.testing import assert_equal, assert_almost_equal
+from aubio import fvec, zero_crossing_rate, alpha_norm, min_removal
+from numpy import array, shape
+
+class aubio_fvec_test_case(TestCase):
+
+    def test_vector_created_with_zeroes(self):
+        a = fvec(10)
+        a
+        shape(a)
+        a[0]
+        #del a
+        assert_equal(array(a), 0.)
+
+    def test_vector_create_with_list(self):
+        a = fvec([0,1,2,3])
+        assert_equal (range(4), a)
+
+    def test_vector_assign_element(self):
+        a = fvec()
+        a[0] = 1
+        assert_equal(a[0], 1)
+
+    def test_vector_assign_element_end(self):
+        a = fvec()
+        a[-1] = 1
+        assert_equal(a[-1], 1)
+        assert_equal(a[len(a)-1], 1)
+
+    def test_vector(self):
+        a = fvec()
+        a, len(a) #a.length
+        a[0]
+        array(a)
+        a = fvec(10)
+        a = fvec(1)
+        a.T
+        array(a).T
+        a = range(len(a))
+
+    def test_wrong_values(self):
+        self.assertRaises (ValueError, fvec, -10)
+  
+        a = fvec(2)
+        self.assertRaises (IndexError, a.__getitem__, 3)
+        self.assertRaises (IndexError, a.__getitem__, 2)
+
+    def test_alpha_norm_of_fvec(self):
+        a = fvec(2)
+        self.assertEquals (alpha_norm(a, 1), 0)
+        a[0] = 1
+        self.assertEquals (alpha_norm(a, 1), 0.5)
+        a[1] = 1
+        self.assertEquals (alpha_norm(a, 1), 1)
+        a = array([0, 1], dtype='float32')
+        from math import sqrt
+        assert_almost_equal (alpha_norm(a, 2), sqrt(2)/2.)
+
+    def test_alpha_norm_of_none(self):
+        self.assertRaises (ValueError, alpha_norm, None, 1)
+
+    def test_alpha_norm_of_array_of_float32(self):
+        # check scalar fails
+        a = array(1, dtype = 'float32')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check 2d array fails
+        a = array([[2],[4]], dtype = 'float32')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check 1d array
+        a = array(range(10), dtype = 'float32')
+        self.assertEquals (alpha_norm(a, 1), 4.5)
+
+    def test_alpha_norm_of_array_of_int(self):
+        a = array(1, dtype = 'int')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        a = array([[[1,2],[3,4]]], dtype = 'int')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        a = array(range(10), dtype = 'int')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+
+    def test_alpha_norm_of_array_of_string (self):
+        a = "hello"
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+
+    def test_zero_crossing_rate(self):
+        a = array([0,1,-1], dtype='float32')
+        assert_almost_equal (zero_crossing_rate(a), 1./3. )
+        a = array([0.]*100, dtype='float32')
+        self.assertEquals (zero_crossing_rate(a), 0 )
+        a = array([-1.]*100, dtype='float32')
+        self.assertEquals (zero_crossing_rate(a), 0 )
+        a = array([1.]*100, dtype='float32')
+        self.assertEquals (zero_crossing_rate(a), 0 )
+
+    def test_alpha_norm_of_array_of_float64(self):
+        # check scalar fail
+        a = array(1, dtype = 'float64')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check 3d array fail
+        a = array([[[1,2],[3,4]]], dtype = 'float64')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check float64 1d array fail
+        a = array(range(10), dtype = 'float64')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+        # check float64 2d array fail
+        a = array([range(10), range(10)], dtype = 'float64')
+        self.assertRaises (ValueError, alpha_norm, a, 1)
+
+    def test_fvec_min_removal_of_array(self):
+        a = array([20,1,19], dtype='float32')
+        b = min_removal(a)
+        assert_equal (array(b), [19, 0, 18])
+        assert_equal (b, [19, 0, 18])
+        assert_equal (a, b)
+        a[0] = 0
+        assert_equal (a, b)
+
+    def test_fvec_min_removal_of_array_float64(self):
+        a = array([20,1,19], dtype='float64')
+        self.assertRaises (ValueError, min_removal, a)
+
+    def test_fvec_min_removal_of_fvec(self):
+        a = fvec(3)
+        a = array([20, 1, 19], dtype = 'float32')
+        b = min_removal(a)
+        assert_equal (array(b), [19, 0, 18])
+        assert_equal (b, [19, 0, 18])
+        assert_equal (a, b)
+
+if __name__ == '__main__':
+    from unittest import main
+    main()
Index: python/tests/test_onset.py
===================================================================
--- python/tests/test_onset.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_onset.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,20 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, run_module_suite
+from numpy.testing import assert_equal, assert_almost_equal
+# WARNING: numpy also has an fft object
+from aubio import onset, cvec
+from numpy import array, shape, arange, zeros, log
+from math import pi
+
+class aubio_onset(TestCase):
+
+    def test_members(self):
+        o = onset()
+        assert_equal ([o.buf_size, o.hop_size, o.method, o.samplerate],
+            [1024,512,'default',44100])
+    
+
+if __name__ == '__main__':
+    from unittest import main
+    main()
Index: python/tests/test_peakpicker.py
===================================================================
--- python/tests/test_peakpicker.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_peakpicker.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,115 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+from aubio import peakpicker, fvec
+
+class aubio_peakpicker(TestCase):
+
+    def test_members(self):
+        o = peakpicker()
+
+    def test_peakpicker_zeroes(self):
+        o = peakpicker()
+        assert_equal(o.get_thresholded_input(), 0.)
+
+    def test_peakpick_set_threshold(self):
+        o = peakpicker()
+        new_threshold = threshold 
+        o.set_threshold(new_threshold)
+        assert_almost_equal(new_threshold, o.get_threshold())
+
+    def test_peakpicker_get_threshold(self):
+        o = peakpicker()
+        new_threshold = o.get_threshold() 
+        o.set_threshold(new_threshold)
+        assert_equal(new_threshold, o.get_threshold())
+
+buf_size = 1024
+slice_size = 5
+delay = 1
+threshold = .9
+
+class aubio_peakpicker_peaks(TestCase):
+
+    def setUp(self):
+        self.o = peakpicker()
+        self.o.set_threshold (threshold)
+        self.vec = fvec(buf_size)
+
+    def test_peakpicker_impulse(self):
+        vec = self.vec; o = self.o
+        a = 345
+        vec[a] = 1000.
+        self.peaks = [a]
+
+    def test_peakpicker_ramp_up(self):
+        vec = self.vec; o = self.o
+        a = 345
+        vec[a]   = 1000. / 4. * 1.
+        vec[a+1] = 1000. / 4. * 2.
+        vec[a+2] = 1000. / 4. * 3.
+        vec[a+3] = 1000.
+        self.peaks = [a+1]
+
+    def test_peakpicker_ramp_down(self):
+        vec = self.vec; o = self.o
+        a = 345
+        vec[a]   = 1000.
+        vec[a+1] = 1000. / 4. * 3.
+        vec[a+2] = 1000. / 4. * 2.
+        vec[a+3] = 1000. / 4. * 1.
+        self.peaks = [a]
+
+    def test_peakpicker_plateau(self):
+        vec = self.vec; o = self.o
+        a = 345
+        vec[a]   = 1000. / 2
+        vec[a+1] = 1000.
+        vec[a+2] = 1000.
+        vec[a+3] = 1000.
+        vec[a+4] = 1000. / 2
+        self.peaks = [a+1]
+
+    def test_peakpicker_consecutive_peaks(self):
+        vec = self.vec; o = self.o
+        a = 345
+        vec[a]   = 1000. / 2
+        vec[a+1] = 1000.
+        vec[a+3] = 1000.
+        vec[a+4] = 1000. / 2
+        self.peaks = [a]
+
+    def test_peakpicker_distant_peaks(self):
+        vec = self.vec; o = self.o
+        a = 345
+        vec[a] = 1000.
+        vec[a+7] = 1000.
+        self.peaks = [a, a+7]
+
+    def test_peakpicker_very_distant_peaks(self):
+        vec = self.vec; o = self.o
+        a = 345
+        vec[a] = 1000.
+        vec[a+67] = 1000.
+        self.peaks = [a, a+67]
+
+    def tearDown(self):
+        fpeaks = []
+        for index in range(0,buf_size-slice_size):
+            sliced = self.vec[index:index+slice_size]
+            findex = self.o(sliced)
+            if findex:
+              # we found a peak
+              fpeak = index - findex - delay
+              #print self.peaks, index, '-', findex, '-', delay, '=', fpeak
+              if not round(index - findex - delay) in self.peaks:
+                  self.fail('missing peak ' + str(fpeak))
+              fpeaks.append(fpeak)
+        if len(fpeaks) != len(self.peaks):
+            self.fail('some peaks of ' + str(self.peaks) + 'were not found, got only ' + str(fpeaks))
+        #print
+        #print fpeaks, self.peaks
+
+if __name__ == '__main__':
+    from unittest import main
+    main()
Index: python/tests/test_phasevoc.py
===================================================================
--- python/tests/test_phasevoc.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_phasevoc.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,65 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, run_module_suite
+from numpy.testing import assert_equal, assert_almost_equal
+from aubio import fvec, cvec, pvoc
+from numpy import array, shape
+
+class aubio_pvoc_test_case(TestCase):
+
+  def test_members(self):
+    f = pvoc()
+    assert_equal ([f.win_s, f.hop_s], [1024, 512])
+    f = pvoc(2048, 128)
+    assert_equal ([f.win_s, f.hop_s], [2048, 128])
+
+  def test_zeros(self):
+    win_s, hop_s = 1024, 256
+    f = pvoc (win_s, hop_s)
+    t = fvec (hop_s)
+    for time in range( 4 * win_s / hop_s ):
+      s = f(t)
+      r = f.rdo(s)
+      assert_equal ( array(t), 0)
+      assert_equal ( s.norm, 0)
+      assert_equal ( s.phas, 0)
+      assert_equal ( r, 0)
+
+  def test_steps_two_channels(self):
+    """ check the resynthesis of steps is correct """
+    f = pvoc(1024, 512)
+    t1 = fvec(512)
+    t2 = fvec(512)
+    # positive step in first channel
+    t1[100:200] = .1
+    # positive step in second channel
+    t1[20:50] = -.1
+    s1 = f(t1)
+    r1 = f.rdo(s1)
+    s2 = f(t2)
+    r2 = f.rdo(s2)
+    #self.plot_this ( s1.norm.T )
+    assert_almost_equal ( t1, r2, decimal = 6 )
+    
+  def test_steps_three_random_channels(self):
+    from random import random
+    f = pvoc(64, 16)
+    t0 = fvec(16)
+    t1 = fvec(16)
+    for i in xrange(16):
+        t1[i] = random() * 2. - 1.
+    t2 = f.rdo(f(t1))
+    t2 = f.rdo(f(t0))
+    t2 = f.rdo(f(t0))
+    t2 = f.rdo(f(t0))
+    assert_almost_equal( t1, t2, decimal = 6 )
+    
+  def plot_this( self, this ):
+    from pylab import semilogy, show
+    semilogy ( this )
+    show ()
+
+if __name__ == '__main__':
+  from unittest import main
+  main()
+
Index: python/tests/test_pitch.py
===================================================================
--- python/tests/test_pitch.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_pitch.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,101 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase
+from numpy.testing import assert_equal, assert_almost_equal
+from numpy import random, sin, arange, mean, median
+from math import pi
+from aubio import fvec, pitch
+
+class aubio_mathutils_test_case(TestCase):
+
+  def test_members(self):
+    p = pitch()
+    assert_equal ( [p.method, p.buf_size, p.hop_size, p.samplerate],
+      ['default', 1024, 512, 44100])
+
+  def test_members_not_default(self):
+    p = pitch('mcomb', 2048, 512, 32000)
+    assert_equal ( [p.method, p.buf_size, p.hop_size, p.samplerate],
+      ['mcomb', 2048, 512, 32000])
+
+  def test_run_on_zeros(self):
+    p = pitch('mcomb', 2048, 512, 32000)
+    f = fvec (512)
+    assert_equal ( p(f), 0. )
+
+  def test_run_on_ones(self):
+    p = pitch('mcomb', 2048, 512, 32000)
+    f = fvec (512)
+    f[:] = 1
+    assert( p(f) != 0. )
+
+  def test_run_default_on_sinusoid(self):
+    method = 'default'
+    buf_size = 2048
+    hop_size = 512
+    samplerate = 32000
+    freq = 450.
+    self.run_pitch_on_sinusoid(method, buf_size, hop_size, samplerate, freq)
+
+  def test_run_schmitt_on_sinusoid(self):
+    method = 'schmitt'
+    buf_size = 4096
+    hop_size = 512
+    samplerate = 44100
+    freq = 800.
+    self.run_pitch_on_sinusoid(method, buf_size, hop_size, samplerate, freq)
+
+  def test_run_mcomb_on_sinusoid(self):
+    method = 'mcomb'
+    buf_size = 2048
+    hop_size = 512
+    samplerate = 44100
+    freq = 10000.
+    self.run_pitch_on_sinusoid(method, buf_size, hop_size, samplerate, freq)
+
+  def test_run_fcomb_on_sinusoid(self):
+    method = 'fcomb'
+    buf_size = 2048
+    hop_size = 512
+    samplerate = 32000
+    freq = 440.
+    self.run_pitch_on_sinusoid(method, buf_size, hop_size, samplerate, freq)
+
+  def test_run_yin_on_sinusoid(self):
+    method = 'yin'
+    buf_size = 4096
+    hop_size = 512
+    samplerate = 32000
+    freq = 880.
+    self.run_pitch_on_sinusoid(method, buf_size, hop_size, samplerate, freq)
+
+  def test_run_yinfft_on_sinusoid(self):
+    method = 'yinfft'
+    buf_size = 2048
+    hop_size = 512
+    samplerate = 32000
+    freq = 640.
+    self.run_pitch_on_sinusoid(method, buf_size, hop_size, samplerate, freq)
+
+  def run_pitch_on_sinusoid(self, method, buf_size, hop_size, samplerate, freq):
+    p = pitch(method, buf_size, hop_size, samplerate)
+    sinvec = self.build_sinusoid(hop_size * 100, freq, samplerate)
+    self.run_pitch(p, sinvec, freq)
+
+  def build_sinusoid(self, length, freq, samplerate):
+    return sin( 2. * pi * arange(length).astype('float32') * freq / samplerate)
+
+  def run_pitch(self, p, input_vec, freq):
+    count = 0
+    pitches, errors = [], []
+    for vec_slice in input_vec.reshape((-1, p.hop_size)):
+      pitch = p(vec_slice)
+      pitches.append(pitch)
+      errors.append(1. - pitch / freq)
+    # check that the mean of all relative errors is less than 10%
+    assert_almost_equal (mean(errors), 0., decimal = 2)
+
+if __name__ == '__main__':
+  from unittest import main
+  main()
+
Index: python/tests/test_source.py
===================================================================
--- python/tests/test_source.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_source.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,27 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+from aubio import fvec, source
+from numpy import array
+
+path = "/Users/piem/archives/sounds/loops/drum_Chocolate_Milk_-_Ation_Speaks_Louder_Than_Words.wav"
+
+class aubio_filter_test_case(TestCase):
+
+  def test_members(self):
+    f = source(path)
+    print dir(f)
+
+  def test_read(self):
+    f = source(path)
+    total_frames = 0
+    while True:
+      vec, read = f()
+      total_frames += read
+      if read < f.hop_size: break
+    print "read", total_frames / float(f.samplerate), " seconds from", path
+
+if __name__ == '__main__':
+  from unittest import main
+  main()
+
Index: python/tests/test_specdesc.py
===================================================================
--- python/tests/test_specdesc.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
+++ python/tests/test_specdesc.py	(revision 26adcfb10b34d9673d5c6bbec5d97c925982bf53)
@@ -0,0 +1,238 @@
+#! /usr/bin/env python
+
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+from numpy import random, arange, log, zeros
+from aubio import specdesc, cvec
+from math import pi
+
+methods = ["default",
+     "energy",
+     "hfc",
+     "complex",
+     "phase",
+     "specdiff",
+     "kl",
+     "mkl",
+     "specflux",
+     "centroid",
+     "spread",
+     "skewness",
+     "kurtosis",
+     "slope",
+     "decrease",
+     "rolloff"]
+buf_size = 2048
+
+class aubio_specdesc(TestCase):
+
+    def test_members(self):
+        o = specdesc()
+
+        for method in methods:
+          o = specdesc(method, buf_size)
+          assert_equal ([o.buf_size, o.method], [buf_size, method])
+
+          spec = cvec(buf_size)
+          spec.norm[0] = 1
+          spec.norm[1] = 1./2.
+          #print "%20s" % method, str(o(spec))
+          o(spec)
+          spec.norm = random.random_sample((len(spec.norm),)).astype('float32')
+          spec.phas = random.random_sample((len(spec.phas),)).astype('float32')
+          #print "%20s" % method, str(o(spec))
+          assert (o(spec) != 0.)
+
+    def test_hfc(self):
+        o = specdesc("hfc", buf_size)
+        spec = cvec(buf_size)
+        # hfc of zeros is zero
+        assert_equal (o(spec), 0.)
+        # hfc of ones is sum of all bin numbers
+        spec.norm[:] = 1
+        expected = sum(range(buf_size/2 + 2))
+        assert_equal (o(spec), expected)
+        # changing phase doesn't change anything
+        spec.phas[:] = 1
+        assert_equal (o(spec), sum(range(buf_size/2 + 2)))
+
+    def test_phase(self):
+        o = specdesc("phase", buf_size)
+        spec = cvec(buf_size)
+        # phase of zeros is zero
+        assert_equal (o(spec), 0.)
+        spec.phas = random.random_sample((len(spec.phas),)).astype('float32')
+        # phase of random is not zero
+        spec.norm[:] = 1
+        assert (o(spec) != 0.)
+
+    def test_specdiff(self):
+        o = specdesc("phase", buf_size)
+        spec = cvec(buf_size)
+        # specdiff of zeros is zero
+        assert_equal (o(spec), 0.)
+        spec.phas = random.random_sample((len(spec.phas),)).astype('float32')
+        # phase of random is not zero
+        spec.norm[:] = 1
+        assert (o(spec) != 0.)
+    
+    def test_hfc(self):
+        o = specdesc("hfc")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length, dtype='float32')
+        c.norm = a
+        assert_equal (a, c.norm)
+        assert_equal ( sum(a*(a+1)), o(c))
+
+    def test_complex(self):
+        o = specdesc("complex")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length, dtype='float32')
+        c.norm = a
+        assert_equal (a, c.norm)
+        # the previous run was on zeros, so previous frames are still 0
+        # so we have sqrt ( abs ( r2 ^ 2) ) == r2
+        assert_equal ( sum(a), o(c))
+        # second time. c.norm = a, so, r1 = r2, and the euclidian distance is 0
+        assert_equal ( 0, o(c))
+
+    def test_kl(self):
+        o = specdesc("kl")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length, dtype='float32')
+        c.norm = a
+        assert_almost_equal( sum(a * log(1.+ a/1.e-10 ) ) / o(c), 1., decimal=6)
+
+    def test_mkl(self):
+        o = specdesc("mkl")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length, dtype='float32')
+        c.norm = a
+        assert_almost_equal( sum(log(1.+ a/1.e-10 ) ) / o(c), 1, decimal=6)
+
+    def test_specflux(self):
+        o = specdesc("specflux")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length, dtype='float32')
+        c.norm = a
+        assert_equal( sum(a), o(c))
+        assert_equal( 0, o(c))
+        c.norm = zeros(c.length, dtype='float32')
+        assert_equal( 0, o(c))
+
+    def test_centroid(self):
+        o = specdesc("centroid")
+        c = cvec()
+        # make sure centroid of zeros is zero
+        assert_equal( 0., o(c))
+        a = arange(c.length, dtype='float32')
+        c.norm = a
+        centroid = sum(a*a) / sum(a)
+        assert_almost_equal (centroid, o(c), decimal = 2)
+
+        c.norm = a * .5 
+        assert_almost_equal (centroid, o(c), decimal = 2)
+
+    def test_spread(self):
+        o = specdesc("spread")
+        c = cvec(2048)
+        ramp = arange(c.length, dtype='float32')
+        assert_equal( 0., o(c))
+
+        a = ramp
+        c.norm = a
+        centroid = sum(a*a) / sum(a)
+        spread = sum( a * pow(ramp - centroid, 2.) ) / sum(a)
+        assert_almost_equal (o(c), spread, decimal = 1)
+
+    def test_skewness(self):
+        o = specdesc("skewness")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length, dtype='float32')
+        c.norm = a
+        centroid = sum(a*a) / sum(a)
+        spread = sum( (a - centroid)**2 *a) / sum(a)
+        skewness = sum( (a - centroid)**3 *a) / sum(a) / spread **1.5
+        assert_almost_equal (skewness, o(c), decimal = 2)
+
+        c.norm = a * 3
+        assert_almost_equal (skewness, o(c), decimal = 2)
+
+    def test_kurtosis(self):
+        o = specdesc("kurtosis")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length, dtype='float32')
+        c.norm = a
+        centroid = sum(a*a) / sum(a)
+        spread = sum( (a - centroid)**2 *a) / sum(a)
+        kurtosis = sum( (a - centroid)**4 *a) / sum(a) / spread **2
+        assert_almost_equal (kurtosis, o(c), decimal = 2)
+
+    def test_slope(self):
+        o = specdesc("slope")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length * 2, 0, -2, dtype='float32')
+        k = arange(c.length, dtype='float32')
+        c.norm = a
+        num = len(a) * sum(k*a) - sum(k)*sum(a)
+        den = (len(a) * sum(k**2) - sum(k)**2)
+        slope = num/den/sum(a)
+        assert_almost_equal (slope, o(c), decimal = 5)
+
+        a = arange(0, c.length * 2, +2, dtype='float32')
+        c.norm = a
+        num = len(a) * sum(k*a) - sum(k)*sum(a)
+        den = (len(a) * sum(k**2) - sum(k)**2)
+        slope = num/den/sum(a)
+        assert_almost_equal (slope, o(c), decimal = 5)
+
+        a = arange(0, c.length * 2, +2, dtype='float32')
+        c.norm = a * 2
+        assert_almost_equal (slope, o(c), decimal = 5)
+
+    def test_decrease(self):
+        o = specdesc("decrease")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length * 2, 0, -2, dtype='float32')
+        k = arange(c.length, dtype='float32')
+        c.norm = a
+        decrease = sum((a[1:] - a [0]) / k[1:]) / sum(a[1:]) 
+        assert_almost_equal (decrease, o(c), decimal = 5)
+
+        a = arange(0, c.length * 2, +2, dtype='float32')
+        c.norm = a
+        decrease = sum((a[1:] - a [0]) / k[1:]) / sum(a[1:]) 
+        assert_almost_equal (decrease, o(c), decimal = 5)
+
+        a = arange(0, c.length * 2, +2, dtype='float32')
+        c.norm = a * 2
+        decrease = sum((a[1:] - a [0]) / k[1:]) / sum(a[1:]) 
+        assert_almost_equal (decrease, o(c), decimal = 5)
+
+    def test_rolloff(self):
+        o = specdesc("rolloff")
+        c = cvec()
+        assert_equal( 0., o(c))
+        a = arange(c.length * 2, 0, -2, dtype='float32')
+        k = arange(c.length, dtype='float32')
+        c.norm = a
+        cumsum = .95*sum(a*a)
+        i = 0; rollsum = 0
+        while rollsum < cumsum:
+          rollsum += a[i]*a[i]
+          i+=1
+        rolloff = i 
+        assert_equal (rolloff, o(c))
+
+
+if __name__ == '__main__':
+    from unittest import main
+    main()
