source: python/demos/demo_source_simple.py @ 254acce

feature/autosinkfeature/constantqfeature/pitchshiftfeature/pydocstringsfeature/timestretch
Last change on this file since 254acce was 254acce, checked in by Paul Brossier <piem@piem.org>, 21 months ago

[py] improve style for demo_source_simple.py

  • Property mode set to 100755
File size: 591 bytes
Line 
1#! /usr/bin/env python
2
3"""A simple example using aubio.source."""
4
5import sys
6import aubio
7
8samplerate = 0  # use original source samplerate
9hop_size = 256  # number of frames to read in one block
10src = aubio.source(sys.argv[1], samplerate, hop_size)
11total_frames = 0
12
13while True:
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
18
19fmt_string = "read {:d} frames at {:d}Hz from {:s}"
20print(fmt_string.format(total_frames, src.samplerate, src.uri))
Note: See TracBrowser for help on using the repository browser.