view lotplot.m @ 13:4b356e8b673f

Added contents file
author danieleb@code.soundsoftware.ac.uk
date Tue, 21 Jun 2011 14:33:02 +0100
parents df83493c1669
children 2e42f5fb764d
line wrap: on
line source
function varargout = lotplot(y,wLength,Fs)
% LOTPLOT plot of the lapped orthogonal transform
%
% varargout = lappedorthoplot(y,wLength,timeVec)
%
% plots a spectrogram-like visualisation of the lapped orthogonal
% transform coefficients contained in y
%
% INPUT:
% - y: vector containing the lapped orthogonal transform coefficients
% - wLength: vector containing the lengths of the overlapping windows
% - Fs: (optional, default=44100) sampling frequency
%
% OUTPUT:
% - varargout{1}: optionally, the function outputs the matrix containing 
% the spectrogram-like representation.
%
% SEE ALSO
% lot, ilot
%

if ~exist('Fs','var') || isempty(Fs), Fs = 44100; end
if isscalar(wLength) %create vector of fixed window lengths
    nWindows = floor(length(y)/wLength);
    wLength = wLength*ones(nWindows,1);
end

nWindows = length(wLength);
maxLength = max(wLength);
sigLength = sum(wLength);

timeVec = linspace(0,sigLength/Fs,10*ceil(sigLength/min(wLength))); 

S = zeros(maxLength,length(timeVec));
timeSupp  = @(p) floor(wLength(p)*length(timeVec)/sigLength);
interpFun = @(p,v) interp1(1:wLength(p),abs(v),linspace(1,wLength(p),maxLength))';
S(:,1:timeSupp(1)) = repmat(interpFun(1,y(1:wLength(1))),1,timeSupp(1));
for i=2:nWindows
    S(:,sum(timeSupp(1:i-1))+(1:timeSupp(i))) = ...
        repmat(interpFun(i,y(sum(wLength(1:i-1))+(1:wLength(i)))),1,timeSupp(i));
end

SmagdB = mag2db(S);
if nargout, varargout{1} = SmagdB; end

surf(timeVec,1:maxLength,SmagdB,'EdgeColor','none');
axis xy; axis tight;
colormap(jet);
view(0,90);
set(gca,'YScale','log');