Showing the changes to python (1 of 1 file). Show all
Unified · Split
| @@ -1,16 +1,20 @@ | |||
| 1 | #! /usr/bin/env python | 1 | #! /usr/bin/env python |
| 2 | |||
| 3 | """A simple example using aubio.source.""" | ||
| 4 | |||
| 2 | import sys | 5 | import sys |
| 3 | import aubio | 6 | import aubio |
| 4 | 7 | ||
| 5 | samplerate = 0 # use original source samplerate | 8 | samplerate = 0 # use original source samplerate |
| 6 | hop_size = 256 # number of frames to read in one block | 9 | hop_size = 256 # number of frames to read in one block |
| 7 | src = aubio.source(sys.argv[1], samplerate, hop_size) | 10 | src = aubio.source(sys.argv[1], samplerate, hop_size) |
| 8 | total_frames = 0 | 11 | total_frames = 0 |
| 9 | 12 | ||
| 10 | while True: | 13 | while True: |
| 11 | samples, read = src() # read hop_size new samples from source | 14 | samples, read = src() # read hop_size new samples from source |
| 12 | total_frames += read # increment total number of frames | 15 | total_frames += read # increment total number of frames |
| 13 | if read < hop_size: break # end of file reached | 16 | if read < hop_size: # end of file reached |
| 17 | break | ||
| 14 | 18 | ||
| 15 | fmt_string = "read {:d} frames at {:d}Hz from {:s}" | 19 | fmt_string = "read {:d} frames at {:d}Hz from {:s}" |
| 16 | print (fmt_string.format(total_frames, src.samplerate, src.uri)) | 20 | print(fmt_string.format(total_frames, src.samplerate, src.uri)) |