Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/demos/demo_source_simple.py

    re6ce204 r254acce  
    11#! /usr/bin/env python
    2 import sys, aubio
     2
     3"""A simple example using aubio.source."""
     4
     5import sys
     6import aubio
    37
    48samplerate = 0  # use original source samplerate
    5 hop_size = 256 # number of frames to read in one block
    6 s = aubio.source(sys.argv[1], samplerate, hop_size)
     9hop_size = 256  # number of frames to read in one block
     10src = aubio.source(sys.argv[1], samplerate, hop_size)
    711total_frames = 0
    812
    9 while True: # reading loop
    10     samples, read = s()
    11     total_frames += read
    12     if read < hop_size: break # end of file reached
     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
    1318
    1419fmt_string = "read {:d} frames at {:d}Hz from {:s}"
    15 print (fmt_string.format(total_frames, s.samplerate, sys.argv[1]))
    16 
     20print(fmt_string.format(total_frames, src.samplerate, src.uri))
Note: See TracChangeset for help on using the changeset viewer.