source: python/tests/test_pitchshift.py @ b3f79ca

feature/cnnfeature/crepefeature/pitchshiftfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretch
Last change on this file since b3f79ca was 60cbfe8, checked in by Paul Brossier <piem@piem.org>, 8 years ago

python/tests/test_pitchshift.py: skip test on RuntimeError?

  • Property mode set to 100755
File size: 1.4 KB
Line 
1#! /usr/bin/env python
2
3from numpy.testing import TestCase
4import aubio
5
6class aubio_pitchshift(TestCase):
7
8    def setUp(self):
9        try:
10            self.o = aubio.pitchshift()
11        except RuntimeError as e:
12            self.skipTest("creating aubio.pitchshift failed (recompile with rubberband?)")
13
14    def test_default_creation(self):
15        self.assertEqual(self.o.get_pitchscale(), 1)
16        self.assertEqual(self.o.get_transpose(), 0)
17
18    def test_on_zeros(self):
19        test_length = 20000
20        read = 0
21        # test on zeros
22        vec = aubio.fvec(512)
23        transpose_range = 24
24        while read < test_length:
25            # transpose the samples
26            out = self.o(vec)
27            self.assertTrue((out == 0).all())
28            # position in the file (between 0. and 1.)
29            percent_read = read / float(test_length)
30            # variable transpose rate (in semitones)
31            transpose = 2 * transpose_range * percent_read - transpose_range
32            # set transpose rate
33            self.o.set_transpose(transpose)
34            read += len(vec)
35
36    def test_transpose_too_high(self):
37        with self.assertRaises(ValueError):
38            self.o.set_transpose(24.3)
39
40    def test_transpose_too_low(self):
41        with self.assertRaises(ValueError):
42            self.o.set_transpose(-24.3)
43
44if __name__ == '__main__':
45    from nose2 import main
46    main()
Note: See TracBrowser for help on using the repository browser.