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