annotate _beattracker/getperiod.m @ 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 function [period,rcf,period2] = getperiod(acf,wv,timesig,pmax,pmin,lowest)
matthiasm@8 2
matthiasm@8 3
matthiasm@8 4 % using for loop approach to extract beat period
matthiasm@8 5
matthiasm@8 6 pmax = round(pmax);
matthiasm@8 7 pmin = round(pmin);
matthiasm@8 8
matthiasm@8 9 rcf = zeros(1,pmax);
matthiasm@8 10
matthiasm@8 11
matthiasm@8 12 if(~timesig) % timesig unknown, must be general state
matthiasm@8 13 numelem = 4;
matthiasm@8 14
matthiasm@8 15 for i=pmin:pmax-1, % maximum beat period
matthiasm@8 16 for a=1:numelem, % number of comb elements
matthiasm@8 17 for b=1-a:a-1, % gs using normalization of comb elements
matthiasm@8 18 rcf(i) = rcf(i) + (acf(a*i+b)*wv(i))/(2*a-1);
matthiasm@8 19 end
matthiasm@8 20 end
matthiasm@8 21 end
matthiasm@8 22
matthiasm@8 23 else
matthiasm@8 24 numelem = timesig; % timesig known must be context dependent state
matthiasm@8 25
matthiasm@8 26 for i=pmin:pmax-1, % maximum beat period
matthiasm@8 27 for a=1:numelem, % number of comb elements
matthiasm@8 28 for b=1-a:a-1, % cds not normalizing comb elements
matthiasm@8 29 rcf(i) = rcf(i) + acf(a*i+b)*wv(i);
matthiasm@8 30 end
matthiasm@8 31 end
matthiasm@8 32 end
matthiasm@8 33
matthiasm@8 34 end
matthiasm@8 35
matthiasm@8 36
matthiasm@8 37 [val, period] = max(rcf);
matthiasm@8 38
matthiasm@8 39
matthiasm@8 40
matthiasm@8 41
matthiasm@8 42 period = refineperiod(period,acf,timesig);
matthiasm@8 43
matthiasm@8 44
matthiasm@8 45 while(period<lowest)
matthiasm@8 46 period = period*2;
matthiasm@8 47 end
matthiasm@8 48 %period
matthiasm@8 49
matthiasm@8 50 if (~sum(abs(wv))) % i.e. using cds_wv before initialised
matthiasm@8 51 period = 0;
matthiasm@8 52 end
matthiasm@8 53
matthiasm@8 54 % not important... just here to prevent an error in the number of outputs
matthiasm@8 55 period2 = period*2;
matthiasm@8 56 %figure(1); plot(rcf); pause