To check out this repository please hg clone the following URL, or open the URL using EasyMercurial or your preferred Mercurial client.

Statistics Download as Zip
| Branch: | Revision:

root / _beattracker / getalignment2.m @ 8:b5b38998ef3b

History | View | Annotate | Download (1.33 KB)

1
function [alignment] = getalignment2(dfframe,phwv,period,timesig)
2

    
3

    
4
period = round(period);
5

    
6

    
7

    
8
%normalise and linearly weight most recent strongest
9
%dfframe = dfframe.*([1:length(dfframe)]);
10

    
11
% reverse 
12
dfframe = dfframe(end:-1:1); 
13

    
14
% output of alignment comb filter
15
phcf = zeros(1,period);
16

    
17
numelem = floor((length(dfframe)-0)/period);
18

    
19
%dfframe = [dfframe' zeros(1,length(dfframe))]';
20
%this line is neeeded for using commented part below
21

    
22
if (~timesig) % initial state
23

    
24
   
25

    
26
    % fit as many as possible
27
    for i=1:period
28
        for b = 1:numelem, 
29
                phcf(i) = phcf(i) + dfframe(( b-1)*period+i) * phwv(i); %+ ...
30
%  			dfframe(( b-1)*period+i+1) * phwv(i) + ...
31
%    				dfframe(( b-1)*period+i+2) * phwv(i);% + ...
32
%    				dfframe(( b-1)*period+i+3) * phwv(i) + ...
33
%  				dfframe(( b-1)*period+i+4) * phwv(i);
34
         end
35
    end
36

    
37
else
38

    
39
    numelem = timesig; 
40
    for i=1:period
41
        for b = 1:numelem, 
42
         %   for a = 1-b:b-1
43
            phcf(i) = phcf(i) + dfframe(( b-1)*period+i) * phwv(i) + ...
44
			dfframe(( b-1)*period+i+1) * phwv(i) + ...
45
				dfframe(( b-1)*period+i+2) * phwv(i) + ...
46
				dfframe(( b-1)*period+i+3) * phwv(i) + ...
47
				dfframe(( b-1)*period+i+4) * phwv(i);
48
          %  end
49
        end
50
    end
51

    
52
end
53

    
54

    
55
[val,alignment] = max(phcf);
56
[val2,bestguess] = max(phwv);
57

    
58
if alignment>=2,
59
alignment = alignment-1;
60
end