annotate mirex2012-matlab/computeCQT.m @ 116:91bb029a847a timing

Reorder the calculations to match the series of vector operations in the most recent bqvec code, just in case it's the order of vector calculations that is saving the time rather than the avoidance of std::vector
author Chris Cannam
date Wed, 07 May 2014 09:57:19 +0100
parents 8017dd4a650d
children
rev   line source
Chris@2 1 function [intCQT] = computeCQT(filename)
Chris@2 2 % Settings for computing CQT for music signals (by E. Benetos)
Chris@2 3
Chris@2 4 % Load .wav file
Chris@2 5 [x fs bits] = wavread(filename);
Chris@2 6 if (size(x,2) == 2) y = mean(x')'; clear('x'); else y=x; clear('x'); end;
Chris@2 7 if (fs ~= 44100) y = resample(y,44100,fs); end;
Chris@2 8 y = 0.5*y/max(y);
Chris@2 9 fs = 44100;
Chris@2 10
Chris@2 11
Chris@2 12 % Compute CQT
Chris@2 13 Xcqt = cqt(y,27.5,fs/3,60,fs,'q',0.80,'atomHopFactor',0.3,'thresh',0.0005,'win','hann');
Chris@2 14 %Xcqt = cqt(y,27.5,fs/3,120,fs,'q',0.35,'atomHopFactor',0.3,'thresh',0.0005,'win','hann'); % old resolution
Chris@2 15 absCQT = getCQT(Xcqt,'all','all');
Chris@2 16
Chris@2 17 % Crop CQT to useful time regions
Chris@2 18 emptyHops = Xcqt.intParams.firstcenter/Xcqt.intParams.atomHOP;
Chris@2 19 maxDrop = emptyHops*2^(Xcqt.octaveNr-1)-emptyHops;
Chris@2 20 droppedSamples = (maxDrop-1)*Xcqt.intParams.atomHOP + Xcqt.intParams.firstcenter;
Chris@2 21 outputTimeVec = (1:size(absCQT,2))*Xcqt.intParams.atomHOP-Xcqt.intParams.preZeros+droppedSamples;
Chris@2 22
Chris@2 23 lowerLim = find(outputTimeVec>0,1);
Chris@2 24 upperLim = find(outputTimeVec>length(y),1)-1;
Chris@2 25
Chris@2 26 %intCQT = absCQT(112:1200,lowerLim:upperLim); % old resolution
Chris@2 27 intCQT = absCQT(56:600,lowerLim:upperLim);
Chris@2 28
Chris@2 29
Chris@2 30 %figure; imagesc(imrotate(abs(intCQT),90));