From 70dd55c08cc1f84568f596890c9ee5748d6dbea1 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Thu, 8 Oct 2009 02:48:37 +0200 Subject: [PATCH] tests/python/src/temporal/c_weighting.py: add test for c_weighting --- tests/python/src/temporal/c_weighting.py | 59 +++++++++++++++++++ .../temporal/c_weighting_test_simple.expected | 2 + .../c_weighting_test_simple_8000.expected | 2 + 3 files changed, 63 insertions(+) create mode 100644 tests/python/src/temporal/c_weighting.py create mode 100644 tests/python/src/temporal/c_weighting_test_simple.expected create mode 100644 tests/python/src/temporal/c_weighting_test_simple_8000.expected diff --git a/tests/python/src/temporal/c_weighting.py b/tests/python/src/temporal/c_weighting.py new file mode 100644 index 00000000..35dd4030 --- /dev/null +++ b/tests/python/src/temporal/c_weighting.py @@ -0,0 +1,59 @@ +from localaubio import * + +class c_weighting_unit(aubio_unit_template): + + def test_simple(self): + expected = array_from_text_file('src/temporal/c_weighting_test_simple.expected') + samplerate = 44100 + channels = 1 + buf_size = 32 + + # prepare input + input = new_fvec (buf_size, 1) + output = new_fvec (buf_size, 1) + fvec_write_sample (input, 0.5, 0, 12) + + # check input + for i in range(buf_size): + for c in range(channels): + self.assertEqual(expected[0][i], fvec_read_sample(input, c, i)) + + # filter + f = new_aubio_filter_c_weighting (samplerate, channels) + aubio_filter_do_outplace (f, input, output) + del_aubio_filter (f) + + # check output + for i in range(buf_size): + for c in range(channels): + self.assertAlmostEqual(expected[1][i], fvec_read_sample(output, c, i)) + + def test_simple_8000(self): + expected = array_from_text_file('src/temporal/c_weighting_test_simple_8000.expected') + samplerate = 8000 + channels = 1 + buf_size = 32 + + # prepare input + input = new_fvec (buf_size, 1) + output = new_fvec (buf_size, 1) + fvec_write_sample (input, 0.5, 0, 12) + + # check input + for i in range(buf_size): + for c in range(channels): + self.assertEqual(expected[0][i], fvec_read_sample(input, c, i)) + + # filter + f = new_aubio_filter_c_weighting (samplerate, channels) + aubio_filter_do_outplace (f, input, output) + del_aubio_filter (f) + + # check output + for i in range(buf_size): + for c in range(channels): + self.assertAlmostEqual(expected[1][i], fvec_read_sample(output, c, i)) + +if __name__ == '__main__': + import unittest + unittest.main() diff --git a/tests/python/src/temporal/c_weighting_test_simple.expected b/tests/python/src/temporal/c_weighting_test_simple.expected new file mode 100644 index 00000000..70e2b159 --- /dev/null +++ b/tests/python/src/temporal/c_weighting_test_simple.expected @@ -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.08504281e-01 2.31621372e-01 1.38614617e-01 1.58040475e-02 -9.84900252e-04 -2.72686896e-03 -2.87772967e-03 -2.87932142e-03 -2.86783482e-03 -2.85529016e-03 -2.84270413e-03 -2.83016008e-03 -2.81766458e-03 -2.80521796e-03 -2.79282009e-03 -2.78047079e-03 -2.76816989e-03 -2.75591721e-03 -2.74371257e-03 -2.73155579e-03 diff --git a/tests/python/src/temporal/c_weighting_test_simple_8000.expected b/tests/python/src/temporal/c_weighting_test_simple_8000.expected new file mode 100644 index 00000000..f34eda6b --- /dev/null +++ b/tests/python/src/temporal/c_weighting_test_simple_8000.expected @@ -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 3.39108697e-01 2.23441868e-01 -1.31029191e-01 3.33061907e-02 -2.89386407e-02 -1.68524660e-02 -5.02737225e-03 -2.47225074e-02 -3.06670933e-03 -2.20570849e-02 -5.57507292e-03 -1.81342032e-02 -7.89289483e-03 -1.50756531e-02 -9.23565472e-03 -1.29964131e-02 -9.78591684e-03 -1.16053213e-02 -9.84372912e-03 -1.06315198e-02 -- 2.26.2