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: function nap=gen_hcl(bmm,options) tomwalters@0: tomwalters@0: waithand=waitbar(0,'generating NAP'); tomwalters@0: tomwalters@0: compression=options.compression; tomwalters@0: switch compression tomwalters@0: case 'sqrt' tomwalters@0: nap=halfwayrectify(bmm); tomwalters@0: nap=sqrt(nap); tomwalters@0: case 'log' tomwalters@0: nap=logcompress(bmm,options); tomwalters@0: end tomwalters@0: %save bmm.mat bmm; tomwalters@0: %save nap.mat nap; 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: