[832b0f64] | 1 | #! /usr/bin/env python |
---|
| 2 | |
---|
| 3 | from unittest import main |
---|
| 4 | from numpy.testing import TestCase, assert_equal, assert_almost_equal |
---|
| 5 | import aubio |
---|
| 6 | |
---|
| 7 | class aubio_tempo_default(TestCase): |
---|
| 8 | |
---|
| 9 | def test_members(self): |
---|
| 10 | o = aubio.tempo() |
---|
| 11 | assert_equal ([o.buf_size, o.hop_size, o.method, o.samplerate], |
---|
| 12 | [1024,512,'default',44100]) |
---|
| 13 | |
---|
| 14 | class aubio_tempo_params(TestCase): |
---|
| 15 | |
---|
| 16 | samplerate = 44100 |
---|
| 17 | |
---|
| 18 | def setUp(self): |
---|
| 19 | self.o = aubio.tempo(samplerate = self.samplerate) |
---|
| 20 | |
---|
| 21 | def test_get_delay(self): |
---|
| 22 | self.assertEqual(self.o.get_delay(), 0) |
---|
| 23 | |
---|
| 24 | def test_set_delay(self): |
---|
| 25 | val = 256 |
---|
| 26 | self.o.set_delay(val) |
---|
| 27 | assert_equal (self.o.get_delay(), val) |
---|
| 28 | |
---|
| 29 | def test_get_delay_s(self): |
---|
| 30 | self.assertEqual(self.o.get_delay_s(), 0.) |
---|
| 31 | |
---|
| 32 | def test_set_delay_s(self): |
---|
| 33 | val = .05 |
---|
| 34 | self.o.set_delay_s(val) |
---|
| 35 | assert_almost_equal (self.o.get_delay_s(), val) |
---|
| 36 | |
---|
| 37 | def test_get_delay_ms(self): |
---|
| 38 | self.assertEqual(self.o.get_delay_ms(), 0.) |
---|
| 39 | |
---|
| 40 | def test_set_delay_ms(self): |
---|
| 41 | val = 50. |
---|
| 42 | self.o.set_delay_ms(val) |
---|
| 43 | assert_almost_equal (self.o.get_delay_ms(), val) |
---|
| 44 | |
---|
| 45 | def test_get_threshold(self): |
---|
| 46 | assert_almost_equal(self.o.get_threshold(), 0.3) |
---|
| 47 | |
---|
| 48 | def test_set_threshold(self): |
---|
| 49 | val = .1 |
---|
| 50 | self.o.set_threshold(val) |
---|
| 51 | assert_almost_equal (self.o.get_threshold(), val) |
---|
| 52 | |
---|
| 53 | def test_get_silence(self): |
---|
| 54 | self.assertEqual(self.o.get_silence(), -90.) |
---|
| 55 | |
---|
| 56 | def test_set_silence(self): |
---|
| 57 | val = -50. |
---|
| 58 | self.o.set_silence(val) |
---|
| 59 | assert_almost_equal (self.o.get_silence(), val) |
---|
| 60 | |
---|
| 61 | def test_get_last(self): |
---|
| 62 | self.assertEqual(self.o.get_last(), 0.) |
---|
| 63 | |
---|
| 64 | def test_get_last_s(self): |
---|
| 65 | self.assertEqual(self.o.get_last_s(), 0.) |
---|
| 66 | |
---|
| 67 | def test_get_last_ms(self): |
---|
| 68 | self.assertEqual(self.o.get_last_ms(), 0.) |
---|
| 69 | |
---|
| 70 | def test_get_period(self): |
---|
| 71 | self.assertEqual(self.o.get_period(), 0.) |
---|
| 72 | |
---|
| 73 | def test_get_period_s(self): |
---|
| 74 | self.assertEqual(self.o.get_period_s(), 0.) |
---|
| 75 | |
---|
| 76 | def test_get_last_tatum(self): |
---|
| 77 | self.assertEqual(self.o.get_last_tatum(), 0.) |
---|
| 78 | |
---|
| 79 | def test_set_tatum_signature(self): |
---|
| 80 | self.o.set_tatum_signature(8) |
---|
| 81 | self.o.set_tatum_signature(64) |
---|
| 82 | self.o.set_tatum_signature(1) |
---|
| 83 | |
---|
| 84 | def test_set_wrong_tatum_signature(self): |
---|
| 85 | with self.assertRaises(ValueError): |
---|
| 86 | self.o.set_tatum_signature(101) |
---|
| 87 | with self.assertRaises(ValueError): |
---|
| 88 | self.o.set_tatum_signature(0) |
---|
| 89 | |
---|
| 90 | if __name__ == '__main__': |
---|
| 91 | main() |
---|