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