Changeset 254acce for python/demos
- Timestamp:
- Nov 4, 2018, 8:58:16 PM (6 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
- Children:
- eff63ab
- Parents:
- 8ebcd3d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_source_simple.py
r8ebcd3d r254acce 1 1 #! /usr/bin/env python 2 3 """A simple example using aubio.source.""" 4 2 5 import sys 3 6 import aubio 4 7 5 samplerate = 0 # use original source samplerate6 hop_size = 256 # number of frames to read in one block8 samplerate = 0 # use original source samplerate 9 hop_size = 256 # number of frames to read in one block 7 10 src = aubio.source(sys.argv[1], samplerate, hop_size) 8 11 total_frames = 0 9 12 10 13 while 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 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 14 18 15 19 fmt_string = "read {:d} frames at {:d}Hz from {:s}" 16 print 20 print(fmt_string.format(total_frames, src.samplerate, src.uri))
Note: See TracChangeset
for help on using the changeset viewer.