annotate _beattracker/refineperiod.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 = refineperiod(period,acf,timesig);
matthiasm@8 2
matthiasm@8 3
matthiasm@8 4 if ~timesig, timesig=4; end
matthiasm@8 5
matthiasm@8 6 % peaks = zeros(1,timesig);
matthiasm@8 7 % ind = period;
matthiasm@8 8 % for i=1:timesig
matthiasm@8 9 % segment = acf(ind*i-(i-1):ind*i+(i-1));
matthiasm@8 10 % [val,loc] = max(segment);
matthiasm@8 11 % peaks(i) = loc + ind*i-(i-1)-1;
matthiasm@8 12 % end
matthiasm@8 13 %
matthiasm@8 14 %
matthiasm@8 15 % for i=1:timesig
matthiasm@8 16 % peaks(i) = (peaks(i)-1)/i;
matthiasm@8 17 % end
matthiasm@8 18 %
matthiasm@8 19 % period = mean(peaks);
matthiasm@8 20 %
matthiasm@8 21 %
matthiasm@8 22
matthiasm@8 23
matthiasm@8 24
matthiasm@8 25
matthiasm@8 26
matthiasm@8 27 %
matthiasm@8 28 %
matthiasm@8 29 if ~timesig
matthiasm@8 30 timesig =4;
matthiasm@8 31 end
matthiasm@8 32
matthiasm@8 33 ind = period;
matthiasm@8 34
matthiasm@8 35 if (timesig==4)
matthiasm@8 36 peak = zeros(1,4);
matthiasm@8 37
matthiasm@8 38 peak(1) = ind;
matthiasm@8 39
matthiasm@8 40 [val2,ind2] = max(acf(2*ind-1:2*ind+1));
matthiasm@8 41 peak(2) = ind2 + 2*ind-2;
matthiasm@8 42
matthiasm@8 43 [val3,ind3] = max(acf(3*ind-2:3*ind+2));
matthiasm@8 44 peak(3) = ind3 + 3*ind-4;
matthiasm@8 45
matthiasm@8 46 [val4,ind4] = max(acf(4*ind-3:4*ind+3));
matthiasm@8 47 peak(4) = ind4 + 4*ind-9;
matthiasm@8 48
matthiasm@8 49 period = mean([ peak(1) peak(2)/2 peak(3)/3 peak(4)/4 ]);
matthiasm@8 50
matthiasm@8 51 else
matthiasm@8 52
matthiasm@8 53 peak = zeros(1,3);
matthiasm@8 54
matthiasm@8 55 peak(1) = ind;
matthiasm@8 56
matthiasm@8 57 [val2,ind2] = max(acf(2*ind-1:2*ind+1));
matthiasm@8 58 peak(2) = ind2 +2*ind-2;
matthiasm@8 59
matthiasm@8 60 [val3,ind3] = max(acf(3*ind-2:3*ind+2));
matthiasm@8 61 peak(3) = ind3 + 3*ind-4;
matthiasm@8 62
matthiasm@8 63 period = mean([ peak(1) peak(2)/2 peak(3)/3 ]);
matthiasm@8 64
matthiasm@8 65 end