예제 #1
0
 def test_triangle_freqs_with_double_value(self):
     """make sure set_triangle_bands works with 2 duplicate freqs"""
     samplerate = 22050
     freq_list = [0, 100, 1000, 4000, 4000, 4000, 10000]
     f = filterbank(len(freq_list)-2, 1024)
     with assert_warns(UserWarning):
         f.set_triangle_bands(fvec(freq_list), samplerate)
예제 #2
0
 def test_triangle_freqs_with_too_many_filters(self):
     """make sure set_triangle_bands warns when too many filters"""
     samplerate = 22050
     freq_list = [0, 100, 1000, 4000, 8000, 10000]
     f = filterbank(len(freq_list)-1, 1024)
     with assert_warns(UserWarning):
         f.set_triangle_bands(fvec(freq_list), samplerate)
예제 #3
0
 def test_triangle_freqs_with_large_freq(self):
     """make sure set_triangle_bands warns when freq > nyquist"""
     samplerate = 22050
     freq_list = [0, samplerate//4, samplerate // 2 + 1]
     f = filterbank(len(freq_list)-2, 1024)
     with assert_warns(UserWarning):
         f.set_triangle_bands(fvec(freq_list), samplerate)
예제 #4
0
파일: test_source.py 프로젝트: aubio/aubio
 def test_samplerate_hopsize(self, hop_size, samplerate, soundfile):
     orig_samplerate = parse_file_samplerate(soundfile)
     try:
         if orig_samplerate is not None and orig_samplerate < samplerate:
             # upsampling should emit a warning
             with assert_warns(UserWarning):
                 f = source(soundfile, samplerate, hop_size)
         else:
             f = source(soundfile, samplerate, hop_size)
     except RuntimeError as e:
         err_msg = 'failed opening with hop_s={:d}, samplerate={:d} ({:s})'
         skipTest(err_msg.format(hop_size, samplerate, str(e)))
     assert f.samplerate != 0
     read_frames = self.read_from_source(f)
     if 'f_' in soundfile and samplerate == 0:
         import re
         f = re.compile(r'.*_\([0:9]*f\)_.*')
         match_f = re.findall('([0-9]*)f_', soundfile)
         if len(match_f) == 1:
             expected_frames = int(match_f[0])
             assert_equal(expected_frames, read_frames)
예제 #5
0
 def test_samplerate_hopsize(self, hop_size, samplerate, soundfile):
     orig_samplerate = parse_file_samplerate(soundfile)
     try:
         if orig_samplerate is not None and orig_samplerate < samplerate:
             # upsampling should emit a warning
             with assert_warns(UserWarning):
                 f = source(soundfile, samplerate, hop_size)
         else:
             f = source(soundfile, samplerate, hop_size)
     except RuntimeError as e:
         err_msg = 'failed opening with hop_s={:d}, samplerate={:d} ({:s})'
         skipTest(err_msg.format(hop_size, samplerate, str(e)))
     assert f.samplerate != 0
     read_frames = self.read_from_source(f)
     if 'f_' in soundfile and samplerate == 0:
         import re
         f = re.compile(r'.*_\([0:9]*f\)_.*')
         match_f = re.findall('([0-9]*)f_', soundfile)
         if len(match_f) == 1:
             expected_frames = int(match_f[0])
             assert_equal(expected_frames, read_frames)
예제 #6
0
파일: test_sink.py 프로젝트: aubio/aubio
 def test_read_and_write_multi(self, hop_size, samplerate, path):
     orig_samplerate = parse_file_samplerate(soundfile)
     try:
         if orig_samplerate is not None and orig_samplerate < samplerate:
             # upsampling should emit a warning
             with assert_warns(UserWarning):
                 f = source(soundfile, samplerate, hop_size)
         else:
             f = source(soundfile, samplerate, hop_size)
     except RuntimeError as e:
         err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
         skipTest(err_msg.format(str(e), hop_size, samplerate))
     if samplerate == 0: samplerate = f.samplerate
     sink_path = get_tmp_sink_path()
     g = sink(sink_path, samplerate, channels = f.channels)
     total_frames = 0
     while True:
         vec, read = f.do_multi()
         g.do_multi(vec, read)
         total_frames += read
         if read < f.hop_size: break
     del_tmp_sink_path(sink_path)
예제 #7
0
 def test_read_and_write_multi(self, hop_size, samplerate, path):
     orig_samplerate = parse_file_samplerate(soundfile)
     try:
         if orig_samplerate is not None and orig_samplerate < samplerate:
             # upsampling should emit a warning
             with assert_warns(UserWarning):
                 f = source(soundfile, samplerate, hop_size)
         else:
             f = source(soundfile, samplerate, hop_size)
     except RuntimeError as e:
         err_msg = '{:s} (hop_s = {:d}, samplerate = {:d})'
         skipTest(err_msg.format(str(e), hop_size, samplerate))
     if samplerate == 0: samplerate = f.samplerate
     sink_path = get_tmp_sink_path()
     g = sink(sink_path, samplerate, channels=f.channels)
     total_frames = 0
     while True:
         vec, read = f.do_multi()
         g.do_multi(vec, read)
         total_frames += read
         if read < f.hop_size: break
     del_tmp_sink_path(sink_path)
예제 #8
0
 def test_hztomel_negative(self):
     with assert_warns(UserWarning):
         assert_equal(meltohz(-1, htk=True), 0)
     with assert_warns(UserWarning):
         assert_equal(hztomel(-1, htk=True), 0)
     assert_almost_equal(hztomel(1000, htk=True), 1000., decimal=1)
예제 #9
0
 def test_meltohz_negative(self):
     with assert_warns(UserWarning):
         assert_equal(meltohz(-1, htk=True), 0)
     assert_almost_equal(meltohz(2000, htk=True), 3428.7, decimal=1)
     assert_almost_equal(meltohz(1000, htk=True), 1000., decimal=1)
예제 #10
0
 def test_hztomel_negative(self):
     with assert_warns(UserWarning):
         assert_equal(hztomel(-1), 0)
예제 #11
0
 def test_meltohz_negative(self):
     with assert_warns(UserWarning):
         assert_equal(meltohz(-1), 0)