ref: d5e846c4a54a78204784739e155a5317f4ecfcf1
parent: 318446885b70cec57eee0f3e78e0e4813446c8d4
author: Paul Brossier <piem@piem.org>
date: Wed Mar 6 11:56:04 EST 2013
demos/demo_beats_and_tempo.py: skip plot if not beats
--- a/python/demos/demo_beats_and_tempo.py
+++ b/python/demos/demo_beats_and_tempo.py
@@ -31,9 +31,11 @@
periods = [60./(b - a) for a,b in zip(beats[:-1],beats[1:])]
from numpy import mean, median
-print 'mean period:', mean(periods), 'bpm'
-print 'median period:', median(periods), 'bpm'
-
-from pylab import plot, show
-plot(beats[1:], periods)
-show()
+if len(periods):
+ print 'mean period:', "%.2f" % mean(periods), 'bpm', 'median', "%.2f" % median(periods), 'bpm'
+ if 0:
+ from pylab import plot, show
+ plot(beats[1:], periods)
+ show()
+else:
+ print 'mean period:', "%.2f" % 0, 'bpm', 'median', "%.2f" % 0, 'bpm'