[75e715f] | 1 | #! /usr/bin/env python |
---|
[312826c] | 2 | |
---|
[0b6d23d] | 3 | from unittest import main |
---|
| 4 | from numpy.testing import TestCase, assert_equal, assert_almost_equal |
---|
[8eff66d] | 5 | from aubio import onset |
---|
[312826c] | 6 | |
---|
[8eff66d] | 7 | class aubio_onset_default(TestCase): |
---|
[312826c] | 8 | |
---|
| 9 | def test_members(self): |
---|
| 10 | o = onset() |
---|
| 11 | assert_equal ([o.buf_size, o.hop_size, o.method, o.samplerate], |
---|
| 12 | [1024,512,'default',44100]) |
---|
[8eff66d] | 13 | |
---|
| 14 | class aubio_onset_params(TestCase): |
---|
| 15 | |
---|
| 16 | samplerate = 44100 |
---|
| 17 | |
---|
| 18 | def setUp(self): |
---|
| 19 | self.o = onset(samplerate = self.samplerate) |
---|
| 20 | |
---|
| 21 | def test_get_delay(self): |
---|
[25e0b0e] | 22 | self.assertGreater(self.o.get_delay(), 0) |
---|
[8eff66d] | 23 | |
---|
| 24 | def test_get_delay_s(self): |
---|
[25e0b0e] | 25 | self.assertGreater(self.o.get_delay_s(), 0.) |
---|
[8eff66d] | 26 | |
---|
| 27 | def test_get_delay_ms(self): |
---|
[25e0b0e] | 28 | self.assertGreater(self.o.get_delay_ms(), 0.) |
---|
[8eff66d] | 29 | |
---|
| 30 | def test_get_minioi(self): |
---|
[25e0b0e] | 31 | self.assertGreater(self.o.get_minioi(), 0) |
---|
[8eff66d] | 32 | |
---|
| 33 | def test_get_minioi_s(self): |
---|
[25e0b0e] | 34 | self.assertGreater(self.o.get_minioi_s(), 0.) |
---|
[8eff66d] | 35 | |
---|
| 36 | def test_get_minioi_ms(self): |
---|
[25e0b0e] | 37 | self.assertGreater(self.o.get_minioi_ms(), 0.) |
---|
[8eff66d] | 38 | |
---|
| 39 | def test_get_threshold(self): |
---|
[25e0b0e] | 40 | self.assertGreater(self.o.get_threshold(), 0.) |
---|
[8eff66d] | 41 | |
---|
| 42 | def test_set_delay(self): |
---|
| 43 | val = 256 |
---|
| 44 | self.o.set_delay(val) |
---|
| 45 | assert_equal (self.o.get_delay(), val) |
---|
| 46 | |
---|
| 47 | def test_set_delay_s(self): |
---|
| 48 | val = .05 |
---|
| 49 | self.o.set_delay_s(val) |
---|
| 50 | assert_almost_equal (self.o.get_delay_s(), val) |
---|
| 51 | |
---|
| 52 | def test_set_delay_ms(self): |
---|
| 53 | val = 50. |
---|
| 54 | self.o.set_delay_ms(val) |
---|
| 55 | assert_almost_equal (self.o.get_delay_ms(), val) |
---|
| 56 | |
---|
| 57 | def test_set_minioi(self): |
---|
| 58 | val = 200 |
---|
| 59 | self.o.set_minioi(val) |
---|
| 60 | assert_equal (self.o.get_minioi(), val) |
---|
| 61 | |
---|
| 62 | def test_set_minioi_s(self): |
---|
| 63 | val = 0.04 |
---|
| 64 | self.o.set_minioi_s(val) |
---|
| 65 | assert_almost_equal (self.o.get_minioi_s(), val) |
---|
| 66 | |
---|
| 67 | def test_set_minioi_ms(self): |
---|
| 68 | val = 40. |
---|
| 69 | self.o.set_minioi_ms(val) |
---|
| 70 | assert_almost_equal (self.o.get_minioi_ms(), val) |
---|
| 71 | |
---|
| 72 | def test_set_threshold(self): |
---|
| 73 | val = 0.2 |
---|
| 74 | self.o.set_threshold(val) |
---|
| 75 | assert_almost_equal (self.o.get_threshold(), val) |
---|
| 76 | |
---|
| 77 | class aubio_onset_96000(aubio_onset_params): |
---|
| 78 | samplerate = 96000 |
---|
| 79 | |
---|
| 80 | class aubio_onset_32000(aubio_onset_params): |
---|
| 81 | samplerate = 32000 |
---|
| 82 | |
---|
| 83 | class aubio_onset_8000(aubio_onset_params): |
---|
| 84 | samplerate = 8000 |
---|
[312826c] | 85 | |
---|
| 86 | if __name__ == '__main__': |
---|
| 87 | main() |
---|