ref: 832b0f6461740d1322d1ecb04584d4dc7fdad816
parent: 075bc57f99576413ff37b3cbd4b18c24b1c0b8ec
author: Paul Brossier <piem@piem.org>
date: Sat Nov 24 13:31:25 EST 2018
[py] add tempo tests
--- /dev/null
+++ b/python/tests/test_tempo.py
@@ -1,0 +1,91 @@
+#! /usr/bin/env python
+
+from unittest import main
+from numpy.testing import TestCase, assert_equal, assert_almost_equal
+import aubio
+
+class aubio_tempo_default(TestCase):
+
+ def test_members(self):
+ o = aubio.tempo()
+ assert_equal ([o.buf_size, o.hop_size, o.method, o.samplerate],
+ [1024,512,'default',44100])
+
+class aubio_tempo_params(TestCase):
+
+ samplerate = 44100
+
+ def setUp(self):
+ self.o = aubio.tempo(samplerate = self.samplerate)
+
+ def test_get_delay(self):
+ self.assertEqual(self.o.get_delay(), 0)
+
+ def test_set_delay(self):
+ val = 256
+ self.o.set_delay(val)
+ assert_equal (self.o.get_delay(), val)
+
+ def test_get_delay_s(self):
+ self.assertEqual(self.o.get_delay_s(), 0.)
+
+ def test_set_delay_s(self):
+ val = .05
+ self.o.set_delay_s(val)
+ assert_almost_equal (self.o.get_delay_s(), val)
+
+ def test_get_delay_ms(self):
+ self.assertEqual(self.o.get_delay_ms(), 0.)
+
+ def test_set_delay_ms(self):
+ val = 50.
+ self.o.set_delay_ms(val)
+ assert_almost_equal (self.o.get_delay_ms(), val)
+
+ def test_get_threshold(self):
+ assert_almost_equal(self.o.get_threshold(), 0.3)
+
+ def test_set_threshold(self):
+ val = .1
+ self.o.set_threshold(val)
+ assert_almost_equal (self.o.get_threshold(), val)
+
+ def test_get_silence(self):
+ self.assertEqual(self.o.get_silence(), -90.)
+
+ def test_set_silence(self):
+ val = -50.
+ self.o.set_silence(val)
+ assert_almost_equal (self.o.get_silence(), val)
+
+ def test_get_last(self):
+ self.assertEqual(self.o.get_last(), 0.)
+
+ def test_get_last_s(self):
+ self.assertEqual(self.o.get_last_s(), 0.)
+
+ def test_get_last_ms(self):
+ self.assertEqual(self.o.get_last_ms(), 0.)
+
+ def test_get_period(self):
+ self.assertEqual(self.o.get_period(), 0.)
+
+ def test_get_period_s(self):
+ self.assertEqual(self.o.get_period_s(), 0.)
+
+ def test_get_last_tatum(self):
+ self.assertEqual(self.o.get_last_tatum(), 0.)
+
+ def test_set_tatum_signature(self):
+ self.o.set_tatum_signature(8)
+ self.o.set_tatum_signature(64)
+ self.o.set_tatum_signature(1)
+
+ def test_set_wrong_tatum_signature(self):
+ with self.assertRaises(ValueError):
+ self.o.set_tatum_signature(101)
+ with self.assertRaises(ValueError):
+ self.o.set_tatum_signature(0)
+
+if __name__ == '__main__':
+ main()