source: python/demos/demo_source_simple.py @ 088760e

feature/constantq
Last change on this file since 088760e was 78561f7, checked in by Paul Brossier <piem@piem.org>, 6 years ago

[doc] improve demos used in examples

  • Property mode set to 100755
File size: 540 bytes
RevLine 
[d44763f]1#! /usr/bin/env python
[78561f7]2import sys
3import aubio
[d44763f]4
[78561f7]5samplerate = 0 # use original source samplerate
[d44763f]6hop_size = 256 # number of frames to read in one block
[78561f7]7src = aubio.source(sys.argv[1], samplerate, hop_size)
[d44763f]8total_frames = 0
9
[78561f7]10while True:
11    samples, read = src()     # read hop_size new samples from source
12    total_frames += read      # increment total number of frames
[30e080c]13    if read < hop_size: break # end of file reached
[d44763f]14
15fmt_string = "read {:d} frames at {:d}Hz from {:s}"
[78561f7]16print (fmt_string.format(total_frames, src.samplerate, src.uri))
Note: See TracBrowser for help on using the repository browser.