diff trunk/matlab/bmm/carfac/CARFAC_IHC_Step.m @ 560:ab7fabe2af5d

fix some bugs I left in IHC one-cap and just-hwr modes
author dicklyon@google.com
date Mon, 23 Apr 2012 21:02:04 +0000
parents 910efa18d8f5
children 3e2e0ab4f708
line wrap: on
line diff
--- a/trunk/matlab/bmm/carfac/CARFAC_IHC_Step.m	Tue Apr 10 05:40:18 2012 +0000
+++ b/trunk/matlab/bmm/carfac/CARFAC_IHC_Step.m	Mon Apr 23 21:02:04 2012 +0000
@@ -26,7 +26,7 @@
 just_hwr = coeffs.just_hwr;
 
 if just_hwr
-  ihc_out = max(0, filters_out);
+  ihc_out = min(2, max(0, filters_out));  % limit it for stability
   state.ihc_accum = state.ihc_accum + ihc_out;
 else
   conductance = CARFAC_Detect(filters_out);  % detect with HWR or so
@@ -48,13 +48,11 @@
 
   % smooth it twice with LPF:
 
+  ihc_out = ihc_out * coeffs.output_gain;
   state.lpf1_state = state.lpf1_state + coeffs.lpf_coeff * ...
     (ihc_out - state.lpf1_state);
-
   state.lpf2_state = state.lpf2_state + coeffs.lpf_coeff * ...
     (state.lpf1_state - state.lpf2_state);
-
-  ihc_out = state.lpf2_state * coeffs.output_gain - coeffs.rest_output;
-  
+  ihc_out = state.lpf2_state - coeffs.rest_output;
   state.ihc_accum = state.ihc_accum + ihc_out;  % for where decimated output is useful
 end