comparison toolboxes/MIRtoolbox1.3.2/MIRToolbox/mireventdensity.m @ 0:e9a9cd732c1e tip

first hg version after svn
author wolffd
date Tue, 10 Feb 2015 15:05:51 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:e9a9cd732c1e
1 function varargout = mireventdensity(x,varargin)
2 % e = mireventdensity(x) estimate the mean frequency of events (i.e., how
3 % many note onsets per second) in the temporal data x.
4
5 % Optional arguments: Option1, Option2
6 % Tuomas Eerola, 14.08.2008
7 %
8 normal.type = 'String';
9 normal.choice = {'Option1','Option2'};
10 normal.default = 'Option1';
11 option.normal = normal;
12
13 frame.key = 'Frame';
14 frame.type = 'Integer';
15 frame.number = 2;
16 frame.default = [0 0];
17 frame.keydefault = [10 1];
18 option.frame = frame;
19
20 specif.option = option;
21
22 specif.defaultframelength = 1.00;
23 specif.defaultframehop = 0.5;
24
25 %specif.eachchunk = 'Normal';
26 specif.combinechunk = {'Average','Concat'};
27
28 varargout = mirfunction(@mireventdensity,x,varargin,nargout,specif,@init,@main);
29
30
31 function [x type] = init(x,option)
32 if not(isamir(x,'mirenvelope'))
33 if option.frame.length.val
34 x = mironsets(x,'Klapuri99', 'Frame',option.frame.length.val,...
35 option.frame.length.unit,...
36 option.frame.hop.val,...
37 option.frame.hop.unit);
38 else
39 x = mironsets(x,'Klapuri99');
40 end
41 end
42 type = 'mirscalar';
43
44
45 function e = main(o,option,postoption)
46 if iscell(o)
47 o = o{1};
48 end
49 sr = get(o,'Sampling');
50 p = mirpeaks(o); %%%%<<<<<<< MORE OPTIONS HERE
51 pv = get(p,'PeakVal');
52 v = mircompute(@algo,pv,o,option,sr);
53 e = mirscalar(o,'Data',v,'Title','Event density','Unit','per second');
54 e = {e o};
55
56
57 function e = algo(pv,o,option,sr)
58 nc = size(o,2);
59 nch = size(o,3);
60 e = zeros(1,nc,nch);
61 % for i = 1:nch
62 % for j = 1:nc
63 % if option.root
64 % e(1,j,i) = norm(d(:,j,i));
65 % else
66 % disp('do the calc...')
67 % % e(1,j,i) = d(:,j,i)'*d(:,j,i);
68 % %tmp = mironsets(d,'Filterbank',10,'Contrast',0.1); % Change by TE, was only FB=20, no other params
69 % e2 = mirpeaks(e)
70 % [o1,o2] = mirgetdata(e);
71 % e(1,j,i) = length(o2)/mirgetdata(mirlength(d));
72 % end
73 % end
74 % end
75 for i = 1:nch
76 for j = 1:nc
77 e(1,j,i) = length(pv{1,j,i});
78 if strcmpi(option.normal,'Option1')
79 e(1,j,i) = e(1,j,i) *sr/size(o,1);
80 elseif strcmpi(option.normal,'Option2')
81 pvs = pv{1};
82 high_pvs = length(find(mean(pvs)>pvs));
83 e(1,j,i) = high_pvs(1,j,i) *sr/size(o,1); % only those which are larger than mean
84 end
85 end
86 end
87
88
89
90 %function [y orig] = eachchunk(orig,option,missing,postchunk)
91 %y = mireventdensity(orig,option);
92
93
94 %function y = combinechunk(old,new)
95 %do = mirgetdata(old);
96 %dn = mirgetdata(new);
97 %y = set(old,'ChunkData',do+dn);