ref: 6e157df38d1a9acb48810660b7b8f1a9e7d87a7e
dir: /python/demos/demo_source_simple.py/
#! /usr/bin/env python
"""A simple example using aubio.source."""
import sys
import aubio
samplerate = 0  # use original source samplerate
hop_size = 256  # number of frames to read in one block
src = aubio.source(sys.argv[1], samplerate, hop_size)
total_frames = 0
while True:
    samples, read = src()  # read hop_size new samples from source
    total_frames += read   # increment total number of frames
    if read < hop_size:    # end of file reached
        break
fmt_string = "read {:d} frames at {:d}Hz from {:s}"
print(fmt_string.format(total_frames, src.samplerate, src.uri))