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