From 060a3135918e8f1d7739ff5f1c82986c0fce7911 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Sun, 23 Feb 2014 17:39:43 -0300 Subject: [PATCH] python/tests/test_sink.py: add read_write_multi --- python/tests/test_sink.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/python/tests/test_sink.py b/python/tests/test_sink.py index 44a12fb1..54749d8e 100755 --- a/python/tests/test_sink.py +++ b/python/tests/test_sink.py @@ -77,6 +77,33 @@ class aubio_sink_test_case(TestCase): print "to", g.uri del_tmp_sink_path(sink_path) + 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) ), + print "(", total_frames, "frames", "in", + print f.channels, "channels", "in", + print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")", + print "from", f.uri, + print "to", g.uri, + print "in", g.channels, "channels" + del_tmp_sink_path(sink_path) + def test_close_file(self): samplerate = 44100 sink_path = get_tmp_sink_path() -- 2.11.0