source: python/tests/test_onset.py @ eef6335

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5sampleryinfft+
Last change on this file since eef6335 was 0b6d23d, checked in by Paul Brossier <piem@piem.org>, 8 years ago

python/tests: fix most prospect warnings

  • Property mode set to 100755
File size: 2.4 KB
Line 
1#! /usr/bin/env python
2
3from unittest import main
4from numpy.testing import TestCase, assert_equal, assert_almost_equal
5from aubio import onset
6
7class aubio_onset_default(TestCase):
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])
13
14class 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):
22        assert_equal (self.o.get_delay(), int(4.3 * self.o.hop_size))
23
24    def test_get_delay_s(self):
25        assert_almost_equal (self.o.get_delay_s(), self.o.get_delay() / float(self.samplerate))
26
27    def test_get_delay_ms(self):
28        assert_almost_equal (self.o.get_delay_ms(), self.o.get_delay() * 1000. / self.samplerate, 5)
29
30    def test_get_minioi(self):
31        assert_almost_equal (self.o.get_minioi(), 0.02 * self.samplerate)
32
33    def test_get_minioi_s(self):
34        assert_almost_equal (self.o.get_minioi_s(), 0.02)
35
36    def test_get_minioi_ms(self):
37        assert_equal (self.o.get_minioi_ms(), 20.)
38
39    def test_get_threshold(self):
40        assert_almost_equal (self.o.get_threshold(), 0.3)
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
77class aubio_onset_96000(aubio_onset_params):
78    samplerate = 96000
79
80class aubio_onset_32000(aubio_onset_params):
81    samplerate = 32000
82
83class aubio_onset_8000(aubio_onset_params):
84    samplerate = 8000
85
86if __name__ == '__main__':
87    main()
Note: See TracBrowser for help on using the repository browser.