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