bleeck@4: % generating function for 'aim-mat' bleeck@4: % bleeck@4: % INPUT VALUES: bleeck@4: % bleeck@4: % RETURN VALUE: bleeck@4: % bleeck@4: % bleeck@4: % (c) 2003, University of Cambridge, Medical Research Council bleeck@4: % Christoph Lindner bleeck@4: % (c) 2011, University of Southampton bleeck@4: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@4: % download of current version is on the soundsoftware site: bleeck@4: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@4: % documentation and everything is on http://www.acousticscale.org bleeck@4: bleeck@4: bleeck@4: function ps_result=genpitchstrength(sai,options) bleeck@4: bleeck@4: nr_frames=length(sai); bleeck@4: bleeck@4: target_frequency=options.target_frequency; bleeck@4: bleeck@4: % if only one frequency range is important, then find out, which bleeck@4: % channels are important and which not bleeck@4: nr_channels=getnrchannels(sai{1}); bleeck@4: bleeck@4: % find out about scaling: bleeck@4: maxval=-inf; bleeck@4: maxfreval=-inf; bleeck@4: maxsumval=-inf; bleeck@4: bleeck@4: for ii=1:nr_frames bleeck@4: maxval=max([maxval getmaximumvalue(sai{ii})]); bleeck@4: maxsumval=max([maxsumval getscalesumme(sai{ii})]); bleeck@4: maxfreval=max([maxfreval getscalefrequency(sai{ii})]); bleeck@4: end bleeck@4: bleeck@4: bleeck@4: for frame_number=1:nr_frames bleeck@4: current_frame = sai{frame_number}; bleeck@4: frame_start_time(frame_number)=getcurrentframestarttime(current_frame); bleeck@4: tip(frame_number)=gettimeintervalprofile(current_frame,options); bleeck@4: freqp(frame_number)=getfrequencyprofile(current_frame); bleeck@4: bleeck@4: % figure(234324) bleeck@4: % clf bleeck@4: % plot(tip(frame_number)); bleeck@4: end bleeck@4: frame_duration=frame_start_time(2)-frame_start_time(1); bleeck@4: bleeck@4: % calculate the averaged tips bleeck@4: % the first frames are not average, since not long enough time has bleeck@4: % passed. After that, the relevant last frames are averaged bleeck@4: tip_time=options.tip_average_time; bleeck@4: % time for pitch to drop to 1/2 (6dB) --in seconds bleeck@4: % this means so much per frame bleeck@4: ps_decay_constant=1-log(2)/(tip_time/frame_duration); bleeck@4: bleeck@4: start_frame=1; bleeck@4: histo=mute(tip(1)); bleeck@4: % mache ein Histogramm für jede Frequenz mit allem Maxima: bleeck@4: nr_points=getnrpoints(sai{1}); bleeck@4: bleeck@4: waithand = waitbar(0,'Generating pitch strength'); bleeck@4: bleeck@4: for frame_number=start_frame:nr_frames bleeck@4: % for frame_number=nr_frames:nr_frames bleeck@4: bleeck@4: waitbar(frame_number/nr_frames, waithand); bleeck@4: bleeck@4: current_frame = sai{frame_number}; bleeck@4: current_frame = setallmaxvalue(current_frame, maxval); bleeck@4: current_frame = setscalesumme(current_frame, maxsumval); bleeck@4: current_frame = setscalefrequency(current_frame, maxfreval); bleeck@4: bleeck@4: interval_sig = tip(frame_number); bleeck@4: % Normalisation bleeck@4: interval_sig = interval_sig/nr_channels; bleeck@4: bleeck@4: % sum the interval sum to the floating average: bleeck@4: histo=histo+interval_sig; bleeck@4: % dynamic decrease of all pitch strengthes bleeck@4: histo=histo*ps_decay_constant; bleeck@4: % bleeck@4: % figure(234324) bleeck@4: % clf bleeck@4: % plot(histo); bleeck@4: bleeck@4: bleeck@4: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bleeck@4: % Peak Picker for IntervalProfile bleeck@4: opts.ps_options=options; bleeck@4: opts.current_time=getcurrentframestarttime(current_frame); bleeck@4: ti_result=find_pitches(histo,opts); bleeck@4: ps_result{frame_number}.ti_result=ti_result; bleeck@4: ps_result{frame_number}.ti_result.ti_profile=interval_sig; bleeck@4: ps_result{frame_number}.ti_result.averaged_signal=histo; bleeck@4: bleeck@4: %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% bleeck@4: % Peak Picker for FrequencyProfile bleeck@4: frequency_sig=freqp(frame_number); bleeck@4: % Normalisation bleeck@4: frequency_sig=frequency_sig/getnrpoints(interval_sig); bleeck@4: bleeck@4: ps_result{frame_number}.channel_center_fq = getcf(sai{frame_number}); bleeck@4: bleeck@4: % Analyse the dualprofile bleeck@4: options.nap=sai{end}; % just for the frequency information bleeck@4: f_result= analyse_frequency_profile(frequency_sig,options); bleeck@4: ps_result{frame_number}.f_result=f_result; bleeck@4: bleeck@4: end bleeck@4: bleeck@4: close(waithand); bleeck@4: bleeck@4: return