source: python/tests/test_slicing.py @ bc24e9c

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since bc24e9c was 88432a9, checked in by Paul Brossier <piem@piem.org>, 11 years ago

python/lib/aubio/slicing.py: rewrite slicing loop from aubiocut, add some tests

  • Property mode set to 100755
File size: 1.6 KB
Line 
1#! /usr/bin/env python
2
3from numpy.testing import TestCase, run_module_suite
4from numpy.testing import assert_equal, assert_almost_equal
5
6from aubio import slice_source_at_stamps
7from utils import count_samples_in_file, count_samples_in_directory
8
9import tempfile
10import shutil
11
12class aubio_slicing_test_case(TestCase):
13
14    def setUp(self):
15        self.source_file = 'chocolate_1min.wav'
16        self.output_dir = tempfile.mkdtemp(suffix = 'aubio_slicing_test_case')
17
18    def test_slice_start_only(self):
19        regions_start = [i*1000 for i in range(100)]
20        slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
21
22    def test_slice_start_only_no_zero(self):
23        regions_start = [i*1000 for i in range(1, 100)]
24        slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
25
26    def test_slice_start_beyond_end(self):
27        regions_start = [i*1000 for i in range(1, 100)]
28        regions_start += [count_samples_in_file(self.source_file)]
29        regions_start += [count_samples_in_file(self.source_file) + 1000]
30        slice_source_at_stamps(self.source_file, regions_start, output_dir = self.output_dir)
31
32    def tearDown(self):
33        original_samples = count_samples_in_file(self.source_file)
34        written_samples = count_samples_in_directory(self.output_dir)
35        assert_equal(original_samples, written_samples,
36            "number samples written different from number of original samples")
37        shutil.rmtree(self.output_dir)
38
39if __name__ == '__main__':
40    from unittest import main
41    main()
Note: See TracBrowser for help on using the repository browser.