tomwalters@0
|
1 % method of class @signal
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % INPUT VALUES:
|
tomwalters@0
|
4 %
|
tomwalters@0
|
5 % RETURN VALUE:
|
tomwalters@0
|
6 %
|
tomwalters@0
|
7 %
|
bleeck@3
|
8 % This external file is included as part of the 'aim-mat' distribution package
|
bleeck@3
|
9 % (c) 2011, University of Southampton
|
bleeck@3
|
10 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@3
|
11 % download of current version is on the soundsoftware site:
|
bleeck@3
|
12 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@3
|
13 % documentation and everything is on http://www.acousticscale.org
|
bleeck@3
|
14
|
tomwalters@0
|
15
|
tomwalters@0
|
16 function sources=getsourceestimate(sig,sigma)
|
tomwalters@0
|
17 % usage: sources=getsourceestimate(sig,sigma))
|
tomwalters@0
|
18 % returns a struct of sources.position and sources.height
|
tomwalters@0
|
19 % for each maximum in the signal sig.
|
tomwalters@0
|
20 % it is assumed, that each maximum contributes to the signal with
|
tomwalters@0
|
21 % a gaussian kernel of the width "sigma"
|
tomwalters@0
|
22
|
tomwalters@0
|
23
|
tomwalters@0
|
24 grafix=0; % debug
|
tomwalters@0
|
25
|
tomwalters@0
|
26 % nrchannels=getnrchannels(cframe);
|
tomwalters@0
|
27 % smoothwidth=nrchannels/64;
|
tomwalters@0
|
28 % fresumme=smooth(fresumme,smoothwidth);
|
tomwalters@0
|
29
|
tomwalters@0
|
30 finished=0; % it can be finished by:
|
tomwalters@0
|
31 % a) after 5 Maxima
|
tomwalters@0
|
32 % b) the signal is below 30 % of original
|
tomwalters@0
|
33 how_many_max_maximal=5;
|
tomwalters@0
|
34 threshold_criterion=0.3;
|
tomwalters@0
|
35
|
tomwalters@0
|
36 if nargin < 2
|
tomwalters@0
|
37 % wie breit jedes Maximum angenommen wird
|
tomwalters@0
|
38 sigma=3; % this is in the sr of the singal
|
tomwalters@0
|
39 end
|
tomwalters@0
|
40
|
tomwalters@0
|
41 current_max=1;
|
tomwalters@0
|
42 start_max_hight=max(sig); % so hoch im Moment
|
tomwalters@0
|
43
|
tomwalters@0
|
44 if grafix
|
tomwalters@0
|
45 plot(sig);
|
tomwalters@0
|
46 hold on;
|
tomwalters@0
|
47 a=axis;
|
tomwalters@0
|
48 a(3)=-start_max_hight*1.1;
|
tomwalters@0
|
49 a(4)=start_max_hight*1.1;
|
tomwalters@0
|
50 axis(a);
|
tomwalters@0
|
51 end
|
tomwalters@0
|
52
|
tomwalters@0
|
53 cols=['b';'g';'k';'y';'b';'g';'k']; % verschiedene Farben für die unterschiedlichen Dominanzregionen
|
tomwalters@0
|
54 while ~finished
|
tomwalters@0
|
55 [maxpos,minpos,maxs,mins]=getminmax(sig);
|
tomwalters@0
|
56 [maxmaxhight,maxmaxpos]=max(sig);
|
tomwalters@0
|
57
|
tomwalters@0
|
58 gauss=signal(sig);
|
tomwalters@0
|
59 gauss=generategauss(gauss,maxmaxpos,maxmaxhight,sigma);
|
tomwalters@0
|
60 sig=sig-gauss;
|
tomwalters@0
|
61
|
tomwalters@0
|
62 sources{current_max}.position=maxmaxpos;
|
tomwalters@0
|
63 sources{current_max}.height=maxmaxhight;
|
tomwalters@0
|
64 sources{current_max}.sigma=sigma;
|
tomwalters@0
|
65
|
tomwalters@0
|
66
|
tomwalters@0
|
67 if grafix
|
tomwalters@0
|
68 cur_col=cols(mod(current_max,7)+1,:);
|
tomwalters@0
|
69 plot(sig,cur_col);
|
tomwalters@0
|
70 axis(a);
|
tomwalters@0
|
71 plot(maxmaxpos,maxmaxhight,'r.','MarkerSize',20);
|
tomwalters@0
|
72 end
|
tomwalters@0
|
73 current_max_hight=max(sig); % so hoch im Moment
|
tomwalters@0
|
74 if current_max_hight <= start_max_hight*threshold_criterion
|
tomwalters@0
|
75 finished=1;
|
tomwalters@0
|
76 end
|
tomwalters@0
|
77
|
tomwalters@0
|
78
|
tomwalters@0
|
79 current_max=current_max+1;
|
tomwalters@0
|
80 if current_max>how_many_max_maximal
|
tomwalters@0
|
81 finished=1;
|
tomwalters@0
|
82 end
|
tomwalters@0
|
83
|
tomwalters@0
|
84 end
|
tomwalters@0
|
85 if grafix
|
tomwalters@0
|
86 plot(sig,'r');
|
tomwalters@0
|
87 axis(a);
|
tomwalters@0
|
88 end
|
tomwalters@0
|
89
|
tomwalters@0
|
90 return
|
tomwalters@0
|
91
|
tomwalters@0
|
92
|
tomwalters@0
|
93
|
tomwalters@0
|
94
|
tomwalters@0
|
95
|
tomwalters@0
|
96
|
tomwalters@0
|
97
|