From: Paul Brossier Date: Sun, 4 Nov 2018 19:58:16 +0000 (+0100) Subject: [py] improve style for demo_source_simple.py X-Git-Tag: 0.4.8~77 X-Git-Url: https://git.aubio.org/?a=commitdiff_plain;h=254accea9c7fa74f1af3b2cc6675075ea2e56098;p=aubio.git [py] improve style for demo_source_simple.py --- diff --git a/python/demos/demo_source_simple.py b/python/demos/demo_source_simple.py index bdf03267..f0577f8c 100755 --- a/python/demos/demo_source_simple.py +++ b/python/demos/demo_source_simple.py @@ -1,16 +1,20 @@ #! /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 +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: break # end of file reached + 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)) +print(fmt_string.format(total_frames, src.samplerate, src.uri))