tests/python/src/temporal/: update a_weighting tests
authorPaul Brossier <piem@piem.org>
Thu, 8 Oct 2009 00:13:38 +0000 (02:13 +0200)
committerPaul Brossier <piem@piem.org>
Thu, 8 Oct 2009 00:13:38 +0000 (02:13 +0200)
tests/python/src/temporal/a_weighting.py
tests/python/src/temporal/a_weighting_test_simple.expected [new file with mode: 0644]

index 9a7f78bacb1ab3c1925839db0387c3a5392814e3..1787e782b389bfc30af82951f7d2ad417d486a3d 100644 (file)
@@ -2,9 +2,9 @@ from localaubio import *
 
 samplerate = 44100
 buf_size = 1024
-channels = 2
+channels = 1
 
-class adsgn_filter_unit(aubio_unit_template):
+class a_weighting_unit (aubio_unit_template):
 
   def setUp(self):
     self.o = new_aubio_filter_a_weighting (samplerate, channels)
@@ -46,6 +46,22 @@ class adsgn_filter_unit(aubio_unit_template):
         self.assertEqual(0., fvec_read_sample(vec,channel,index))
     del_fvec(vec)
 
+  def test_simple(self):
+    buf_size = 32
+    input = new_fvec (buf_size, 1)
+    output = new_fvec (buf_size, 1)
+    expected = array_from_text_file('src/temporal/a_weighting_test_simple.expected')
+    fvec_write_sample (input, 0.5, 0, 12)
+    for i in range(buf_size):
+      for c in range(channels):
+        self.assertEqual(expected[0][i], fvec_read_sample(input, c, i))
+    f = new_aubio_filter_a_weighting (samplerate, channels)
+    aubio_filter_do_outplace (f, input, output)
+    del_aubio_filter (f)
+    for i in range(buf_size):
+      for c in range(channels):
+        self.assertCloseEnough(expected[1][i], fvec_read_sample(output, c, i))
+
 if __name__ == '__main__':
   import unittest
   unittest.main()
diff --git a/tests/python/src/temporal/a_weighting_test_simple.expected b/tests/python/src/temporal/a_weighting_test_simple.expected
new file mode 100644 (file)
index 0000000..6cd3ff3
--- /dev/null
@@ -0,0 +1,2 @@
+ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 5.00000000e-01 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00
+ 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 0.00000000e+00 1.27870563e-01 2.58244342e-01 1.18719361e-01 -4.02623805e-02 -5.61812129e-02 -5.24739734e-02 -4.72329276e-02 -4.23394349e-02 -3.79219586e-02 -3.39473148e-02 -3.03724479e-02 -2.71574847e-02 -2.42664433e-02 -2.16669285e-02 -1.93297810e-02 -1.72287543e-02 -1.53402241e-02 -1.36429261e-02 -1.21177207e-02 -1.07473802e-02