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