Ignore:
Timestamp:
Apr 1, 2019, 1:30:22 AM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/cnn, feature/crepe, feature/timestretch, fix/ffmpeg5, master
Children:
65f7886
Parents:
1301f66 (diff), 439ba7b (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'feature/pitchshift' into feature/timestretch

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_source.py

    r1301f66 r7a02ce9  
    44from numpy.testing import TestCase, assert_equal
    55from aubio import source
    6 from utils import list_all_sounds
     6from utils import list_all_sounds, parse_file_samplerate
    77import unittest
    8 from _tools import parametrize, assert_raises, assert_equal, skipTest
     8from _tools import assert_raises, assert_equal, assert_warns
     9from _tools import parametrize, skipTest
    910
    1011list_of_sounds = list_all_sounds('sounds')
     
    2425_debug = False
    2526
    26 class Test_aubio_source_test_case(object):
    27 
    28     @parametrize('filename', list_of_sounds)
    29     def test_close_file(self, filename):
     27
     28class Test_aubio_source_test_case(TestCase):
     29
     30    def setUp(self):
     31        if not default_test_sound:
     32            skipTest(no_sounds_msg)
     33
     34    def test_close_file(self):
    3035        samplerate = 0 # use native samplerate
    3136        hop_size = 256
    32         f = source(filename, samplerate, hop_size)
    33         f.close()
    34 
    35     @parametrize('filename', list_of_sounds)
    36     def test_close_file_twice(self, filename):
     37        f = source(default_test_sound, samplerate, hop_size)
     38        f.close()
     39
     40    def test_close_file_twice(self):
    3741        samplerate = 0 # use native samplerate
    3842        hop_size = 256
    39         f = source(filename, samplerate, hop_size)
    40         f.close()
    41         f.close()
     43        f = source(default_test_sound, samplerate, hop_size)
     44        f.close()
     45        f.close()
     46
     47    def test_read_after_close(self):
     48        samplerate = 0 # use native samplerate
     49        hop_size = 256
     50        f = source(default_test_sound, samplerate, hop_size)
     51        read, frames = f()
     52        f.close()
     53        with assert_raises(RuntimeError):
     54            read, frames = f()
     55        with assert_raises(RuntimeError):
     56            read, frames = f.do_multi()
     57
    4258
    4359class Test_aubio_source_read(object):
     
    6177    @parametrize('hop_size, samplerate, soundfile', all_params)
    6278    def test_samplerate_hopsize(self, hop_size, samplerate, soundfile):
     79        orig_samplerate = parse_file_samplerate(soundfile)
    6380        try:
    64             f = source(soundfile, samplerate, hop_size)
     81            if orig_samplerate is not None and orig_samplerate < samplerate:
     82                # upsampling should emit a warning
     83                with assert_warns(UserWarning):
     84                    f = source(soundfile, samplerate, hop_size)
     85            else:
     86                f = source(soundfile, samplerate, hop_size)
    6587        except RuntimeError as e:
    6688            err_msg = 'failed opening with hop_s={:d}, samplerate={:d} ({:s})'
Note: See TracChangeset for help on using the changeset viewer.