Changeset 060a3135 for python


Ignore:
Timestamp:
Feb 23, 2014, 9:39:43 PM (11 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
2a49114
Parents:
1a121ca
Message:

python/tests/test_sink.py: add read_write_multi

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/tests/test_sink.py

    r1a121ca r060a3135  
    7878                del_tmp_sink_path(sink_path)
    7979
     80    def test_read_and_write_multi(self):
     81
     82        if not len(list_of_sounds):
     83            self.skipTest('add some sound files in \'python/tests/sounds\'')
     84
     85        for path in list_of_sounds:
     86            for samplerate, hop_size in zip([0, 44100, 8000, 32000], [512, 1024, 64, 256]):
     87                f = source(path, samplerate, hop_size)
     88                if samplerate == 0: samplerate = f.samplerate
     89                sink_path = get_tmp_sink_path()
     90                g = sink(sink_path, samplerate, channels = f.channels)
     91                total_frames = 0
     92                while True:
     93                    vec, read = f.do_multi()
     94                    g.do_multi(vec, read)
     95                    total_frames += read
     96                    if read < f.hop_size: break
     97                if 0:
     98                    print "read", "%.2fs" % (total_frames / float(f.samplerate) ),
     99                    print "(", total_frames, "frames", "in",
     100                    print f.channels, "channels", "in",
     101                    print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")",
     102                    print "from", f.uri,
     103                    print "to", g.uri,
     104                    print "in", g.channels, "channels"
     105                del_tmp_sink_path(sink_path)
     106
    80107    def test_close_file(self):
    81108        samplerate = 44100
Note: See TracChangeset for help on using the changeset viewer.