view _misc/featureextraction/.svn/text-base/hpcp2chroma.m.svn-base @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
line wrap: on
line source
function [chromaframes, info] = hpcp2chroma(hpcpframes, info)

% calculate the best shift 
% (0 - none, 1 - one third of semitone down, 
%  2 - two thirds of semitone down)

bps = info.binsperoctave/12;

indices = (0:11) * bps;


%%%%% NANs! $%%%%%%%%%%%%
% nanrows = isnan(sum(hpcpframes,2));
% binweights = sum(hpcpframes(~nanrows,:));
% condensedweights = zeros(bps,12);
% for iBin = 1:bps
%     condensedweights(iBin,1:12) = sum(binweights(indices+iBin)); 
% end
% % [maximum, maxind] = max(...
% %     [sum(binweights(indices+1)),...
% %      sum(binweights(indices+2)),...
% %      sum(binweights(indices+3))]);
% [maximum, maxind] = max(sum(condensedweights,2));
% shiftposs = [1 0 -1];
% shift = shiftposs(maxind);
% if bps ==3
%     hpcpframes = circshift(hpcpframes',shift)';
%     info.tuning6th = shift;
% end
maxind = 1;

% fprintf(1,['(max. energy at ' num2str(maxind) ', shift by ' num2str(shift) ')\n\n'])
if (~info.maxx)
    if bps == 3
        chromaframes = ...
            0 * hpcpframes(:,indices+1) + ...
            1 * hpcpframes(:,indices+2) + ...
            0 * hpcpframes(:,indices+3);
    elseif bps == 2
        chromaframes = ...
            (1-shift)* hpcpframes(:,indices+1) + ...
             shift* hpcpframes(:,indices+2);
    elseif bps == 1
        chromaframes = hpcpframes;
    end
else
    chromaframes = zeros(size(hpcpframes,1),12);
    for iChroma = 1:12
        chromaframes(:,iChroma) = max(hpcpframes(:,indices(iChroma)+(1:3)),[],2);
    end
end

chromaframes = chromaframes ./ repmat(sum(chromaframes,2),1,12);