changeset 606:03c642677954

Minor tweaks to AGC params, state update, and hacking script.
author dicklyon@google.com
date Thu, 09 May 2013 18:24:51 +0000
parents 3875bb31cc10
children 49eef19e4f1d
files matlab/bmm/carfac/CARFAC_Design.m matlab/bmm/carfac/CARFAC_Init.m matlab/bmm/carfac/CARFAC_hacking.m
diffstat 3 files changed, 39 insertions(+), 48 deletions(-) [+]
line wrap: on
line diff
--- a/matlab/bmm/carfac/CARFAC_Design.m	Thu May 09 04:00:25 2013 +0000
+++ b/matlab/bmm/carfac/CARFAC_Design.m	Thu May 09 18:24:51 2013 +0000
@@ -71,14 +71,14 @@
     'time_constants', [1, 4, 16, 64]*0.002, ...
     'AGC_stage_gain', 2, ...  % gain from each stage to next slower stage
     'decimation', [8, 2, 2, 2], ...  % how often to update the AGC states
-    'AGC1_scales', [1.0, 1.4,  2.0, 2.8], ...   % in units of channels
-    'AGC2_scales', [1.6, 2.25, 3.2, 4.5], ... % spread more toward base
+    'AGC1_scales', [1.0, 1.4, 2.0, 2.8]*1.0, ...   % in units of channels
+    'AGC2_scales', [1.0, 1.4, 2.0, 2.8]*1.65, ... % spread more toward base
     'AGC_mix_coeff', 0.5);
 end
 
 if nargin < 5
   % HACK: these constant control the defaults
