%plots 15 sec wavelet chunks

%clear wavelet; mex wavelet.f

%[sig,fs,bits]=auread('waltz0-1_45.au');
%[sig,fs,bits]=auread('polly32.au');

dtime=1.0/fs;
times=dtime*(1:length(sig));

chunklen=10;

%for ii=7:floor(max(times)/chunklen)

for ii=0:0

tmin=-+ii*chunklen; tmax=tmin+chunklen+1;

%tmin=61;tmax=66;

skip=100; % how many timesteps to skip...

mstart=min(find(times >= tmin));
mend=max(find(times <= tmax));

s=sig(mstart:mend)';
t=times(mstart:mend);
dt=dtime;

f0=65.4064;
notes=0:60;
freq=f0*2.^(notes/12.0);

period=1.0./freq;

figure(1)
clf
plot(t,s)
xlabel('time(s)')
drawnow
tic
wave=wavelet(s,freq,dt,60,skip);
toc
figure(ii+3)
clf
pcolor(times(mstart:skip:mend),notes-.5,log(abs(wave(1:skip:end,:)')));shading flat
%pcolor(t(1:skip:end),ni-.5,abs(wave(1:skip:end,:)'));shading flat;
 caxis([3.5 8]);
colormap(flipud(gray));
%colormap([[1 1 1];jet]);
set(gcf,'papertype','a4');set(gcf,'paperorientation','landscape');set(gcf,'paperposition',[0.25 0.25 11.193 7.7677]);

axis([tmin tmax notes(1) notes(end)])
hold on
set(gca,'ytick',[])

ni=notes;
notes='c d ef g a b';

for i=1:length(ni)
	if (notes(mod(i-1,12)+1) ~= ' ')
		plot([tmin tmax],[ni(i) ni(i)],'k')
		text(tmin-0.03*(tmax-tmin),ni(i),notes(mod(i-1,12)+1))
	end
end

set(gca,'tickdir','out')

xlabel('Time (sec)')

%printjcmm

end %time loop



