

function [] = cepsdemo()
clear; close all;

wav_file='wavs/Voice.wav';
[x, fs, nbits] = wavread(wav_file);
%Narrowband spectrogram
T=0.020;
N=T*fs;
Lfft=512;
overlap=round(.95*N);

subplot(411)
specgram(x,Lfft,fs,hamming(N), overlap);
zz=specgram(x,Lfft,fs,hamming(N), overlap);
size(zz)
%spectrogram(x,hamming(N),overlap,Lfft,fs,'yaxis')
title(sprintf('Narrowband Spectrogram overlap=%i timepts=%i',overlap,size(zz,2)));



subplot(412)
spectral_centroid=zeros(1,size(zz,2));
for f=1:size(zz,2)
  frame=zz(:,f);
  spectral_centroid(f)=sum([1:size(frame)].*abs(frame'));
end
ax=linspace(0,length(x)/fs,length(spectral_centroid));
plot(ax,spectral_centroid);
xlabel('spectral centroid')
axis([0,max(ax),0,max(spectral_centroid)])


subplot(413)
spectral_flux=zeros(1,size(zz,2));
for f=2:size(zz,2)
  frame=zz(:,f);
  pframe=zz(:,f-1);
  l2norm=sqrt(sum((abs(frame)-abs(pframe)).^2));
  spectral_flux(f)=l2norm;
end
plot(ax,spectral_flux);
xlabel('spectral flux')
axis([0,max(ax),0,max(spectral_flux)])




subplot(414)
zero_crossing_rate=zeros(1,size(zz,2));

st=1;
step=floor(length(x)/size(zz,2));

for f=1:size(zz,2)
  zero_crossing_rate(f)=zcr(x(st:st+step));
  st=st+step;
end
plot(ax,zero_crossing_rate);
xlabel('zero crossing rate')
axis([0,max(ax),0,max(zero_crossing_rate)])
