In [2]:
from bregman.suite import *
import glob
In [4]:
# Load a 60s segment of electroacoustic music (Bernard Parmeggiani)
x,sr,fmt=wavread('IncidencesRésonances.wav')
print x.shape[0]/(44100.), 'secs'
play(x)
In [5]:
F = LogFrequencySpectrum(x,nfft=4096,wfft=4096,nhop=2048)
F.feature_plot(dbscale=1)
In [30]:
help(F.separate)
In [35]:
# Use 2D Shift-invariant PLCA, 4 components, window with 7 shifts and 10 frames
F.separate(plca.SIPLCA2, n=1, win=(12,20))
F.normalize_components()
W, Z, H, Xhat = F.w, F.z, F.h, F.X_hat
In [36]:
print "shapes of components W,Z,H: ", W.shape, Z.shape, H.shape
print " reconstruction / original: ", Xhat[0].shape, F.X.shape
In [37]:
for k in range(len(Z)):
fig,axes = subplots(1, 2, figsize=(12.75,4))
im=axes[0].imshow(20*log10(clip(W[:,k,:],0.0001,1)/W[:,k,:].max()),aspect='auto',origin='bottom',cmap=cm.jet)
axes[0].set_title('Spectro-Temporal Basis Function')
colorbar(im,ax=axes[0])
im=axes[1].imshow(20*log10(clip(H[k],0.000001,1)/H[k].max()), aspect='auto',origin='bottom',cmap=cm.jet)
#feature_plot(sin(U),cmap=cm.hot,nofig=1)
axes[1].set_title('Time-Frequency Shift Matrix')
colorbar(im,ax=axes[1])
fig.subplots_adjust(wspace=0.1)
In [38]:
for k in range(len(Xhat)):
#subplot(ceil(len(Xhat)/3.),3,k+1)
feature_plot(Xhat[k], dbscale=1, normalize=1)
x_hat = F.inverse(Xhat[k])
play(balance_signal(x_hat))
In [13]:
F.play_components()
In [23]:
Out[23]:
In [ ]: