Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -4,25 +4,26 @@ import sys · 3 unmodified lines | |||
| 4 | from aubio import source, sink | 4 | from aubio import source, sink |
| 5 | 5 | ||
| 6 | if __name__ == '__main__': | 6 | if __name__ == '__main__': |
| 7 | if len(sys.argv) < 3: | 7 | if len(sys.argv) < 3: |
| 8 | print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0] | 8 | print 'usage: %s <inputfile> <outputfile> [samplerate] [hop_size]' % sys.argv[0] |
| 9 | sys.exit(1) | 9 | sys.exit(1) |
| 10 | 10 | ||
| 11 | if len(sys.argv) > 3: samplerate = int(sys.argv[3]) | 11 | if len(sys.argv) > 3: samplerate = int(sys.argv[3]) |
| 12 | else: samplerate = 0 | 12 | else: samplerate = 0 |
| 13 | if len(sys.argv) > 4: hop_size = int(sys.argv[4]) | 13 | if len(sys.argv) > 4: hop_size = int(sys.argv[4]) |
| 14 | else: hop_size = 256 | 14 | else: hop_size = 256 |
| 15 | 15 | ||
| 16 | f = source(sys.argv[1], samplerate, hop_size) | 16 | f = source(sys.argv[1], samplerate, hop_size) |
| 17 | if samplerate == 0: samplerate = f.samplerate | 17 | if samplerate == 0: samplerate = f.samplerate |
| 18 | g = sink(sys.argv[2], samplerate) | 18 | g = sink(sys.argv[2], samplerate) |
| 19 | 19 | ||
| 20 | total_frames, read = 0, hop_size | 20 | total_frames, read = 0, hop_size |
| 21 | while read: | 21 | while read: |
| 22 | vec, read = f() | 22 | vec, read = f() |
| 23 | g(vec, read) | 23 | g(vec, read) |
| 24 | total_frames += read | 24 | total_frames += read |
| 25 | print "wrote", "%.2fs" % (total_frames / float(samplerate) ), | 25 | print "wrote", "%.2fs" % (total_frames / float(samplerate) ), |
| 26 | print "(", total_frames, "frames", "in", total_frames % hop_size, "blocks", "at", "%dHz" % samplerate, ")", | 26 | print "(", total_frames, "frames", "in", |
| 27 | print "from", f.uri, | 27 | print total_frames / f.hop_size, "blocks", "at", "%dHz" % f.samplerate, ")", |
| 28 | print "to", g.uri | 28 | print "from", f.uri, |
| 29 | print "to", g.uri | ||