matthiasm@8
|
1 function [chromaframes, info] = hpcp2chroma(hpcpframes, info)
|
matthiasm@8
|
2
|
matthiasm@8
|
3 % calculate the best shift
|
matthiasm@8
|
4 % (0 - none, 1 - one third of semitone down,
|
matthiasm@8
|
5 % 2 - two thirds of semitone down)
|
matthiasm@8
|
6
|
matthiasm@8
|
7 bps = info.binsperoctave/12;
|
matthiasm@8
|
8
|
matthiasm@8
|
9 indices = (0:11) * bps;
|
matthiasm@8
|
10
|
matthiasm@8
|
11
|
matthiasm@8
|
12 %%%%% NANs! $%%%%%%%%%%%%
|
matthiasm@8
|
13 % nanrows = isnan(sum(hpcpframes,2));
|
matthiasm@8
|
14 % binweights = sum(hpcpframes(~nanrows,:));
|
matthiasm@8
|
15 % condensedweights = zeros(bps,12);
|
matthiasm@8
|
16 % for iBin = 1:bps
|
matthiasm@8
|
17 % condensedweights(iBin,1:12) = sum(binweights(indices+iBin));
|
matthiasm@8
|
18 % end
|
matthiasm@8
|
19 % % [maximum, maxind] = max(...
|
matthiasm@8
|
20 % % [sum(binweights(indices+1)),...
|
matthiasm@8
|
21 % % sum(binweights(indices+2)),...
|
matthiasm@8
|
22 % % sum(binweights(indices+3))]);
|
matthiasm@8
|
23 % [maximum, maxind] = max(sum(condensedweights,2));
|
matthiasm@8
|
24 % shiftposs = [1 0 -1];
|
matthiasm@8
|
25 % shift = shiftposs(maxind);
|
matthiasm@8
|
26 % if bps ==3
|
matthiasm@8
|
27 % hpcpframes = circshift(hpcpframes',shift)';
|
matthiasm@8
|
28 % info.tuning6th = shift;
|
matthiasm@8
|
29 % end
|
matthiasm@8
|
30 maxind = 1;
|
matthiasm@8
|
31
|
matthiasm@8
|
32 % fprintf(1,['(max. energy at ' num2str(maxind) ', shift by ' num2str(shift) ')\n\n'])
|
matthiasm@8
|
33 if (~info.maxx)
|
matthiasm@8
|
34 if bps == 3
|
matthiasm@8
|
35 chromaframes = ...
|
matthiasm@8
|
36 0 * hpcpframes(:,indices+1) + ...
|
matthiasm@8
|
37 1 * hpcpframes(:,indices+2) + ...
|
matthiasm@8
|
38 0 * hpcpframes(:,indices+3);
|
matthiasm@8
|
39 elseif bps == 2
|
matthiasm@8
|
40 chromaframes = ...
|
matthiasm@8
|
41 (1-shift)* hpcpframes(:,indices+1) + ...
|
matthiasm@8
|
42 shift* hpcpframes(:,indices+2);
|
matthiasm@8
|
43 elseif bps == 1
|
matthiasm@8
|
44 chromaframes = hpcpframes;
|
matthiasm@8
|
45 end
|
matthiasm@8
|
46 else
|
matthiasm@8
|
47 chromaframes = zeros(size(hpcpframes,1),12);
|
matthiasm@8
|
48 for iChroma = 1:12
|
matthiasm@8
|
49 chromaframes(:,iChroma) = max(hpcpframes(:,indices(iChroma)+(1:3)),[],2);
|
matthiasm@8
|
50 end
|
matthiasm@8
|
51 end
|
matthiasm@8
|
52
|
matthiasm@8
|
53 chromaframes = chromaframes ./ repmat(sum(chromaframes,2),1,12); |