dicklyon@528: % Copyright 2012, Google, Inc. dicklyon@528: % Author Richard F. Lyon dicklyon@528: % dicklyon@528: % This Matlab file is part of an implementation of Lyon's cochlear model: dicklyon@528: % "Cascade of Asymmetric Resonators with Fast-Acting Compression" dicklyon@528: % to supplement Lyon's upcoming book "Human and Machine Hearing" dicklyon@528: % dicklyon@528: % Licensed under the Apache License, Version 2.0 (the "License"); dicklyon@528: % you may not use this file except in compliance with the License. dicklyon@528: % You may obtain a copy of the License at dicklyon@528: % dicklyon@528: % http://www.apache.org/licenses/LICENSE-2.0 dicklyon@528: % dicklyon@528: % Unless required by applicable law or agreed to in writing, software dicklyon@528: % distributed under the License is distributed on an "AS IS" BASIS, dicklyon@528: % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. dicklyon@528: % See the License for the specific language governing permissions and dicklyon@528: % limitations under the License. dicklyon@528: dicklyon@565: function [naps, CF] = CARFAC_Run_Linear(CF, input_waves, relative_undamping) dicklyon@565: % function [naps, CF] = CARFAC_Run_Linear(CF, input_waves, relative_undamping) dicklyon@528: % dicklyon@528: % This function runs the CARFAC; that is, filters a 1 or more channel dicklyon@528: % sound input to make one or more neural activity patterns (naps); dicklyon@528: % however, unlike CARFAC_Run, it forces it to be linear, and gives a dicklyon@528: % linear (not detected) output. dicklyon@528: dicklyon@561: % only saving one of these, really: dicklyon@565: velocity_scale = CF.ears(1).CAR_coeffs.velocity_scale; dicklyon@561: for ear = 1:CF.n_ears dicklyon@565: % make it effectively linear for now dicklyon@565: CF.ears(ear).CAR_coeffs.velocity_scale = 0; dicklyon@561: end dicklyon@528: dicklyon@534: [n_samp, n_ears] = size(input_waves); dicklyon@528: n_ch = CF.n_ch; dicklyon@528: dicklyon@553: if nargin < 3 dicklyon@565: relative_undamping = 1; % default to min-damping condition dicklyon@553: end dicklyon@553: dicklyon@534: if n_ears ~= CF.n_ears dicklyon@528: error('bad number of input_waves channels passed to CARFAC_Run') dicklyon@528: end dicklyon@528: dicklyon@534: for ear = 1:CF.n_ears dicklyon@565: coeffs = CF.ears(ear).CAR_coeffs; dicklyon@530: % Set the state of damping, and prevent interpolation from there: dicklyon@565: CF.ears(ear).CAR_state.zB_memory(:) = coeffs.zr_coeffs .* relative_undamping; % interpolator state dicklyon@561: CF.ears(ear).CAR_state.dzB_memory(:) = 0; % interpolator slope dicklyon@565: CF.ears(ear).CAR_state.g_memory = CARFAC_Stage_g(coeffs, relative_undamping); dicklyon@561: CF.ears(ear).CAR_state.dg_memory(:) = 0; % interpolator slope dicklyon@528: end dicklyon@528: dicklyon@534: naps = zeros(n_samp, n_ch, n_ears); dicklyon@528: dicklyon@528: for k = 1:n_samp dicklyon@528: % at each time step, possibly handle multiple channels dicklyon@534: for ear = 1:n_ears dicklyon@561: [filters_out, CF.ears(ear).CAR_state] = CARFAC_CAR_Step( ... dicklyon@561: input_waves(k, ear), CF.ears(ear).CAR_coeffs, CF.ears(ear).CAR_state); dicklyon@534: naps(k, :, ear) = filters_out; % linear dicklyon@528: end dicklyon@528: % skip IHC and AGC updates dicklyon@528: end dicklyon@528: dicklyon@561: for ear = 1:CF.n_ears dicklyon@565: CF.ears(ear).CAR_coeffs.velocity_scale = velocity_scale; dicklyon@561: end dicklyon@528: