source: python/demos/demo_source_simple.py @ 8ebcd3d

feature/autosinkfeature/cnnfeature/cnn_orgfeature/constantqfeature/crepefeature/crepe_orgfeature/pitchshiftfeature/pydocstringsfeature/timestretchfix/ffmpeg5
Last change on this file since 8ebcd3d was 78561f7, checked in by Paul Brossier <piem@piem.org>, 5 years ago

[doc] improve demos used in examples

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