Exemplo n.º 1
0
 def test_close_file_twice(self):
     samplerate = 44100
     sink_path = get_tmp_sink_path()
     g = sink(sink_path, samplerate)
     g.close()
     g.close()
     del_tmp_sink_path(sink_path)
Exemplo n.º 2
0
    def test_read_and_write_multi(self):

        if not len(list_of_sounds):
            self.skipTest('add some sound files in \'python/tests/sounds\'')

        for path in list_of_sounds:
            for samplerate, hop_size in zip([0, 44100, 8000, 32000],
                                            [512, 1024, 64, 256]):
                f = source(path, samplerate, hop_size)
                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
                if 0:
                    print("read",
                          "%.2fs" % (total_frames / float(f.samplerate)),
                          end=' ')
                    print("(", total_frames, "frames", "in", end=' ')
                    print(f.channels, "channels", "in", end=' ')
                    print(total_frames / f.hop_size,
                          "blocks",
                          "at",
                          "%dHz" % f.samplerate,
                          ")",
                          end=' ')
                    print("from", f.uri, end=' ')
                    print("to", g.uri, end=' ')
                    print("in", g.channels, "channels")
                del_tmp_sink_path(sink_path)
Exemplo n.º 3
0
 def test_close_file_twice(self):
     samplerate = 44100
     sink_path = get_tmp_sink_path()
     g = sink(sink_path, samplerate)
     g.close()
     g.close()
     del_tmp_sink_path(sink_path)
Exemplo n.º 4
0
 def test_read_and_write_multi(self, hop_size, samplerate, path):
     try:
         f = source(path, samplerate, hop_size)
     except RuntimeError as e:
         self.skipTest('failed opening with hop_s = {:d}, samplerate = {:d} ({:s})'.format(hop_size, samplerate, str(e)))
     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)
Exemplo n.º 5
0
 def test_read_and_write_multi(self, hop_size, samplerate, path):
     try:
         f = source(path, samplerate, hop_size)
     except RuntimeError as e:
         self.skipTest(
             'failed opening with hop_s = {:d}, samplerate = {:d} ({:s})'.
             format(hop_size, samplerate, str(e)))
     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)
Exemplo n.º 6
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)
Exemplo n.º 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)