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