source: python/demos/demo_sink_multi.py @ 8bffcff

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5pitchshiftsamplertimestretchyinfft+
Last change on this file since 8bffcff was 048dd6c, checked in by Paul Brossier <piem@piem.org>, 10 years ago

python/demos/demo_sink_multi.py: add multi channel version

  • Property mode set to 100755
File size: 976 bytes
Line 
1#! /usr/bin/env python
2
3import sys
4from aubio import source, sink
5
6if __name__ == '__main__':
7    if len(sys.argv) < 3:
8        print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0]
9        sys.exit(1)
10
11    if len(sys.argv) > 3: samplerate = int(sys.argv[3])
12    else: samplerate = 0
13    if len(sys.argv) > 4: hop_size = int(sys.argv[4])
14    else: hop_size = 256
15
16    f = source(sys.argv[1], samplerate, hop_size)
17    if samplerate == 0: samplerate = f.samplerate
18    g = sink(sys.argv[2], samplerate, f.channels)
19
20    total_frames, read = 0, hop_size
21    while read:
22        vec, read = f.do_multi()
23        g.do_multi(vec, read)
24        total_frames += read
25    print "wrote", "%.2fs" % (total_frames / float(samplerate) ),
26    print "(", total_frames, "frames", "in",
27    print total_frames / f.hop_size, "blocks",
28    print "of", f.channels, "channels",
29    print "at", "%dHz" % f.samplerate, ")",
30    print "from", f.uri,
31    print "to", g.uri
Note: See TracBrowser for help on using the repository browser.