tomwalters@0
|
1 % generating function for 'aim-mat'
|
tomwalters@0
|
2 %
|
tomwalters@0
|
3 % INPUT VALUES:
|
tomwalters@0
|
4 %
|
tomwalters@0
|
5 % RETURN VALUE:
|
tomwalters@0
|
6 %
|
tomwalters@0
|
7 %
|
tomwalters@0
|
8 % (c) 2011, University of Southampton
|
bleeck@3
|
9 % Maintained by Stefan Bleeck (bleeck@gmail.com)
|
bleeck@3
|
10 % download of current version is on the soundsoftware site:
|
bleeck@3
|
11 % http://code.soundsoftware.ac.uk/projects/aimmat
|
bleeck@3
|
12 % documentation and everything is on http://www.acousticscale.org
|
bleeck@3
|
13
|
tomwalters@0
|
14
|
tomwalters@0
|
15 function nap=gen_hcl(bmm,options)
|
tomwalters@0
|
16
|
tomwalters@0
|
17 waithand=waitbar(0,'generating NAP');
|
tomwalters@0
|
18
|
tomwalters@0
|
19 compression=options.compression;
|
tomwalters@0
|
20 switch compression
|
tomwalters@0
|
21 case 'sqrt'
|
tomwalters@0
|
22 nap=halfwayrectify(bmm);
|
tomwalters@0
|
23 nap=sqrt(nap);
|
tomwalters@0
|
24 case 'log'
|
tomwalters@0
|
25 nap=logcompress(bmm,options);
|
tomwalters@0
|
26 end
|
tomwalters@0
|
27 %save bmm.mat bmm;
|
tomwalters@0
|
28 %save nap.mat nap;
|
tomwalters@0
|
29
|
tomwalters@0
|
30 % lowpassfiltering in the end
|
tomwalters@0
|
31 if isfield(options,'do_lowpassfiltering') % this is multiplied to the threshold_time_const
|
tomwalters@0
|
32 do_lowpassfiltering=options.do_lowpassfiltering;
|
tomwalters@0
|
33 else
|
tomwalters@0
|
34 do_lowpassfiltering=1;
|
tomwalters@0
|
35 end
|
tomwalters@0
|
36
|
tomwalters@0
|
37 % cut off frequency lowpassfiltering in the end
|
tomwalters@0
|
38 if isfield(options,'lowpass_cutoff_frequency') % this is multiplied to the threshold_time_const
|
tomwalters@0
|
39 lowpass_cutoff_frequency=options.lowpass_cutoff_frequency;
|
tomwalters@0
|
40 else
|
tomwalters@0
|
41 lowpass_cutoff_frequency=1200;
|
tomwalters@0
|
42 end
|
tomwalters@0
|
43
|
tomwalters@0
|
44
|
tomwalters@0
|
45
|
tomwalters@0
|
46 % order of the lowpassfiltering in the end
|
tomwalters@0
|
47 if isfield(options,'lowpass_order') % this is multiplied to the threshold_time_const
|
tomwalters@0
|
48 lowpass_order=options.lowpass_order;
|
tomwalters@0
|
49 else
|
tomwalters@0
|
50 lowpass_order=2;
|
tomwalters@0
|
51 end
|
tomwalters@0
|
52
|
tomwalters@0
|
53
|
tomwalters@0
|
54 nr_chan=getnrchannels(nap);
|
tomwalters@0
|
55 if options.do_lowpassfiltering==1
|
tomwalters@0
|
56 for ii=1:nr_chan % through all channels: prepare working variable
|
tomwalters@0
|
57 if mod(ii,10)==0
|
tomwalters@0
|
58 waitbar(ii/nr_chan);
|
tomwalters@0
|
59 end
|
tomwalters@0
|
60 sig=getsinglechannel(nap,ii);
|
tomwalters@0
|
61 newsig=leakyintegrator(sig,lowpass_cutoff_frequency,lowpass_order);
|
tomwalters@0
|
62 nap=setsinglechannel(nap,ii,newsig);
|
tomwalters@0
|
63 end
|
tomwalters@0
|
64 end
|
tomwalters@0
|
65
|
tomwalters@0
|
66
|
tomwalters@0
|
67
|
tomwalters@0
|
68 timesum=getsum(nap);
|
tomwalters@0
|
69 maxt=max(timesum);
|
tomwalters@0
|
70 nap=setscalesumme(nap,maxt);
|
tomwalters@0
|
71 %save nap1.mat nap;
|
tomwalters@0
|
72 close(waithand);
|
tomwalters@0
|
73
|
tomwalters@0
|
74
|