feature/crepe_org
Last change
on this file since e2010b3 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:
842 bytes
|
Rev | Line | |
---|
[7175ed4] | 1 | #! /usr/bin/env python |
---|
[b0ac9cd] | 2 | |
---|
| 3 | import sys |
---|
| 4 | from aubio import source |
---|
| 5 | |
---|
| 6 | if __name__ == '__main__': |
---|
[e253a86] | 7 | if len(sys.argv) < 2: |
---|
[4120fbc] | 8 | print('usage: %s <inputfile> [samplerate] [hop_size]' % sys.argv[0]) |
---|
[e253a86] | 9 | sys.exit(1) |
---|
| 10 | samplerate = 0 |
---|
| 11 | hop_size = 256 |
---|
| 12 | if len(sys.argv) > 2: samplerate = int(sys.argv[2]) |
---|
| 13 | if len(sys.argv) > 3: hop_size = int(sys.argv[3]) |
---|
| 14 | |
---|
| 15 | f = source(sys.argv[1], samplerate, hop_size) |
---|
| 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 |
---|
[4120fbc] | 23 | outstr = "read %.2fs" % (total_frames / float(samplerate)) |
---|
| 24 | outstr += " (%d frames in" % total_frames |
---|
| 25 | outstr += " %d blocks" % (total_frames // f.hop_size) |
---|
| 26 | outstr += " at %dHz)" % f.samplerate |
---|
| 27 | outstr += " from " + f.uri |
---|
| 28 | print(outstr) |
---|
Note: See
TracBrowser
for help on using the repository browser.