bleeck@4
|
1 % generating function for 'aim-mat'
|
bleeck@4
|
2 %
|
bleeck@4
|
3 % INPUT VALUES:
|
bleeck@4
|
4 %
|
bleeck@4
|
5 % RETURN VALUE:
|
bleeck@4
|
6 %
|
bleeck@4
|
7 %
|
bleeck@4
|
8 % (c) 2003, University of Cambridge, Medical Research Council
|
bleeck@4
|
9 % Christoph Lindner
|
bleeck@4
|
10 % (c) 2011, University of Southampton
|
bleeck@4
|
11 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@4
|
12 % download of current version is on the soundsoftware site:
|
bleeck@4
|
13 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@4
|
14 % documentation and everything is on http://www.acousticscale.org
|
bleeck@4
|
15
|
bleeck@4
|
16
|
bleeck@4
|
17 function ps_result=genpitchstrength(sai,options)
|
bleeck@4
|
18
|
bleeck@4
|
19 nr_frames=length(sai);
|
bleeck@4
|
20
|
bleeck@4
|
21 target_frequency=options.target_frequency;
|
bleeck@4
|
22
|
bleeck@4
|
23 % if only one frequency range is important, then find out, which
|
bleeck@4
|
24 % channels are important and which not
|
bleeck@4
|
25 nr_channels=getnrchannels(sai{1});
|
bleeck@4
|
26
|
bleeck@4
|
27 % find out about scaling:
|
bleeck@4
|
28 maxval=-inf;
|
bleeck@4
|
29 maxfreval=-inf;
|
bleeck@4
|
30 maxsumval=-inf;
|
bleeck@4
|
31
|
bleeck@4
|
32 for ii=1:nr_frames
|
bleeck@4
|
33 maxval=max([maxval getmaximumvalue(sai{ii})]);
|
bleeck@4
|
34 maxsumval=max([maxsumval getscalesumme(sai{ii})]);
|
bleeck@4
|
35 maxfreval=max([maxfreval getscalefrequency(sai{ii})]);
|
bleeck@4
|
36 end
|
bleeck@4
|
37
|
bleeck@4
|
38
|
bleeck@4
|
39 for frame_number=1:nr_frames
|
bleeck@4
|
40 current_frame = sai{frame_number};
|
bleeck@4
|
41 frame_start_time(frame_number)=getcurrentframestarttime(current_frame);
|
bleeck@4
|
42 tip(frame_number)=gettimeintervalprofile(current_frame,options);
|
bleeck@4
|
43 freqp(frame_number)=getfrequencyprofile(current_frame);
|
bleeck@4
|
44
|
bleeck@4
|
45 % figure(234324)
|
bleeck@4
|
46 % clf
|
bleeck@4
|
47 % plot(tip(frame_number));
|
bleeck@4
|
48 end
|
bleeck@4
|
49 frame_duration=frame_start_time(2)-frame_start_time(1);
|
bleeck@4
|
50
|
bleeck@4
|
51 % calculate the averaged tips
|
bleeck@4
|
52 % the first frames are not average, since not long enough time has
|
bleeck@4
|
53 % passed. After that, the relevant last frames are averaged
|
bleeck@4
|
54 tip_time=options.tip_average_time;
|
bleeck@4
|
55 % time for pitch to drop to 1/2 (6dB) --in seconds
|
bleeck@4
|
56 % this means so much per frame
|
bleeck@4
|
57 ps_decay_constant=1-log(2)/(tip_time/frame_duration);
|
bleeck@4
|
58
|
bleeck@4
|
59 start_frame=1;
|
bleeck@4
|
60 histo=mute(tip(1));
|
bleeck@4
|
61 % mache ein Histogramm für jede Frequenz mit allem Maxima:
|
bleeck@4
|
62 nr_points=getnrpoints(sai{1});
|
bleeck@4
|
63
|
bleeck@4
|
64 waithand = waitbar(0,'Generating pitch strength');
|
bleeck@4
|
65
|
bleeck@4
|
66 for frame_number=start_frame:nr_frames
|
bleeck@4
|
67 % for frame_number=nr_frames:nr_frames
|
bleeck@4
|
68
|
bleeck@4
|
69 waitbar(frame_number/nr_frames, waithand);
|
bleeck@4
|
70
|
bleeck@4
|
71 current_frame = sai{frame_number};
|
bleeck@4
|
72 current_frame = setallmaxvalue(current_frame, maxval);
|
bleeck@4
|
73 current_frame = setscalesumme(current_frame, maxsumval);
|
bleeck@4
|
74 current_frame = setscalefrequency(current_frame, maxfreval);
|
bleeck@4
|
75
|
bleeck@4
|
76 interval_sig = tip(frame_number);
|
bleeck@4
|
77 % Normalisation
|
bleeck@4
|
78 interval_sig = interval_sig/nr_channels;
|
bleeck@4
|
79
|
bleeck@4
|
80 % sum the interval sum to the floating average:
|
bleeck@4
|
81 histo=histo+interval_sig;
|
bleeck@4
|
82 % dynamic decrease of all pitch strengthes
|
bleeck@4
|
83 histo=histo*ps_decay_constant;
|
bleeck@4
|
84 %
|
bleeck@4
|
85 % figure(234324)
|
bleeck@4
|
86 % clf
|
bleeck@4
|
87 % plot(histo);
|
bleeck@4
|
88
|
bleeck@4
|
89
|
bleeck@4
|
90 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
bleeck@4
|
91 % Peak Picker for IntervalProfile
|
bleeck@4
|
92 opts.ps_options=options;
|
bleeck@4
|
93 opts.current_time=getcurrentframestarttime(current_frame);
|
bleeck@4
|
94 ti_result=find_pitches(histo,opts);
|
bleeck@4
|
95 ps_result{frame_number}.ti_result=ti_result;
|
bleeck@4
|
96 ps_result{frame_number}.ti_result.ti_profile=interval_sig;
|
bleeck@4
|
97 ps_result{frame_number}.ti_result.averaged_signal=histo;
|
bleeck@4
|
98
|
bleeck@4
|
99 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
bleeck@4
|
100 % Peak Picker for FrequencyProfile
|
bleeck@4
|
101 frequency_sig=freqp(frame_number);
|
bleeck@4
|
102 % Normalisation
|
bleeck@4
|
103 frequency_sig=frequency_sig/getnrpoints(interval_sig);
|
bleeck@4
|
104
|
bleeck@4
|
105 ps_result{frame_number}.channel_center_fq = getcf(sai{frame_number});
|
bleeck@4
|
106
|
bleeck@4
|
107 % Analyse the dualprofile
|
bleeck@4
|
108 options.nap=sai{end}; % just for the frequency information
|
bleeck@4
|
109 f_result= analyse_frequency_profile(frequency_sig,options);
|
bleeck@4
|
110 ps_result{frame_number}.f_result=f_result;
|
bleeck@4
|
111
|
bleeck@4
|
112 end
|
bleeck@4
|
113
|
bleeck@4
|
114 close(waithand);
|
bleeck@4
|
115
|
bleeck@4
|
116 return
|