[974dddc] | 1 | from template import aubio_unit_template |
---|
| 2 | from localaubio import * |
---|
[203c551] | 3 | |
---|
| 4 | buf_size = 2048 |
---|
| 5 | channels = 3 |
---|
| 6 | |
---|
[974dddc] | 7 | class cvec_unit(aubio_unit_template): |
---|
[203c551] | 8 | |
---|
| 9 | def setUp(self): |
---|
| 10 | self.vector = new_cvec(buf_size, channels) |
---|
| 11 | |
---|
| 12 | def tearDown(self): |
---|
| 13 | del_cvec(self.vector) |
---|
| 14 | |
---|
| 15 | def test_cvec(self): |
---|
| 16 | """ create and delete cvec """ |
---|
| 17 | pass |
---|
| 18 | |
---|
| 19 | def test_cvec_read_norm(self): |
---|
| 20 | """ check new cvec norm elements are set to 0. """ |
---|
| 21 | for index in range(buf_size/2+1): |
---|
| 22 | for channel in range(channels): |
---|
| 23 | self.assertEqual(cvec_read_norm(self.vector,channel,index),0.) |
---|
| 24 | |
---|
| 25 | def test_cvec_read_phas(self): |
---|
| 26 | """ check new cvec phas elements are set to 0. """ |
---|
| 27 | for index in range(buf_size/2+1): |
---|
| 28 | for channel in range(channels): |
---|
| 29 | self.assertEqual(cvec_read_phas(self.vector,channel,index),0.) |
---|
| 30 | |
---|
| 31 | def test_cvec_write_norm(self): |
---|
| 32 | """ check new cvec norm elements are set with cvec_write_norm """ |
---|
| 33 | for index in range(buf_size/2+1): |
---|
| 34 | for channel in range(channels): |
---|
| 35 | cvec_write_norm(self.vector,1.,channel,index) |
---|
| 36 | for index in range(buf_size/2+1): |
---|
| 37 | for channel in range(channels): |
---|
| 38 | self.assertEqual(cvec_read_norm(self.vector,channel,index),1.) |
---|
| 39 | |
---|
| 40 | def test_cvec_write_phas(self): |
---|
| 41 | """ check new cvec phas elements are set with cvec_write_phas """ |
---|
| 42 | for index in range(buf_size/2+1): |
---|
| 43 | for channel in range(channels): |
---|
| 44 | cvec_write_phas(self.vector,1.,channel,index) |
---|
| 45 | for index in range(buf_size/2+1): |
---|
| 46 | for channel in range(channels): |
---|
| 47 | self.assertEqual(cvec_read_phas(self.vector,channel,index),1.) |
---|
| 48 | |
---|
| 49 | if __name__ == '__main__': |
---|
| 50 | unittest.main() |
---|