ref: 048dd6cd47c0759ab2fafa985c2036f0c024d24b
parent: 1ba8e601bb6be628e7fda92fda097c3fc04716e1
author: Paul Brossier <piem@piem.org>
date: Thu Jan 29 10:14:46 EST 2015
python/demos/demo_sink_multi.py: add multi channel version
--- /dev/null
+++ b/python/demos/demo_sink_multi.py
@@ -1,0 +1,31 @@
+#! /usr/bin/env python
+
+import sys
+from aubio import source, sink
+
+if __name__ == '__main__':
+ if len(sys.argv) < 3:
+ print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0]
+ sys.exit(1)
+
+ if len(sys.argv) > 3: samplerate = int(sys.argv[3])
+ else: samplerate = 0
+ if len(sys.argv) > 4: hop_size = int(sys.argv[4])
+ else: hop_size = 256
+
+ f = source(sys.argv[1], samplerate, hop_size)
+ if samplerate == 0: samplerate = f.samplerate
+ g = sink(sys.argv[2], samplerate, f.channels)
+
+ total_frames, read = 0, hop_size
+ while read:
+ vec, read = f.do_multi()
+ g.do_multi(vec, read)
+ total_frames += read
+ print "wrote", "%.2fs" % (total_frames / float(samplerate) ),
+ print "(", total_frames, "frames", "in",
+ print total_frames / f.hop_size, "blocks",
+ print "of", f.channels, "channels",
+ print "at", "%dHz" % f.samplerate, ")",
+ print "from", f.uri,
+ print "to", g.uri