comparison matlab/bmm/carfac/CARFAC_Design.m @ 467:a2e184f0a7b4

More updates
author dicklyon@google.com
date Sat, 10 Mar 2012 05:05:35 +0000
parents 7b57ab0d0126
children bc0618485ad4
comparison
equal deleted inserted replaced
466:8d9538f64176 467:a2e184f0a7b4
95 'velocity_scale', 0.2, ... % for the "cubic" velocity nonlinearity 95 'velocity_scale', 0.2, ... % for the "cubic" velocity nonlinearity
96 'v_offset', 0.01, ... % offset gives a quadratic part 96 'v_offset', 0.01, ... % offset gives a quadratic part
97 'v2_corner', 0.2, ... % corner for essential nonlin 97 'v2_corner', 0.2, ... % corner for essential nonlin
98 'v_damp_max', 0.01, ... % damping delta damping from velocity nonlin 98 'v_damp_max', 0.01, ... % damping delta damping from velocity nonlin
99 'min_zeta', 0.12, ... 99 'min_zeta', 0.12, ...
100 'first_pole_theta', 0.78*pi, ... 100 'first_pole_theta', 0.85*pi, ...
101 'zero_ratio', sqrt(2), ... 101 'zero_ratio', sqrt(2), ... % how far zero is above pole
102 'ERB_per_step', 0.3333, ... % assume G&M's ERB formula 102 'ERB_per_step', 0.5, ... % assume G&M's ERB formula
103 'min_pole_Hz', 40 ); 103 'min_pole_Hz', 30 );
104 end 104 end
105 105
106 if nargin < 1 106 if nargin < 1
107 fs = 22050; 107 fs = 22050;
108 end 108 end
124 pole_Hz = pole_Hz - CF_filter_params.ERB_per_step * ... 124 pole_Hz = pole_Hz - CF_filter_params.ERB_per_step * ...
125 ERB_Hz(pole_Hz, ERB_break_freq, ERB_Q); 125 ERB_Hz(pole_Hz, ERB_break_freq, ERB_Q);
126 end 126 end
127 % now we have n_ch, the number of channels, and pole_freqs array 127 % now we have n_ch, the number of channels, and pole_freqs array
128 128
129 max_channels_per_octave = log(2) / log(pole_freqs(1)/pole_freqs(2));
130
129 CF = struct( ... 131 CF = struct( ...
130 'fs', fs, ... 132 'fs', fs, ...
133 'max_channels_per_octave', max_channels_per_octave, ...
131 'filter_params', CF_filter_params, ... 134 'filter_params', CF_filter_params, ...
132 'AGC_params', CF_AGC_params, ... 135 'AGC_params', CF_AGC_params, ...
133 'IHC_params', CF_IHC_params, ... 136 'IHC_params', CF_IHC_params, ...
134 'n_ch', n_ch, ... 137 'n_ch', n_ch, ...
135 'pole_freqs', pole_freqs, ... 138 'pole_freqs', pole_freqs, ...
173 theta = pole_freqs .* (2 * pi / fs); 176 theta = pole_freqs .* (2 * pi / fs);
174 177
175 % different possible interpretations for min-damping r: 178 % different possible interpretations for min-damping r:
176 % r = exp(-theta * CF_filter_params.min_zeta). 179 % r = exp(-theta * CF_filter_params.min_zeta).
177 % Using sin gives somewhat higher Q at highest thetas. 180 % Using sin gives somewhat higher Q at highest thetas.
178 r = (1 - sin(theta) * filter_params.min_zeta); 181 ff = 5; % fudge factor for theta distortion; at least 1.0
182 r = (1 - ff*sin(theta/ff) * filter_params.min_zeta);
179 filter_coeffs.r_coeffs = r; 183 filter_coeffs.r_coeffs = r;
180 184
181 % undamped coupled-form coefficients: 185 % undamped coupled-form coefficients:
182 filter_coeffs.a_coeffs = cos(theta); 186 filter_coeffs.a_coeffs = cos(theta);
183 filter_coeffs.c_coeffs = sin(theta); 187 filter_coeffs.c_coeffs = sin(theta);
184 188
185 % the zeros follow via the h_coeffs 189 % the zeros follow via the h_coeffs
186 h = sin(theta) .* f; 190 h = sin(theta) .* f;
187 filter_coeffs.h_coeffs = h; 191 filter_coeffs.h_coeffs = h;
188 192
189 % unity gain at min damping, radius r: 193 % % unity gain at min damping, radius r:
190 filter_coeffs.g_coeffs = (1 - 2*r.*cos(theta) + r.^2) ./ ... 194 g = (1 - 2*r.*cos(theta) + r.^2) ./ ...
191 (1 - 2*r .* cos(theta) + h .* r .* sin(theta) + r.^2); 195 (1 - 2*r .* cos(theta) + h .* r .* sin(theta) + r.^2);
192 196 % or assume r is 1, for the zero-damping gain g0:
197 g0 = (2 - 2*cos(theta)) ./ ...
198 (2 - 2 * cos(theta) + h .* sin(theta));
199
200 filter_coeffs.g_coeffs = g0;
201 % make coeffs that can correct g0 to make g based on (1 - r).^2:
202 filter_coeffs.gr_coeffs = ((g ./ g0) - 1) ./ ((1 - r).^2);
193 203
194 %% the AGC design coeffs: 204 %% the AGC design coeffs:
195 function AGC_coeffs = CARFAC_DesignAGC(AGC_params, fs) 205 function AGC_coeffs = CARFAC_DesignAGC(AGC_params, fs)
196 206
197 AGC_coeffs = struct('AGC_stage_gain', AGC_params.AGC_stage_gain); 207 AGC_coeffs = struct('AGC_stage_gain', AGC_params.AGC_stage_gain);