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
|
tomwalters@0
|
16 function nap=gen_hl(bmm,options)
|
tomwalters@0
|
17
|
tomwalters@0
|
18 waithand=waitbar(0,'generating NAP');
|
tomwalters@0
|
19
|
tomwalters@0
|
20 nap=halfwayrectify(bmm);
|
tomwalters@0
|
21
|
tomwalters@0
|
22 vals=getvalues(nap);
|
tomwalters@0
|
23
|
tomwalters@0
|
24 %gtfb output values are: 0< gt_vals <1
|
tomwalters@0
|
25 %therefore we will scale for 16bit values
|
tomwalters@0
|
26 %operationally only 15 bits are used as we
|
tomwalters@0
|
27 %half wave rectify
|
tomwalters@0
|
28
|
tomwalters@0
|
29 % TCW AIM 2006 - 07/03/06 autoscaling now fixed
|
tomwalters@0
|
30 %vals=vals.*2.^15;
|
tomwalters@0
|
31 % Note: tcw Nov '05 - only re-added this part (from the log code) since otherwise it really
|
tomwalters@0
|
32 % screws up the display code later on. See do_aim_autoscale, cases {4,5}
|
tomwalters@0
|
33 % for why - the scaling seems a bit arbitrary to me!
|
tomwalters@0
|
34
|
tomwalters@0
|
35 nap=setvalues(nap,vals);
|
tomwalters@0
|
36
|
tomwalters@0
|
37 % lowpassfiltering in the end
|
tomwalters@0
|
38 if isfield(options,'do_lowpassfiltering') % this is multiplied to the threshold_time_const
|
tomwalters@0
|
39 do_lowpassfiltering=options.do_lowpassfiltering;
|
tomwalters@0
|
40 else
|
tomwalters@0
|
41 do_lowpassfiltering=1;
|
tomwalters@0
|
42 end
|
tomwalters@0
|
43
|
tomwalters@0
|
44 % cut off frequency lowpassfiltering in the end
|
tomwalters@0
|
45 if isfield(options,'lowpass_cutoff_frequency') % this is multiplied to the threshold_time_const
|
tomwalters@0
|
46 lowpass_cutoff_frequency=options.lowpass_cutoff_frequency;
|
tomwalters@0
|
47 else
|
tomwalters@0
|
48 lowpass_cutoff_frequency=1200;
|
tomwalters@0
|
49 end
|
tomwalters@0
|
50
|
tomwalters@0
|
51
|
tomwalters@0
|
52
|
tomwalters@0
|
53 % order of the lowpassfiltering in the end
|
tomwalters@0
|
54 if isfield(options,'lowpass_order') % this is multiplied to the threshold_time_const
|
tomwalters@0
|
55 lowpass_order=options.lowpass_order;
|
tomwalters@0
|
56 else
|
tomwalters@0
|
57 lowpass_order=2;
|
tomwalters@0
|
58 end
|
tomwalters@0
|
59
|
tomwalters@0
|
60
|
tomwalters@0
|
61 nr_chan=getnrchannels(nap);
|
tomwalters@0
|
62 if options.do_lowpassfiltering==1
|
tomwalters@0
|
63 for ii=1:nr_chan % through all channels: prepare working variable
|
tomwalters@0
|
64 if mod(ii,10)==0
|
tomwalters@0
|
65 waitbar(ii/nr_chan);
|
tomwalters@0
|
66 end
|
tomwalters@0
|
67 sig=getsinglechannel(nap,ii);
|
tomwalters@0
|
68 newsig=leakyintegrator(sig,lowpass_cutoff_frequency,lowpass_order);
|
tomwalters@0
|
69 nap=setsinglechannel(nap,ii,newsig);
|
tomwalters@0
|
70 end
|
tomwalters@0
|
71 end
|
tomwalters@0
|
72
|
tomwalters@0
|
73
|
tomwalters@0
|
74
|
tomwalters@0
|
75 timesum=getsum(nap);
|
tomwalters@0
|
76 maxt=max(timesum);
|
tomwalters@0
|
77 nap=setscalesumme(nap,maxt);
|
tomwalters@0
|
78 %save nap1.mat nap;
|
tomwalters@0
|
79 close(waithand);
|
tomwalters@0
|
80
|
tomwalters@0
|
81
|