annotate matlab/bmm/carfac/CARFAC_Spatial_Smooth.m @ 646:e76951e4da20

Style fixes. - Fix most lint errors found by http://google-styleguide.googlecode.com/svn/trunk/cpplint/cpplint.py - Clean up commenting style. - Alphabetize #includes and using statements.
author ronw@google.com
date Tue, 11 Jun 2013 20:41:15 +0000
parents b3118c9ed67f
children
rev   line source
dicklyon@466 1 % Copyright 2012, Google, Inc.
dicklyon@466 2 % Author: Richard F. Lyon
dicklyon@466 3 %
dicklyon@466 4 % This Matlab file is part of an implementation of Lyon's cochlear model:
dicklyon@466 5 % "Cascade of Asymmetric Resonators with Fast-Acting Compression"
dicklyon@466 6 % to supplement Lyon's upcoming book "Human and Machine Hearing"
dicklyon@466 7 %
dicklyon@466 8 % Licensed under the Apache License, Version 2.0 (the "License");
dicklyon@466 9 % you may not use this file except in compliance with the License.
dicklyon@466 10 % You may obtain a copy of the License at
dicklyon@466 11 %
dicklyon@466 12 % http://www.apache.org/licenses/LICENSE-2.0
dicklyon@466 13 %
dicklyon@466 14 % Unless required by applicable law or agreed to in writing, software
dicklyon@466 15 % distributed under the License is distributed on an "AS IS" BASIS,
dicklyon@466 16 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dicklyon@466 17 % See the License for the specific language governing permissions and
dicklyon@466 18 % limitations under the License.
dicklyon@466 19
dicklyon@623 20 function stage_state = CARFAC_Spatial_Smooth(coeffs, stage_state)
dicklyon@462 21 % function AGC_state = CARFAC_Spatial_Smooth( ...
dicklyon@462 22 % n_taps, n_iterations, FIR_coeffs, AGC_state)
dicklyon@462 23
dicklyon@623 24 n_iterations = coeffs.AGC_spatial_iterations;
dicklyon@462 25
dicklyon@462 26 use_FIR = n_iterations < 4; % or whatever condition we want to try
dicklyon@462 27
dicklyon@462 28 if use_FIR
dicklyon@623 29 FIR_coeffs = coeffs.AGC_spatial_FIR;
dicklyon@623 30 switch coeffs.AGC_spatial_n_taps
dicklyon@462 31 case 3
dicklyon@462 32 for iter = 1:n_iterations
dicklyon@462 33 stage_state = ...
dicklyon@462 34 FIR_coeffs(1) * stage_state([1, 1:(end-1)], :) + ...
dicklyon@462 35 FIR_coeffs(2) * stage_state + ...
dicklyon@462 36 FIR_coeffs(3) * stage_state([2:end, end], :);
dicklyon@462 37 end
dicklyon@462 38 case 5 % 5-tap smoother duplicates first and last coeffs:
dicklyon@462 39 for iter = 1:n_iterations
dicklyon@462 40 stage_state = ...
dicklyon@473 41 FIR_coeffs(1) * (stage_state([1, 2, 1:(end-2)], :) + ...
dicklyon@462 42 stage_state([1, 1:(end-1)], :)) + ...
dicklyon@462 43 FIR_coeffs(2) * stage_state + ...
dicklyon@462 44 FIR_coeffs(3) * (stage_state([2:end, end], :) + ...
dicklyon@473 45 stage_state([3:end, end, end-1], :));
dicklyon@462 46 end
dicklyon@462 47 otherwise
dicklyon@475 48 error('Bad AGC_spatial_n_taps in CARFAC_Spatial_Smooth');
dicklyon@462 49 end
dicklyon@462 50 else
dicklyon@475 51 % use IIR method, back-and-forth first-order smoothers:
dicklyon@462 52 stage_state = SmoothDoubleExponential(stage_state, ...
dicklyon@462 53 coeffs.AGC_polez1(stage), coeffs.AGC_polez2(stage));
dicklyon@462 54 end