History

python/demos/demo_bpm_extract.py: add exception type, avoid {} as default argument value

Paul Brossier committed 10 years ago

Commit 494df021 parent 67e16c21 file · +4 −2Browse files

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

Unified · Split

python/demos/demo_bpm_extract.py+4−2
@@ -3,16 +3,18 @@ · 2 unmodified lines
3from aubio import source, tempo3from aubio import source, tempo
4from numpy import median, diff4from numpy import median, diff
5 5
6def get_file_bpm(path, params = {}):6def get_file_bpm(path, params = None):
7 """ Calculate the beats per minute (bpm) of a given file.7 """ Calculate the beats per minute (bpm) of a given file.
8 path: path to the file8 path: path to the file
9 param: dictionary of parameters9 param: dictionary of parameters
10 """10 """
11 if params == None:
12 params = {}
11 try:13 try:
12 win_s = params['win_s']14 win_s = params['win_s']
13 samplerate = params['samplerate']15 samplerate = params['samplerate']
14 hop_s = params['hop_s']16 hop_s = params['hop_s']
15 except:17 except KeyError:
16 """18 """
17 # super fast19 # super fast
18 samplerate, win_s, hop_s = 4000, 128, 64 20 samplerate, win_s, hop_s = 4000, 128, 64

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