In [1]:
import numpy, scipy, matplotlib.pyplot as plt, pandas, librosa

Onset Detection

In [2]:
x, fs = librosa.load('simpleLoop.wav', sr=44100)
print x.shape
(132300,)

Plot the signal:

In [3]:
librosa.display.waveplot(x, fs)
Out[3]:
<matplotlib.collections.PolyCollection at 0x10ab6c150>

Listen:

In [4]:
from IPython.display import Audio
Audio(x, rate=fs)
Out[4]:

librosa.onset.onset_detect

In [5]:
onsets = librosa.onset.onset_detect(x, fs)
print onsets # frame numbers of estimated onsets
[ 44  87 109 130 174]
In [6]:
S = librosa.stft(x)
logS = librosa.logamplitude(S)
librosa.display.specshow(logS, fs, alpha=0.75, x_axis='time')
plt.vlines(onsets, 0, logS.shape[0], color='r')
Out[6]:
<matplotlib.collections.LineCollection at 0x10ab7f110>

essentia.standard.OnsetRate

In [7]:
from essentia.standard import OnsetRate
find_onsets = OnsetRate()
onset_times, onset_rate = find_onsets(x)
print onset_times
print onset_rate
[ 0.01160998  0.48761904  0.98684806  1.24226761  1.48607707]
1.66666662693

essentia.standard.AudioOnsetsMarker

In [8]:
from essentia.standard import AudioOnsetsMarker
onsets_marker = AudioOnsetsMarker(onsets=onset_times, type='beep')
x_beeps = onsets_marker(x)
Audio(x_beeps, rate=fs)
Out[8]: