In [59]:
import essentia
from essentia.streaming import *
from essentia.standard import *
%matplotlib inline
import matplotlib
In [74]:
# Essentia has a selection of audio loaders:
#
# - AudioLoader: the basic one, returns the audio samples, sampling rate and number of channels
# - MonoLoader: which returns audio, down-mixed and resampled to a given sampling rate
# - EasyLoader: a MonoLoader which can optionally trim start/end slices and rescale according
# to a ReplayGain value
# - EqloudLoader: an EasyLoader that applies an equal-loudness filtering on the audio
#
# we start by instantiating the audio loader:
loader = MonoLoader(filename = '/home/glagasse/Songs/Indila - SOS (Remix par Iulian Florea).mp4.mp3')
In [36]:
from IPython.lib.display import Audio
In [37]:
audio = loader()
sequence = audio[0:5*44100]
In [38]:
Audio(sequence, rate=44100)
Out[38]:
In [50]:
plot(sequence)
xlabel('Time (seconds)')
Out[50]:
In [79]:
w = Windowing(type = 'hann')
spectrum = Spectrum()
CD = ChordsDetection()
mfcc = MFCC()
In [75]:
frame = audio[5*44100 : 5*44100 + 1024]
spec = spectrum(w(frame))
plot(spec)
show() # unnecessary if you started "ipython --pylab"
In [82]:
mfccs = []
frameSize = 1024
hopSize = 512
for fstart in range(0, len(audio)-frameSize, hopSize):
frame = audio[fstart:fstart+frameSize]
mfcc_bands, mfcc_coeffs = mfcc(spectrum(w(frame)))
mfccs.append(mfcc_coeffs)
# and plot them...
# as this is a 2D array, we need to use imshow() instead of plot()
imshow(mfccs, aspect = 'auto')
show() # unnecessary if you started "ipython --pylab"
In [83]:
E = Energy()
In [86]:
E(w(sequence))
Out[86]:
In [87]:
BTD = BeatTrackerDegara()
In [93]:
plot(BTD(sequence))
Out[93]:
In [90]:
BHD = BpmHistogramDescriptors()
In [92]:
plot(BHD(sequence))
Out[92]:
In [ ]: