import numpy, scipy, matplotlib.pyplot as plt, pandas, librosa
x, fs = librosa.load('simpleLoop.wav', sr=44100)
print x.shape
(132300,)
Plot the signal:
librosa.display.waveplot(x, fs)
<matplotlib.collections.PolyCollection at 0x10ab6c150>
Listen:
from IPython.display import Audio
Audio(x, rate=fs)
librosa.onset.onset_detect
¶onsets = librosa.onset.onset_detect(x, fs)
print onsets # frame numbers of estimated onsets
[ 44 87 109 130 174]
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')
<matplotlib.collections.LineCollection at 0x10ab7f110>
essentia.standard.OnsetRate
¶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
¶from essentia.standard import AudioOnsetsMarker
onsets_marker = AudioOnsetsMarker(onsets=onset_times, type='beep')
x_beeps = onsets_marker(x)
Audio(x_beeps, rate=fs)