Changeset 8eff66d


Ignore:
Timestamp:
Feb 22, 2014, 7:36:50 PM (6 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
467122d
Parents:
30fb06f
Message:

python/tests/test_onset.py: improve

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_onset.py

    r30fb06f r8eff66d  
    33from numpy.testing import TestCase, run_module_suite
    44from numpy.testing import assert_equal, assert_almost_equal
    5 # WARNING: numpy also has an fft object
    6 from aubio import onset, cvec
    7 from numpy import array, shape, arange, zeros, log
    8 from math import pi
     5from aubio import onset
    96
    10 class aubio_onset(TestCase):
     7class aubio_onset_default(TestCase):
    118
    129    def test_members(self):
     
    1411        assert_equal ([o.buf_size, o.hop_size, o.method, o.samplerate],
    1512            [1024,512,'default',44100])
    16    
     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
    1785
    1886if __name__ == '__main__':
Note: See TracChangeset for help on using the changeset viewer.