History

python/lib/aubio/cmd.py: check we found a few beats

Paul Brossier committed 9 years ago

Commit 62a94b71 parent 86026a01 file · +10 −3Browse files

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

Unified · Split

python/lib/aubio/cmd.py+10−3
@@ -272,9 +272,16 @@ class process_tempo(process_beat): · 271 unmodified lines
272272 self.beat_locations.append(self.tempo.get_last_s())
273273 def flush(self, frames_read, samplerate):
274274 import numpy as np
275− bpms = 60./ np.diff(self.beat_locations)
276− median_bpm = np.mean(bpms)
277− sys.stdout.write('%.2f bpm' % median_bpm + '\n')
275+ if len(self.beat_locations) < 2:
276+ outstr = "unknown bpm"
277+ else:
278+ bpms = 60./ np.diff(self.beat_locations)
279+ median_bpm = np.mean(bpms)
280+ if len(self.beat_locations) < 10:
281+ outstr = "%.2f bpm (uncertain)" % median_bpm
282+ else:
283+ outstr = "%.2f bpm" % median_bpm
284+ sys.stdout.write(outstr + '\n')
278285
279286 class process_notes(default_process):
280287 valid_opts = ['method', 'hop_size', 'buf_size', 'samplerate']

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