annotate _beattracker/findmeter.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 [timesig,three_energy,four_energy] = findmeter_mm(acf,period,thresh);
matthiasm@8 2
matthiasm@8 3 % a simple enegy test with current period value, where energy is evaluated
matthiasm@8 4 % at small regions at double and four times the period, to be compared with
matthiasm@8 5 % energy at 3 and 6 times the beat period, to decide if the time signature
matthiasm@8 6 % of the current frame is duple or triple.
matthiasm@8 7
matthiasm@8 8 if nargin<3
matthiasm@8 9 thresh = 0;
matthiasm@8 10 %default state
matthiasm@8 11 end
matthiasm@8 12
matthiasm@8 13
matthiasm@8 14 acf = acf/sum(acf);
matthiasm@8 15
matthiasm@8 16 period = round(period);
matthiasm@8 17
matthiasm@8 18 sw= 2;
matthiasm@8 19
matthiasm@8 20
matthiasm@8 21 % % new approach - LESS GOOD than the old approach
matthiasm@8 22 %
matthiasm@8 23 % numperiods = floor(length(acf)/period);
matthiasm@8 24 % num4multiples = floor(numperiods/4);
matthiasm@8 25 % % % just check we haven't gone over the end of the acf
matthiasm@8 26 % num4multiples = num4multiples- double((period*num4multiples*4+sw) > length(acf));
matthiasm@8 27 %
matthiasm@8 28 % % initialize;
matthiasm@8 29 % three_energy = 0;
matthiasm@8 30 % four_energy = 0;
matthiasm@8 31 %
matthiasm@8 32 % for i=1:length(num4multiples)
matthiasm@8 33 %
matthiasm@8 34 % three_energy = three_energy + sum(acf(3*i*period-sw:1:3*i*period+sw));
matthiasm@8 35 % four_energy = four_energy + sum(acf(4*i*period-sw:1:4*i*period+sw));
matthiasm@8 36 %
matthiasm@8 37 % end
matthiasm@8 38
matthiasm@8 39
matthiasm@8 40 % old approach...
matthiasm@8 41
matthiasm@8 42 if(length(acf)<6*period+sw)
matthiasm@8 43
matthiasm@8 44
matthiasm@8 45 three_energy = sum(acf(3*period-sw:1:3*period+sw));
matthiasm@8 46
matthiasm@8 47 four_energy = sum(acf(4*period-sw:1:4*period+sw));
matthiasm@8 48
matthiasm@8 49 else
matthiasm@8 50
matthiasm@8 51 three_energy = sum(acf(3*period-sw:1:3*period+sw)) + sum(acf(6*period-sw:1:6*period+sw));
matthiasm@8 52
matthiasm@8 53 four_energy = sum(acf(4*period-sw:1:4*period+sw)) + sum(acf(2*period-sw:1:2*period+sw));
matthiasm@8 54
matthiasm@8 55 end
matthiasm@8 56
matthiasm@8 57
matthiasm@8 58 if ( (four_energy - three_energy) >= thresh )
matthiasm@8 59 timesig = 4;
matthiasm@8 60 else
matthiasm@8 61 timesig = 3;
matthiasm@8 62 end