-
Notifications
You must be signed in to change notification settings - Fork 0
/
get_onsets_madmom.py
26 lines (19 loc) · 978 Bytes
/
get_onsets_madmom.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import numpy as np
import madmom
from madmom.audio.filters import LogarithmicFilterbank
#This script implements a method for using the madmom onset detection functions
#The method parameter can be "madmom_cnn" or "superflux"
def get_onsets_madmom(audio_file, method='madmom_cnn'):
if method == 'superflux':
sodf = madmom.features.onsets.SpectralOnsetProcessor(onset_method='superflux', fps=200,
filterbank=LogarithmicFilterbank,
num_bands=24, log=np.log10)
act = sodf(audio_file)
proc = madmom.features.onsets.OnsetPeakPickingProcessor(fps=200)
elif method == 'madmom_cnn' or method == None:
proc = madmom.features.onsets.OnsetPeakPickingProcessor(fps=100)
act = madmom.features.onsets.CNNOnsetProcessor()(audio_file)
else:
print('\nThe method name entered for `get_onsets_madmom()` is not valid.')
exit()
return proc(act)