source: python/demos/demo_source_simple.py @ d44763f

feature/autosinkfeature/constantqfeature/pitchshiftfeature/pydocstringsfeature/timestretchpitchshiftsamplertimestretchyinfft+
Last change on this file since d44763f was d44763f, checked in by Paul Brossier <piem@piem.org>, 4 years ago

doc/python_module.rst: add demo_source_simple.py

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