Changeset 62a94b7 for python/lib/aubio


Ignore:
Timestamp:
Mar 24, 2017, 2:56:38 AM (8 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, sampler
Children:
2615dd9
Parents:
86026a0
Message:

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

File:
1 edited

Legend:

Unmodified
Added
Removed
  • python/lib/aubio/cmd.py

    r86026a0 r62a94b7  
    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
    279286class process_notes(default_process):
Note: See TracChangeset for help on using the changeset viewer.