comparison aim-mat/modules/usermodule/pitchstrength/genpitchstrength.m @ 4:537f939baef0 tip

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