From: Paul Brossier Date: Sat, 1 Dec 2007 22:00:03 +0000 (+0100) Subject: add tests for adesign and filter X-Git-Tag: bzr2git~410 X-Git-Url: http://git.tremily.us/?a=commitdiff_plain;h=69134340c402870c34c3670cc4c791dfce6c2c78;p=aubio.git add tests for adesign and filter --- diff --git a/tests/python/src/temporal/adesign.py b/tests/python/src/temporal/adesign.py new file mode 100644 index 00000000..8b4b98fb --- /dev/null +++ b/tests/python/src/temporal/adesign.py @@ -0,0 +1,51 @@ +from template import aubio_unit_template +from aubio.aubiowrapper import * + +samplerate = 44100 +buf_size = 1024 +channels = 2 + +class adsgn_filter_unit(aubio_unit_template): + + def setUp(self): + self.o = new_aubio_adsgn_filter(samplerate, channels) + + def tearDown(self): + del_aubio_adsgn_filter(self.o) + + def test_creation(self): + pass + + def test_filter_zeroes(self): + """ check filter run on a vector full of zeroes returns zeros """ + vec = new_fvec(buf_size, channels) + aubio_adsgn_filter_do(self.o, vec) + for index in range(buf_size): + for channel in range(channels): + self.assertEqual(0., fvec_read_sample(vec,channel,index)) + del_fvec(vec) + + def test_filter_ones(self): + vec = new_fvec(buf_size, channels) + for index in range(buf_size): + for channel in range(channels): + fvec_write_sample(vec, 1., channel, index) + aubio_adsgn_filter_do(self.o, vec) + for index in range(buf_size): + for channel in range(channels): + self.assertNotEqual(0., fvec_read_sample(vec,channel,index)) + del_fvec(vec) + + def test_filter_denormal(self): + vec = new_fvec(buf_size, channels) + for index in range(buf_size): + for channel in range(channels): + fvec_write_sample(vec, 1.e-37, channel, index) + aubio_adsgn_filter_do(self.o, vec) + for index in range(buf_size): + for channel in range(channels): + self.assertEqual(0., fvec_read_sample(vec,channel,index)) + del_fvec(vec) + +if __name__ == '__main__': + unittest.main() diff --git a/tests/python/src/temporal/filter.py b/tests/python/src/temporal/filter.py new file mode 100644 index 00000000..c236057d --- /dev/null +++ b/tests/python/src/temporal/filter.py @@ -0,0 +1,30 @@ +from template import aubio_unit_template +from aubio.aubiowrapper import * + +samplerate = 44100 +buf_size = 1024 +channels = 2 + +class filter_unit(aubio_unit_template): + + def setUp(self): + self.o = new_aubio_filter(samplerate, 8, channels) + + def tearDown(self): + del_aubio_filter(self.o) + + def test_creation(self): + """ check filter creation and deletion """ + pass + + def test_filter_zeroes(self): + """ check filter run on a vector full of zeroes returns zeros """ + vec = new_fvec(buf_size, channels) + aubio_filter_do(self.o, vec) + for index in range(buf_size/2+1): + for channel in range(channels): + self.assertEqual(fvec_read_sample(vec,channel,index),0.) + del_fvec(vec) + +if __name__ == '__main__': + unittest.main()