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 / bcfm.m @ 8:b5b38998ef3b

History | View | Annotate | Download (3.05 KB)

1
function [measures,db] = bcfm(bcf,beats,timesig)
2

    
3

    
4
if timesig == 0
5
	timesig =4;
6
end
7
% extract measures from bcf and timesig.
8

    
9
for k=1:timesig,
10
    db(k) = mean(bcf(k:timesig:end));
11
end
12

    
13
[val,downbeat] = max(db);
14

    
15

    
16

    
17
if(downbeat ==timesig),
18
    downbeat = 0;
19
end
20

    
21
downbeat = downbeat+1;
22

    
23
measures = beats(downbeat:timesig:end);
24

    
25

    
26
if 0
27

    
28
    % for extracting batchwise measures...
29
    for i=1:222,
30
        meas{1,i} = bcfm(bcfs{i}.spec,anns.beats{i},anns.timesig{i});
31
        %  meas{2,i} = bcfm(bcf{i}.specs,anns.beats{i},anns.timesig{i});
32
        meas{2,i} = bcfm(bcfs{i}.cq,anns.beats{i},anns.timesig{i});
33
        %  meas{4,i} = bcfm(bcf{i}.cqs,anns.beats{i},anns.timesig{i});
34
        meas{3,i} = bcfm(bcfs{i}.hpcp,anns.beats{i},anns.timesig{i});
35
        %  meas{6,i} = bcfm(bcf{i}.hpcps,anns.beats{i},anns.timesig{i});
36
        meas{4,i} = bcfm(bcfs{i}.chroma,anns.beats{i},anns.timesig{i});
37
        %  meas{8,i} = bcfm(bcf{i}.chromas,anns.beats{i},anns.timesig{i});
38
        meas{5,i} =  bcfm(bcfs{i}.mfcc,anns.beats{i},anns.timesig{i});
39
       % y = bcfs{i}.spec+bcfs{i}.cq+bcfs{i}.hpcp+bcfs{i}.chroma+bcfs{i}.mfcc;
40
      %  meas{6,i} =  bcfm(y,anns.beats{i},anns.timesig{i});
41

    
42
%         % voting mechanism.. find which measures are the same...
43
%         zz = zeros(5);
44
%         for k=1:5, 
45
%             for j=1:5,
46
%                 zz(k,j) = double(~~sum(meas{k,i}==meas{j,i})); 
47
%             end
48
%         end
49
%         
50
%         for p=1:5, zz(p,p) = 0; end
51
%         % find which is similar to another        
52
%         [val,ind] = max(sum(zz));
53
%         % and put these in place...
54
%         meas{6,i} = meas{ind,i};
55
%         
56
        
57
    end
58
    % and their evaluation
59
    for j=1:5
60
        for i=1:222,
61
            % only need rcl
62
            [m.rcl(j,i), m.rtot(j,i), m.acl(j,i), m.atot(j,i)]  = cont_eval(anns.actmeasures{i},meas{j,i},0.1);
63
        end
64
    end
65
end
66

    
67
if 0
68

    
69
    % for extracting batchwise measures...
70
    for i=1:222,
71
        meas{1,i} = bcfm(bcf{i}.spec,beats{i},timesig{i});
72
      %  meas{2,i} = bcfm(bcf{i}.specs,anns.beats{i},anns.timesig{i});
73
        meas{2,i} = bcfm(bcf{i}.cq,beats{i},timesig{i});
74
      %  meas{4,i} = bcfm(bcf{i}.cqs,anns.beats{i},anns.timesig{i});
75
        meas{3,i} = bcfm(bcf{i}.hpcp,beats{i},timesig{i});
76
      %  meas{6,i} = bcfm(bcf{i}.hpcps,anns.beats{i},anns.timesig{i});
77
        meas{4,i} = bcfm(bcf{i}.chroma,beats{i},timesig{i});
78
      %  meas{8,i} = bcfm(bcf{i}.chromas,anns.beats{i},anns.timesig{i});
79
    end
80
    % and their evaluation
81
    for j=1:4
82
        for i=1:222,
83
            % only need rcl
84
            [m.rcl(j,i), m.rtot(j,i), m.acl(j,i), m.atot(j,i)]  = cont_eval(anns.actmeasures{i},meas{j,i},0.1);
85
        end
86
    end
87
end
88

    
89
%new classification approach
90
if 0
91
fname = '95_HipHopFatty';
92
[bcf,frame,beats] = getbcfs2(fname); y = kmeans(frame.spec,4);
93
measures = bcfm(~~abs(diff(y)),beats,4);
94
figure(1);subplot(311); imagesc(10*log(1+abs(frame.spec'))); axis xy; colormap('hot'); subplot(312); stem(y); axis tight; subplot(313); stem(~~abs(diff(y))); axis tight;
95
out = playbeats(measures,wavread(fname),44100); wavwrite(out,44100,'~/Desktop/z2.wav');
96
end