tomwalters@0: % generating function for 'aim-mat' tomwalters@0: % tomwalters@0: % INPUT VALUES: tomwalters@0: % tomwalters@0: % RETURN VALUE: tomwalters@0: % tomwalters@0: % tomwalters@0: % (c) 2011, University of Southampton bleeck@3: % Maintained by Stefan Bleeck (bleeck@gmail.com) bleeck@3: % download of current version is on the soundsoftware site: bleeck@3: % http://code.soundsoftware.ac.uk/projects/aimmat bleeck@3: % documentation and everything is on http://www.acousticscale.org bleeck@3: tomwalters@0: tomwalters@0: tomwalters@0: function nap=gen_hl(bmm,options) tomwalters@0: tomwalters@0: waithand=waitbar(0,'generating NAP'); tomwalters@0: tomwalters@0: nap=halfwayrectify(bmm); tomwalters@0: tomwalters@0: vals=getvalues(nap); tomwalters@0: tomwalters@0: %gtfb output values are: 0< gt_vals <1 tomwalters@0: %therefore we will scale for 16bit values tomwalters@0: %operationally only 15 bits are used as we tomwalters@0: %half wave rectify tomwalters@0: tomwalters@0: % TCW AIM 2006 - 07/03/06 autoscaling now fixed tomwalters@0: %vals=vals.*2.^15; tomwalters@0: % Note: tcw Nov '05 - only re-added this part (from the log code) since otherwise it really tomwalters@0: % screws up the display code later on. See do_aim_autoscale, cases {4,5} tomwalters@0: % for why - the scaling seems a bit arbitrary to me! tomwalters@0: tomwalters@0: nap=setvalues(nap,vals); tomwalters@0: tomwalters@0: % lowpassfiltering in the end tomwalters@0: if isfield(options,'do_lowpassfiltering') % this is multiplied to the threshold_time_const tomwalters@0: do_lowpassfiltering=options.do_lowpassfiltering; tomwalters@0: else tomwalters@0: do_lowpassfiltering=1; tomwalters@0: end tomwalters@0: tomwalters@0: % cut off frequency lowpassfiltering in the end tomwalters@0: if isfield(options,'lowpass_cutoff_frequency') % this is multiplied to the threshold_time_const tomwalters@0: lowpass_cutoff_frequency=options.lowpass_cutoff_frequency; tomwalters@0: else tomwalters@0: lowpass_cutoff_frequency=1200; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: % order of the lowpassfiltering in the end tomwalters@0: if isfield(options,'lowpass_order') % this is multiplied to the threshold_time_const tomwalters@0: lowpass_order=options.lowpass_order; tomwalters@0: else tomwalters@0: lowpass_order=2; tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: nr_chan=getnrchannels(nap); tomwalters@0: if options.do_lowpassfiltering==1 tomwalters@0: for ii=1:nr_chan % through all channels: prepare working variable tomwalters@0: if mod(ii,10)==0 tomwalters@0: waitbar(ii/nr_chan); tomwalters@0: end tomwalters@0: sig=getsinglechannel(nap,ii); tomwalters@0: newsig=leakyintegrator(sig,lowpass_cutoff_frequency,lowpass_order); tomwalters@0: nap=setsinglechannel(nap,ii,newsig); tomwalters@0: end tomwalters@0: end tomwalters@0: tomwalters@0: tomwalters@0: tomwalters@0: timesum=getsum(nap); tomwalters@0: maxt=max(timesum); tomwalters@0: nap=setscalesumme(nap,maxt); tomwalters@0: %save nap1.mat nap; tomwalters@0: close(waithand); tomwalters@0: tomwalters@0: