feature/autosinkfeature/cnnfeature/crepefix/ffmpeg5
Last change
on this file since 3efb631 was
254acce,
checked in by Paul Brossier <piem@piem.org>, 6 years ago
|
[py] improve style for demo_source_simple.py
|
-
Property mode set to
100755
|
File size:
591 bytes
|
Rev | Line | |
---|
[d44763f] | 1 | #! /usr/bin/env python |
---|
[254acce] | 2 | |
---|
| 3 | """A simple example using aubio.source.""" |
---|
| 4 | |
---|
[78561f7] | 5 | import sys |
---|
| 6 | import aubio |
---|
[d44763f] | 7 | |
---|
[254acce] | 8 | samplerate = 0 # use original source samplerate |
---|
| 9 | hop_size = 256 # number of frames to read in one block |
---|
[78561f7] | 10 | src = aubio.source(sys.argv[1], samplerate, hop_size) |
---|
[d44763f] | 11 | total_frames = 0 |
---|
| 12 | |
---|
[78561f7] | 13 | while True: |
---|
[254acce] | 14 | samples, read = src() # read hop_size new samples from source |
---|
| 15 | total_frames += read # increment total number of frames |
---|
| 16 | if read < hop_size: # end of file reached |
---|
| 17 | break |
---|
[d44763f] | 18 | |
---|
| 19 | fmt_string = "read {:d} frames at {:d}Hz from {:s}" |
---|
[254acce] | 20 | print(fmt_string.format(total_frames, src.samplerate, src.uri)) |
---|
Note: See
TracBrowser
for help on using the repository browser.