1 | from template import aubio_unit_template |
---|
2 | from aubio.aubiowrapper import * |
---|
3 | |
---|
4 | samplerate = 44100 |
---|
5 | buf_size = 1024 |
---|
6 | channels = 2 |
---|
7 | |
---|
8 | class adsgn_filter_unit(aubio_unit_template): |
---|
9 | |
---|
10 | def setUp(self): |
---|
11 | self.o = new_aubio_adsgn_filter(samplerate, channels) |
---|
12 | |
---|
13 | def tearDown(self): |
---|
14 | del_aubio_adsgn_filter(self.o) |
---|
15 | |
---|
16 | def test_creation(self): |
---|
17 | pass |
---|
18 | |
---|
19 | def test_filter_zeroes(self): |
---|
20 | """ check filter run on a vector full of zeroes returns zeros """ |
---|
21 | vec = new_fvec(buf_size, channels) |
---|
22 | aubio_adsgn_filter_do(self.o, vec) |
---|
23 | for index in range(buf_size): |
---|
24 | for channel in range(channels): |
---|
25 | self.assertEqual(0., fvec_read_sample(vec,channel,index)) |
---|
26 | del_fvec(vec) |
---|
27 | |
---|
28 | def test_filter_ones(self): |
---|
29 | vec = new_fvec(buf_size, channels) |
---|
30 | for index in range(buf_size): |
---|
31 | for channel in range(channels): |
---|
32 | fvec_write_sample(vec, 1., channel, index) |
---|
33 | aubio_adsgn_filter_do(self.o, vec) |
---|
34 | for index in range(buf_size): |
---|
35 | for channel in range(channels): |
---|
36 | self.assertNotEqual(0., fvec_read_sample(vec,channel,index)) |
---|
37 | del_fvec(vec) |
---|
38 | |
---|
39 | def test_filter_denormal(self): |
---|
40 | vec = new_fvec(buf_size, channels) |
---|
41 | for index in range(buf_size): |
---|
42 | for channel in range(channels): |
---|
43 | fvec_write_sample(vec, 1.e-37, channel, index) |
---|
44 | aubio_adsgn_filter_do(self.o, vec) |
---|
45 | for index in range(buf_size): |
---|
46 | for channel in range(channels): |
---|
47 | self.assertEqual(0., fvec_read_sample(vec,channel,index)) |
---|
48 | del_fvec(vec) |
---|
49 | |
---|
50 | if __name__ == '__main__': |
---|
51 | unittest.main() |
---|