History

[py] improve style for demo_source_simple.py

Paul Brossier committed 8 years ago

Commit 254acce1 parent 8ebcd3d1 file · +10 −6Browse files

Showing the changes to python (1 of 1 file). Show all

Unified · Split

python/demos/demo_source_simple.py+10−6
@@ -1,16 +1,20 @@
1#! /usr/bin/env python1#! /usr/bin/env python
2
3"""A simple example using aubio.source."""
4
2import sys5import sys
3import aubio6import aubio
4 7
5samplerate = 0 # use original source samplerate8samplerate = 0 # use original source samplerate
6hop_size = 256 # number of frames to read in one block9hop_size = 256 # number of frames to read in one block
7src = aubio.source(sys.argv[1], samplerate, hop_size)10src = aubio.source(sys.argv[1], samplerate, hop_size)
8total_frames = 011total_frames = 0
9 12
10while True:13while True:
11 samples, read = src() # read hop_size new samples from source14 samples, read = src() # read hop_size new samples from source
12 total_frames += read # increment total number of frames15 total_frames += read # increment total number of frames
13 if read < hop_size: break # end of file reached16 if read < hop_size: # end of file reached
17 break
14 18
15fmt_string = "read {:d} frames at {:d}Hz from {:s}"19fmt_string = "read {:d} frames at {:d}Hz from {:s}"
16print (fmt_string.format(total_frames, src.samplerate, src.uri))20print(fmt_string.format(total_frames, src.samplerate, src.uri))

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t