annotate getCQT.m @ 1:3ea8ed09af0f tip

additional clarifications
author Dimitrios Giannoulis
date Wed, 13 Mar 2013 11:57:24 +0000
parents 22b10c5b72e8
children
rev   line source
Dimitrios@0 1 function intCQT = getCQT(Xcqt,fSlice,tSlice,iFlag)
Dimitrios@0 2 %outCQ = getCQT(Xcqt,fSlice,tSlice,iFlag) computes a rasterized representation of
Dimitrios@0 3 %the amplitudes of the calculated CQT coefficients for the frequency bins definded in vector fSlice and the
Dimitrios@0 4 %points in time (time frames) defined in vector tSlice using the interpolation method defined in iFlag.
Dimitrios@0 5 %Valid values for iFlag are:
Dimitrios@0 6 %
Dimitrios@0 7 %'linear' ... linear interpolation (default)
Dimitrios@0 8 %'spline' ... spline interpolation
Dimitrios@0 9 %'nearest' ... nearest neighbor interpolation
Dimitrios@0 10 %'cubic' ... piecewise cubic interpolation
Dimitrios@0 11 %
Dimitrios@0 12 %If the entire CQT representation should be rasterized, set fSlice and
Dimitrios@0 13 %tSlice to 'all'.
Dimitrios@0 14 %The input parameter Xcqt is the structure gained using cqt(...).
Dimitrios@0 15 %The output parameter 'intCQT' is the same size as Xcqt.spCQT but is no
Dimitrios@0 16 %longer sparse since the zeros between two coefficients are replaced by
Dimitrios@0 17 %the interpolated values. The coefficients stored in 'intCQT' are now
Dimitrios@0 18 %real-valued since only the absolute values of the coefficients are
Dimitrios@0 19 %interpolated. If a spectrogram-like (rasterized) version of the CQT
Dimitrios@0 20 %coefficients including phase information is required, use the function
Dimitrios@0 21 %cqtPerfectRast() (see documentation for further information)
Dimitrios@0 22 %
Dimitrios@0 23 %Christian Schörkhuber, Anssi Klapuri 2010-06
Dimitrios@0 24
Dimitrios@0 25
Dimitrios@0 26 if ischar(fSlice), fSlice = 1:(Xcqt.bins*Xcqt.octaveNr); end;
Dimitrios@0 27 if ischar(tSlice)
Dimitrios@0 28 lastEnt = find(Xcqt.spCQT(1,:),1,'last');
Dimitrios@0 29 tSlice = 1:lastEnt;
Dimitrios@0 30 end
Dimitrios@0 31 if nargin < 4, iFlag = 'linear'; end;
Dimitrios@0 32
Dimitrios@0 33 intCQT = zeros(length(fSlice),length(tSlice));
Dimitrios@0 34 bins = Xcqt.bins;
Dimitrios@0 35 spCQT = Xcqt.spCQT;
Dimitrios@0 36 octaveNr = Xcqt.octaveNr;
Dimitrios@0 37 spCQT = spCQT.';
Dimitrios@0 38
Dimitrios@0 39 for k=1:length(fSlice)
Dimitrios@0 40 oct = octaveNr-floor((fSlice(k)-0.1)/bins);
Dimitrios@0 41 stepVec = 1:2^(oct-1):size(spCQT,1);
Dimitrios@0 42 Xbin = full(spCQT(stepVec,fSlice(k)));
Dimitrios@0 43 intCQT(k,:) = interp1(stepVec,abs(Xbin),tSlice,iFlag);
Dimitrios@0 44 end
Dimitrios@0 45
Dimitrios@0 46
Dimitrios@0 47