Mercurial > hg > silvet
comparison mirex2012-matlab/computeCQT.m @ 2:8017dd4a650d
Add MIREX 2012 code
author | Chris Cannam |
---|---|
date | Wed, 19 Mar 2014 09:09:23 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
1:662b0a8b17b9 | 2:8017dd4a650d |
---|---|
1 function [intCQT] = computeCQT(filename) | |
2 % Settings for computing CQT for music signals (by E. Benetos) | |
3 | |
4 % Load .wav file | |
5 [x fs bits] = wavread(filename); | |
6 if (size(x,2) == 2) y = mean(x')'; clear('x'); else y=x; clear('x'); end; | |
7 if (fs ~= 44100) y = resample(y,44100,fs); end; | |
8 y = 0.5*y/max(y); | |
9 fs = 44100; | |
10 | |
11 | |
12 % Compute CQT | |
13 Xcqt = cqt(y,27.5,fs/3,60,fs,'q',0.80,'atomHopFactor',0.3,'thresh',0.0005,'win','hann'); | |
14 %Xcqt = cqt(y,27.5,fs/3,120,fs,'q',0.35,'atomHopFactor',0.3,'thresh',0.0005,'win','hann'); % old resolution | |
15 absCQT = getCQT(Xcqt,'all','all'); | |
16 | |
17 % Crop CQT to useful time regions | |
18 emptyHops = Xcqt.intParams.firstcenter/Xcqt.intParams.atomHOP; | |
19 maxDrop = emptyHops*2^(Xcqt.octaveNr-1)-emptyHops; | |
20 droppedSamples = (maxDrop-1)*Xcqt.intParams.atomHOP + Xcqt.intParams.firstcenter; | |
21 outputTimeVec = (1:size(absCQT,2))*Xcqt.intParams.atomHOP-Xcqt.intParams.preZeros+droppedSamples; | |
22 | |
23 lowerLim = find(outputTimeVec>0,1); | |
24 upperLim = find(outputTimeVec>length(y),1)-1; | |
25 | |
26 %intCQT = absCQT(112:1200,lowerLim:upperLim); % old resolution | |
27 intCQT = absCQT(56:600,lowerLim:upperLim); | |
28 | |
29 | |
30 %figure; imagesc(imrotate(abs(intCQT),90)); |