annotate mirex2012-matlab/getCQT.m @ 372:af71cbdab621 tip

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