matthiasm@8
|
1 function out = getmeasures4(fname,ts);
|
matthiasm@8
|
2
|
matthiasm@8
|
3 if nargin<2
|
matthiasm@8
|
4 % optional argument to hand label the timesignature
|
matthiasm@8
|
5 ts = 0;
|
matthiasm@8
|
6 end
|
matthiasm@8
|
7
|
matthiasm@8
|
8 sz = wavread(fname,'size');
|
matthiasm@8
|
9
|
matthiasm@8
|
10 [x fs] = wavread(fname);
|
matthiasm@8
|
11 x = mean(x,2);
|
matthiasm@8
|
12
|
matthiasm@8
|
13 if fs~=11025,
|
matthiasm@8
|
14 x = resample(x,11025,fs);
|
matthiasm@8
|
15 end
|
matthiasm@8
|
16
|
matthiasm@8
|
17 x = x + randn(length(x),1) * 0.0000001;
|
matthiasm@8
|
18
|
matthiasm@8
|
19 df = get_dfs(x,bt_parms(0.01161*4));
|
matthiasm@8
|
20 disp 'onset detection function'
|
matthiasm@8
|
21
|
matthiasm@8
|
22 [beats,localscore,timesig] = newtt_hmm_dp(df{1});
|
matthiasm@8
|
23 disp 'beats'
|
matthiasm@8
|
24
|
matthiasm@8
|
25 % [bcf,frame] = getbcfs2(fname,beats);
|
matthiasm@8
|
26 % if~timesig, timesig = 4; end
|
matthiasm@8
|
27 %
|
matthiasm@8
|
28 % if ts
|
matthiasm@8
|
29 % measures = bcfm(bcf.spec,beats,ts);
|
matthiasm@8
|
30 % else
|
matthiasm@8
|
31 % measures = bcfm(bcf.spec,beats,timesig);
|
matthiasm@8
|
32 % end
|
matthiasm@8
|
33 reduced_fs = 86.12;
|
matthiasm@8
|
34 % x = resample(x,reduced_fs,11025);
|
matthiasm@8
|
35 % x = abs(x);
|
matthiasm@8
|
36 winlength = round(reduced_fs/10/2)*2;
|
matthiasm@8
|
37 win = gausswin(winlength);
|
matthiasm@8
|
38 earlybeats = [0 mean([beats(2:end);beats(1:end-1)])];
|
matthiasm@8
|
39
|
matthiasm@8
|
40
|
matthiasm@8
|
41
|
matthiasm@8
|
42
|
matthiasm@8
|
43 % for iBeat = 1:length(beats)
|
matthiasm@8
|
44 % beatindex = max(round(beats(iBeat)/(44100/reduced_fs)),winlength/2+1);
|
matthiasm@8
|
45 % earlybeatindex = max(round(earlybeats(iBeat)/(44100/reduced_fs)),winlength/2+1);
|
matthiasm@8
|
46 % % beatstrength = sum(x(beatindex-winlength/2+(1:winlength)) .* win);
|
matthiasm@8
|
47 % beatstrength = sum(localscore(beatindex-winlength/2+(1:winlength))' .* win);
|
matthiasm@8
|
48 % % earlybeatstrength = sum(x(earlybeatindex-winlength/2+(1:winlength))
|
matthiasm@8
|
49 % % .* win);
|
matthiasm@8
|
50 % earlybeatstrength = sum(localscore(earlybeatindex-winlength/2+(1:winlength))' .* win);
|
matthiasm@8
|
51 % if earlybeatstrength > 1.5 * beatstrength
|
matthiasm@8
|
52 % beats(iBeat) = earlybeats(iBeat);
|
matthiasm@8
|
53 % end
|
matthiasm@8
|
54 % end
|
matthiasm@8
|
55
|
matthiasm@8
|
56 out.beats = beats/44100;
|
matthiasm@8
|
57 % out.measures = measures/44100;
|
matthiasm@8
|
58 % out.timesig = timesig;
|
matthiasm@8
|
59 % out.df = df{1};
|