annotate _misc/featureextraction/.svn/text-base/mmcq2hpcp.m.svn-base @ 9:4ea6619cb3f5 tip

removed log files
author matthiasm
date Fri, 11 Apr 2014 15:55:11 +0100
parents b5b38998ef3b
children
rev   line source
matthiasm@8 1
matthiasm@8 2
matthiasm@8 3
matthiasm@8 4
matthiasm@8 5 % CQ2HPCP Convert Constant Q spectrum to a HPCP
matthiasm@8 6 %
matthiasm@8 7 % CQ2HPCP(cqframes, info)
matthiasm@8 8 %
matthiasm@8 9 % cqframes = vector or matrix constant q spectrum / spectra
matthiasm@8 10 % info = info structure containing parameters
matthiasm@8 11 %
matthiasm@8 12
matthiasm@8 13 function [hpcpframes] = mmcq2hpcp(cqframes, info)
matthiasm@8 14
matthiasm@8 15 %get cq parameters from info structure
matthiasm@8 16 num_win = info.numberframes;
matthiasm@8 17
matthiasm@8 18 cqbins = size(cqframes,1);
matthiasm@8 19
matthiasm@8 20 bpo = info.binsperoctave;
matthiasm@8 21
matthiasm@8 22 % calculate the number of octaves we have in the spectrum
matthiasm@8 23 num_oct = floor(cqbins/bpo)-1;
matthiasm@8 24
matthiasm@8 25 hpcpframes(1:num_win, 1:bpo) = 0;
matthiasm@8 26
matthiasm@8 27
matthiasm@8 28
matthiasm@8 29 % for each window calculate chromagram
matthiasm@8 30 for i = 1 : num_win
matthiasm@8 31 % add each octave of the spectrum into the chromagram
matthiasm@8 32 for oct = 0:num_oct;
matthiasm@8 33 ind = oct*bpo;
matthiasm@8 34
matthiasm@8 35 hpcpframes(i, 1:bpo) = hpcpframes(i, 1:bpo) + abs(cqframes(ind+1:ind+bpo,i))';
matthiasm@8 36
matthiasm@8 37 end;
matthiasm@8 38
matthiasm@8 39 % normalise
matthiasm@8 40 % hpcpframes(i,1:bpo) = hpcpframes(i,1:bpo)/max(hpcpframes(i,1:bpo));
matthiasm@8 41 meanc = mean(hpcpframes(i,1:bpo));
matthiasm@8 42 if meanc > 0.0000001
matthiasm@8 43 hpcpframes(i,1:bpo) = hpcpframes(i,1:bpo)/mean(hpcpframes(i,1:bpo)); %scale to be a distribution!
matthiasm@8 44 else
matthiasm@8 45 hpcpframes(i,1:bpo) = (bpo)^(-1);
matthiasm@8 46 end
matthiasm@8 47 end;
matthiasm@8 48