annotate lotplot.m @ 9:df83493c1669

more efficient implementation of DCT-I
author danieleb@code.soundsoftware.ac.uk
date Mon, 20 Jun 2011 15:26:07 +0100
parents e2a029a70df3
children 2e42f5fb764d
rev   line source
danieleb@6 1 function varargout = lotplot(y,wLength,Fs)
danieleb@6 2 % LOTPLOT plot of the lapped orthogonal transform
danieleb@0 3 %
danieleb@0 4 % varargout = lappedorthoplot(y,wLength,timeVec)
danieleb@0 5 %
danieleb@0 6 % plots a spectrogram-like visualisation of the lapped orthogonal
danieleb@0 7 % transform coefficients contained in y
danieleb@0 8 %
danieleb@0 9 % INPUT:
danieleb@0 10 % - y: vector containing the lapped orthogonal transform coefficients
danieleb@0 11 % - wLength: vector containing the lengths of the overlapping windows
danieleb@6 12 % - Fs: (optional, default=44100) sampling frequency
danieleb@0 13 %
danieleb@0 14 % OUTPUT:
danieleb@0 15 % - varargout{1}: optionally, the function outputs the matrix containing
danieleb@0 16 % the spectrogram-like representation.
danieleb@0 17 %
danieleb@0 18 % SEE ALSO
danieleb@6 19 % lot, ilot
danieleb@0 20 %
danieleb@6 21
danieleb@6 22 if ~exist('Fs','var') || isempty(Fs), Fs = 44100; end
danieleb@9 23 if isscalar(wLength) %create vector of fixed window lengths
danieleb@9 24 nWindows = floor(length(y)/wLength);
danieleb@9 25 wLength = wLength*ones(nWindows,1);
danieleb@9 26 end
danieleb@6 27
danieleb@0 28 nWindows = length(wLength);
danieleb@0 29 maxLength = max(wLength);
danieleb@0 30 sigLength = sum(wLength);
danieleb@0 31
danieleb@0 32 timeVec = linspace(0,sigLength/Fs,10*ceil(sigLength/min(wLength)));
danieleb@0 33
danieleb@0 34 S = zeros(maxLength,length(timeVec));
danieleb@0 35 timeSupp = @(p) floor(wLength(p)*length(timeVec)/sigLength);
danieleb@0 36 interpFun = @(p,v) interp1(1:wLength(p),abs(v),linspace(1,wLength(p),maxLength))';
danieleb@0 37 S(:,1:timeSupp(1)) = repmat(interpFun(1,y(1:wLength(1))),1,timeSupp(1));
danieleb@0 38 for i=2:nWindows
danieleb@0 39 S(:,sum(timeSupp(1:i-1))+(1:timeSupp(i))) = ...
danieleb@0 40 repmat(interpFun(i,y(sum(wLength(1:i-1))+(1:wLength(i)))),1,timeSupp(i));
danieleb@0 41 end
danieleb@0 42
danieleb@0 43 SmagdB = mag2db(S);
danieleb@0 44 if nargout, varargout{1} = SmagdB; end
danieleb@0 45
danieleb@0 46 surf(timeVec,1:maxLength,SmagdB,'EdgeColor','none');
danieleb@0 47 axis xy; axis tight;
danieleb@0 48 colormap(jet);
danieleb@0 49 view(0,90);
danieleb@6 50 set(gca,'YScale','log');