Changeset 4d1bf0e
- Timestamp:
- Sep 14, 2017, 2:01:00 PM (7 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master
- Children:
- c4fc0f2
- Parents:
- 5db398e
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
python/demos/demo_bpm_extract.py
r5db398e r4d1bf0e 4 4 from numpy import median, diff 5 5 6 def get_file_bpm(path, params =None):6 def get_file_bpm(path, params=None): 7 7 """ Calculate the beats per minute (bpm) of a given file. 8 8 path: path to the file … … 52 52 break 53 53 54 # Convert to periods and to bpm 55 if len(beats) > 1: 56 if len(beats) < 4: 57 print("few beats found in {:s}".format(path)) 58 bpms = 60./diff(beats) 59 b = median(bpms) 60 else: 61 b = 0 62 print("not enough beats found in {:s}".format(path)) 63 return b 54 def beats_to_bpm(beats, path): 55 # if enough beats are found, convert to periods then to bpm 56 if len(beats) > 1: 57 if len(beats) < 4: 58 print("few beats found in {:s}".format(path)) 59 bpms = 60./diff(beats) 60 return median(bpms) 61 else: 62 print("not enough beats found in {:s}".format(path)) 63 return 0 64 65 return beats_to_bpm(beats, path) 64 66 65 67 if __name__ == '__main__':
Note: See TracChangeset
for help on using the changeset viewer.