dicklyon@467: % Copyright 2012, Google, Inc. dicklyon@467: % Author Richard F. Lyon dicklyon@467: % dicklyon@467: % This Matlab file is part of an implementation of Lyon's cochlear model: dicklyon@467: % "Cascade of Asymmetric Resonators with Fast-Acting Compression" dicklyon@467: % to supplement Lyon's upcoming book "Human and Machine Hearing" dicklyon@467: % dicklyon@467: % Licensed under the Apache License, Version 2.0 (the "License"); dicklyon@467: % you may not use this file except in compliance with the License. dicklyon@467: % You may obtain a copy of the License at dicklyon@467: % dicklyon@467: % http://www.apache.org/licenses/LICENSE-2.0 dicklyon@467: % dicklyon@467: % Unless required by applicable law or agreed to in writing, software dicklyon@467: % distributed under the License is distributed on an "AS IS" BASIS, dicklyon@467: % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. dicklyon@467: % See the License for the specific language governing permissions and dicklyon@467: % limitations under the License. dicklyon@467: dicklyon@467: function [naps, CF] = CARFAC_Run_Linear(CF, input_waves, extra_damping) dicklyon@467: % function [naps, CF] = CARFAC_Run_Linear(CF, input_waves, extra_damping) dicklyon@467: % dicklyon@467: % This function runs the CARFAC; that is, filters a 1 or more channel dicklyon@467: % sound input to make one or more neural activity patterns (naps); dicklyon@467: % however, unlike CARFAC_Run, it forces it to be linear, and gives a dicklyon@467: % linear (not detected) output. dicklyon@467: dicklyon@467: saved_v_damp_max = CF.filter_coeffs.v_damp_max; dicklyon@467: CF.filter_coeffs.v_damp_max = 0.00; % make it linear for now dicklyon@467: dicklyon@467: [n_samp, n_mics] = size(input_waves); dicklyon@467: n_ch = CF.n_ch; dicklyon@467: dicklyon@467: if n_mics ~= CF.n_mics dicklyon@467: error('bad number of input_waves channels passed to CARFAC_Run') dicklyon@467: end dicklyon@467: dicklyon@467: for mic = 1:CF.n_mics dicklyon@467: % for the state of the AGC interpolator: dicklyon@467: CF.filter_state(mic).zB_memory(:) = extra_damping; % interpolator state dicklyon@467: CF.filter_state(mic).dzB_memory(:) = 0; % interpolator slope dicklyon@467: end dicklyon@467: dicklyon@467: naps = zeros(n_samp, n_ch, n_mics); dicklyon@467: dicklyon@467: for k = 1:n_samp dicklyon@467: % at each time step, possibly handle multiple channels dicklyon@467: for mic = 1:n_mics dicklyon@467: [filters_out, CF.filter_state(mic)] = CARFAC_FilterStep( ... dicklyon@467: input_waves(k, mic), CF.filter_coeffs, CF.filter_state(mic)); dicklyon@467: naps(k, :, mic) = filters_out; % linear dicklyon@467: end dicklyon@467: % skip IHC and AGC updates dicklyon@467: end dicklyon@467: dicklyon@467: CF.filter_coeffs.v_damp_max = saved_v_damp_max; dicklyon@467: