Mercurial > hg > mauch-mirex-2010
diff _misc/featureextraction/.svn/text-base/mmcq2hpcp.m.svn-base @ 8:b5b38998ef3b
added all that other stuff
author | matthiasm |
---|---|
date | Fri, 11 Apr 2014 15:54:25 +0100 |
parents | |
children |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/_misc/featureextraction/.svn/text-base/mmcq2hpcp.m.svn-base Fri Apr 11 15:54:25 2014 +0100 @@ -0,0 +1,48 @@ + + + + +% CQ2HPCP Convert Constant Q spectrum to a HPCP +% +% CQ2HPCP(cqframes, info) +% +% cqframes = vector or matrix constant q spectrum / spectra +% info = info structure containing parameters +% + +function [hpcpframes] = mmcq2hpcp(cqframes, info) + +%get cq parameters from info structure +num_win = info.numberframes; + +cqbins = size(cqframes,1); + +bpo = info.binsperoctave; + +% calculate the number of octaves we have in the spectrum +num_oct = floor(cqbins/bpo)-1; + +hpcpframes(1:num_win, 1:bpo) = 0; + + + +% for each window calculate chromagram +for i = 1 : num_win + % add each octave of the spectrum into the chromagram + for oct = 0:num_oct; + ind = oct*bpo; + + hpcpframes(i, 1:bpo) = hpcpframes(i, 1:bpo) + abs(cqframes(ind+1:ind+bpo,i))'; + + end; + + % normalise +% hpcpframes(i,1:bpo) = hpcpframes(i,1:bpo)/max(hpcpframes(i,1:bpo)); + meanc = mean(hpcpframes(i,1:bpo)); + if meanc > 0.0000001 + hpcpframes(i,1:bpo) = hpcpframes(i,1:bpo)/mean(hpcpframes(i,1:bpo)); %scale to be a distribution! + else + hpcpframes(i,1:bpo) = (bpo)^(-1); + end +end; +