source: python/tests/test_onset.py @ 319edae

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/timestretchfix/ffmpeg5
Last change on this file since 319edae was 319edae, checked in by Paul Brossier <piem@piem.org>, 6 years ago

[tests] avoid some imports, move main to end

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