In [1]:
%matplotlib inline
import librosa.display as disp
import numpy as np
import librosa
import librosa.core
import matplotlib.pyplot as plt
filepath = '/Users/paul/music/streams/wav/Richard Egarr, Academy of Ancient Music & Andrew Manze; Bach: Harpsichord Concertos - Triple Concerto.wav'

In [16]:
x, sr = librosa.core.load(filepath, offset=60*7 + 63 + 365, duration=500)

In [17]:
D = np.abs(librosa.stft(x, hop_length=2048))**2
plt.figure(figsize=(24, 24))
plt.subplot(3,1,1)
librosa.display.specshow(10*np.log10(D), hop_length=2048, x_axis='time', y_axis='log')
plt.title('Log-frequEncy power spectrogram')
plt.grid()
plt.subplot(3,1,2)
time = np.linspace(0,10,D.shape[1])
plt.plot(time, np.sum(D, axis=0))
plt.tight_layout()
plt.grid()
plt.xlim([0, np.max(time)])
plt.ylim([0, 1000])
plt.subplot(3,1,3)
plt.plot(np.abs(x)**2)
plt.xlim([0, len(x)])
plt.tight_layout()
plt.grid()