-  one_cap = 0;         % bool; 0 for new two-cap hack
+  one_cap = 1;         % bool; 1 for Allen model, as text states we use
   just_hwr = 0;        % book; 0 for normal/fancy IHC; 1 for HWR
   if just_hwr
     CF_IHC_params = struct('just_hwr', 1, ...  % just a simple HWR
@@ -416,7 +416,7 @@
 % default design result, running this function with no args, should look
 % like this, before CARFAC_Init puts state storage into it:
 %
-%
+
 % CF = CARFAC_Design
 % CAR_params = CF.CAR_params
 % AGC_params = CF.AGC_params
@@ -454,22 +454,19 @@
 %     AGC_stage_gain: 2
 %         decimation: [8 2 2 2]
 %        AGC1_scales: [1 1.4000 2 2.8000]
-%        AGC2_scales: [1.6000 2.2500 3.2000 4.5000]
+%        AGC2_scales: [1.6500 2.3100 3.3000 4.6200]
 %      AGC_mix_coeff: 0.5000
 % IHC_params = 
 %         just_hwr: 0
-%          one_cap: 0
+%          one_cap: 1
 %          tau_lpf: 8.0000e-05
-%         tau1_out: 0.0100
-%          tau1_in: 0.0200
-%         tau2_out: 0.0025
-%          tau2_in: 0.0050
+%          tau_out: 5.0000e-04
+%           tau_in: 0.0100
 %     ac_corner_Hz: 20
 % CAR_coeffs = 
 %               n_ch: 71
-%     velocity_scale: 0.0500
+%     velocity_scale: 0.1000
 %           v_offset: 0.0400
-%          v2_corner: 0.2000
 %          r1_coeffs: [71x1 double]
 %          a0_coeffs: [71x1 double]
 %          c0_coeffs: [71x1 double]
@@ -482,8 +479,8 @@
 %             AGC_stage_gain: 2
 %                AGC_epsilon: [0.1659 0.0867 0.0443 0.0224]
 %                 decimation: [8 2 2 2]
-%                 AGC_polez1: [0.1699 0.1780 0.1872 0.1903]
-%                 AGC_polez2: [0.2388 0.2271 0.2216 0.2148]
+%                 AGC_polez1: [0.1737 0.1818 0.1921 0.1948]
+%                 AGC_polez2: [0.2472 0.2336 0.2288 0.2207]
 %     AGC_spatial_iterations: [1 1 1 1]
 %            AGC_spatial_FIR: [3x4 double]
 %         AGC_spatial_n_taps: [3 3 3 3]
@@ -491,23 +488,17 @@
 %                   AGC_gain: 15
 %               detect_scale: 0.0667
 % AGC_spatial_FIR =
-%     0.2744    0.2829    0.2972    0.2999
-%     0.3423    0.3571    0.3512    0.3616
-%     0.3832    0.3600    0.3516    0.3385
+%     0.2856    0.2930    0.3099    0.3111
+%     0.3108    0.3314    0.3212    0.3365
+%     0.4036    0.3756    0.3689    0.3524
 % IHC_coeffs = 
 %            n_ch: 71
 %        just_hwr: 0
 %       lpf_coeff: 0.4327
-%       out1_rate: 0.0045
-%        in1_rate: 0.0023
-%       out2_rate: 0.0199
-%        in2_rate: 0.0091
-%         one_cap: 0
-%     output_gain: 12.1185
-%     rest_output: 0.3791
-%       rest_cap2: 0.7938
-%       rest_cap1: 0.8625
+%        out_rate: 0.0996
+%         in_rate: 0.0045
+%         one_cap: 1
+%     output_gain: 49.3584
+%     rest_output: 1.0426
+%        rest_cap: 0.5360
 %        ac_coeff: 0.0057
-
-
-
--- a/matlab/bmm/carfac/CARFAC_Init.m	Thu May 09 04:00:25 2013 +0000
+++ b/matlab/bmm/carfac/CARFAC_Init.m	Thu May 09 18:24:51 2013 +0000
@@ -39,7 +39,7 @@
   'z1_memory', zeros(n_ch, 1), ...
   'z2_memory', zeros(n_ch, 1), ...
   'zA_memory', zeros(n_ch, 1), ...
-  'zB_memory', zeros(n_ch, 1), ...
+  'zB_memory', coeffs.zr_coeffs, ...
   'dzB_memory', zeros(n_ch, 1), ...
   'zY_memory', zeros(n_ch, 1), ...
   'g_memory', coeffs.g0_coeffs, ...
--- a/matlab/bmm/carfac/CARFAC_hacking.m	Thu May 09 04:00:25 2013 +0000
+++ b/matlab/bmm/carfac/CARFAC_hacking.m	Thu May 09 18:24:51 2013 +0000
@@ -23,16 +23,17 @@
 
 %%
 
-use_plan_file = 1;
-dB_list = -60:20:40
+use_wav_file = 1;
+dB_list = -40;  % -60:20:40
 
-if use_plan_file
+if use_wav_file
+  wav_fn = 'plan.wav';
   
-  file_signal = wavread('plan.wav');
-  %   file_signal = file_signal(8100+(1:20000));  % trim for a faster test
-  file_signal = file_signal(10000+(1:10000));  % trim for a faster test
-  
+  wav_fn
+  file_signal = wavread(wav_fn);
+  file_signal = file_signal(:, 1);  % Mono test only.
 else
+  % A tone complex.
   flist = 1400 + (1:4)*200;
   alist = [1, 1, 1, 1];
   sine_signal = 0;
@@ -52,7 +53,6 @@
   test_signal = [test_signal; file_signal * 10^(dB/20)];
 end
 
-
 %% Run mono, then stereo test:
 
 agc_plot_fig_num = 6;
@@ -68,26 +68,26 @@
   
   CF_struct = CARFAC_Init(CF_struct);
   
-  [CF_struct, nap_decim, nap, BM, ohc, agc] = CARFAC_Run(CF_struct, test_signal, ...
+  [CF_struct, nap_decim, nap] = CARFAC_Run(CF_struct, test_signal, ...
     agc_plot_fig_num);
-  
-  %   nap = deskew(nap);  % deskew doesn't make much difference
-  
-  %   dB_BM = 10/log(10) * log(filter(1, [1, -0.995], BM(:, 20:50, :).^2));
-  sm_BM = filter(1, [1, -0.995], BM(:, :, :).^2);
+    
+  smoothed = filter(1, [1, -0.995], nap(:, :, :));
   
   % only ear 1:
-  smoothed = sm_BM(100:100:end, :, 1);
-  MultiScaleSmooth(10/log(10) * log(smoothed), 1);
+  smoothed = max(0, smoothed(50:50:end, :, 1));
+  MultiScaleSmooth(smoothed.^0.5, 1);
   
- 
+  figure(1)
+  starti = 0;  % Adjust if you want to plot a later part.
+  imagesc(nap(starti+(1:15000), :)');
+  
   % Display results for 1 or 2 ears:
   for ear = 1:n_ears
     smooth_nap = nap_decim(:, :, ear);
     if n_ears == 1
       mono_max = max(smooth_nap(:));
     end
-    figure(3 + ear + n_ears)  % Makes figures 5, ...
+    figure(3 + ear + n_ears)  % Makes figures 5, 6, 7.
     image(63 * ((max(0, smooth_nap)/mono_max)' .^ 0.5))
     title('smooth nap from nap decim')
     colormap(1 - gray);