annotate matlab/bmm/carfac/CARFAC_Run_Linear.m @ 476:b084aed83e87

Simplify plotting mess in CARFAC_Run
author dicklyon@google.com
date Thu, 22 Mar 2012 23:06:46 +0000
parents 52f659be9008
children 9a8334232633
rev   line source
dicklyon@467 1 % Copyright 2012, Google, Inc.
dicklyon@467 2 % Author Richard F. Lyon
dicklyon@467 3 %
dicklyon@467 4 % This Matlab file is part of an implementation of Lyon's cochlear model:
dicklyon@467 5 % "Cascade of Asymmetric Resonators with Fast-Acting Compression"
dicklyon@467 6 % to supplement Lyon's upcoming book "Human and Machine Hearing"
dicklyon@467 7 %
dicklyon@467 8 % Licensed under the Apache License, Version 2.0 (the "License");
dicklyon@467 9 % you may not use this file except in compliance with the License.
dicklyon@467 10 % You may obtain a copy of the License at
dicklyon@467 11 %
dicklyon@467 12 % http://www.apache.org/licenses/LICENSE-2.0
dicklyon@467 13 %
dicklyon@467 14 % Unless required by applicable law or agreed to in writing, software
dicklyon@467 15 % distributed under the License is distributed on an "AS IS" BASIS,
dicklyon@467 16 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
dicklyon@467 17 % See the License for the specific language governing permissions and
dicklyon@467 18 % limitations under the License.
dicklyon@467 19
dicklyon@467 20 function [naps, CF] = CARFAC_Run_Linear(CF, input_waves, extra_damping)
dicklyon@467 21 % function [naps, CF] = CARFAC_Run_Linear(CF, input_waves, extra_damping)
dicklyon@467 22 %
dicklyon@467 23 % This function runs the CARFAC; that is, filters a 1 or more channel
dicklyon@467 24 % sound input to make one or more neural activity patterns (naps);
dicklyon@467 25 % however, unlike CARFAC_Run, it forces it to be linear, and gives a
dicklyon@467 26 % linear (not detected) output.
dicklyon@467 27
dicklyon@473 28 saved_v_damp_max = CF.CAR_coeffs.v_damp_max;
dicklyon@473 29 CF.CAR_coeffs.v_damp_max = 0.00; % make it linear for now
dicklyon@467 30
dicklyon@473 31 [n_samp, n_ears] = size(input_waves);
dicklyon@467 32 n_ch = CF.n_ch;
dicklyon@467 33
dicklyon@473 34 if n_ears ~= CF.n_ears
dicklyon@467 35 error('bad number of input_waves channels passed to CARFAC_Run')
dicklyon@467 36 end
dicklyon@467 37
dicklyon@473 38 for ear = 1:CF.n_ears
dicklyon@469 39 % Set the state of damping, and prevent interpolation from there:
dicklyon@473 40 CF.CAR_state(ear).zB_memory(:) = extra_damping; % interpolator state
dicklyon@473 41 CF.CAR_state(ear).dzB_memory(:) = 0; % interpolator slope
dicklyon@473 42 CF.CAR_state(ear).g_memory = CARFAC_Stage_g( ...
dicklyon@473 43 CF.CAR_coeffs(ear), extra_damping);
dicklyon@473 44 CF.CAR_state(ear).dg_memory(:) = 0; % interpolator slope
dicklyon@467 45 end
dicklyon@467 46
dicklyon@473 47 naps = zeros(n_samp, n_ch, n_ears);
dicklyon@467 48
dicklyon@467 49 for k = 1:n_samp
dicklyon@467 50 % at each time step, possibly handle multiple channels
dicklyon@473 51 for ear = 1:n_ears
dicklyon@475 52 [filters_out, CF.CAR_state(ear)] = CARFAC_CAR_Step( ...
dicklyon@473 53 input_waves(k, ear), CF.CAR_coeffs, CF.CAR_state(ear));
dicklyon@473 54 naps(k, :, ear) = filters_out; % linear
dicklyon@467 55 end
dicklyon@467 56 % skip IHC and AGC updates
dicklyon@467 57 end
dicklyon@467 58
dicklyon@473 59 CF.CAR_coeffs.v_damp_max = saved_v_damp_max;
dicklyon@467 60