feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/timestretchfix/ffmpeg5
Last change
on this file since b5de3a9 was
4120fbc,
checked in by Paul Brossier <piem@piem.org>, 9 years ago
|
python/demos: python3 and double precision compatibility
|
-
Property mode set to
100755
|
File size:
945 bytes
|
Rev | Line | |
---|
[7175ed4] | 1 | #! /usr/bin/env python |
---|
[3ff62e9] | 2 | |
---|
| 3 | import sys |
---|
| 4 | from aubio import source, sink |
---|
| 5 | |
---|
| 6 | if __name__ == '__main__': |
---|
[eadc00b] | 7 | if len(sys.argv) < 3: |
---|
[4120fbc] | 8 | print('usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0]) |
---|
[eadc00b] | 9 | sys.exit(1) |
---|
[e76eaf1] | 10 | |
---|
[eadc00b] | 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 |
---|
[e76eaf1] | 15 | |
---|
[eadc00b] | 16 | f = source(sys.argv[1], samplerate, hop_size) |
---|
| 17 | if samplerate == 0: samplerate = f.samplerate |
---|
| 18 | g = sink(sys.argv[2], samplerate) |
---|
[e76eaf1] | 19 | |
---|
[eadc00b] | 20 | total_frames, read = 0, hop_size |
---|
| 21 | while read: |
---|
| 22 | vec, read = f() |
---|
| 23 | g(vec, read) |
---|
| 24 | total_frames += read |
---|
[4120fbc] | 25 | outstr = "wrote %.2fs" % (total_frames / float(samplerate)) |
---|
| 26 | outstr += " (%d frames in" % total_frames |
---|
| 27 | outstr += " %d blocks" % (total_frames // f.hop_size) |
---|
| 28 | outstr += " at %dHz)" % f.samplerate |
---|
| 29 | outstr += " from " + f.uri |
---|
| 30 | outstr += " to " + g.uri |
---|
| 31 | print(outstr) |
---|
Note: See
TracBrowser
for help on using the repository browser.