comparison trunk/matlab/bmm/carfac/CARFAC_Transfer_Functions.m @ 565:3e2e0ab4f708

Major update to how the DOHC works; like in recent book OHC chapter; Design Doc update (a bit)
author dicklyon@google.com
date Thu, 24 May 2012 22:26:56 +0000
parents 3dff17554c6d
children
comparison
equal deleted inserted replaced
564:9c4c3675c3f8 565:3e2e0ab4f708
48 z_row = exp((i * 2 * pi / CF.fs) * freqs); % z = exp(sT) 48 z_row = exp((i * 2 * pi / CF.fs) * freqs); % z = exp(sT)
49 gains = Rational_Eval(stage_numerators, stage_denominators, z_row); 49 gains = Rational_Eval(stage_numerators, stage_denominators, z_row);
50 50
51 % Now multiply gains from input to output places; use logs? 51 % Now multiply gains from input to output places; use logs?
52 log_gains = log(gains); 52 log_gains = log(gains);
53 cum_log_gains = cumsum(log_gains); % accum across cascaded stages 53 cum_log_gains = cumsum(log_gains); % accum across cascaded stages
54 54
55 % And figure out which cascade products we want: 55 % And figure out which cascade products we want:
56 n_ch = CF.n_ch; 56 n_ch = CF.n_ch;
57 if nargin < 3 57 if nargin < 3
58 to_channels = 1:n_ch; 58 to_channels = 1:n_ch;
93 zz = [z_row .* z_row; z_row; ones(size(z_row))]; 93 zz = [z_row .* z_row; z_row; ones(size(z_row))];
94 % dot product of each poly row with each [z2; z; 1] col: 94 % dot product of each poly row with each [z2; z; 1] col:
95 gains = (numerators * zz) ./ (denominators * zz); 95 gains = (numerators * zz) ./ (denominators * zz);
96 96
97 97
98
98 function [stage_numerators, stage_denominators] = ... 99 function [stage_numerators, stage_denominators] = ...
99 CARFAC_Rational_Functions(CF, ear) 100 CARFAC_Rational_Functions(CF, ear)
100 % function [stage_z_numerators, stage_z_denominators] = ... 101 % function [stage_z_numerators, stage_z_denominators] = ...
101 % CARFAC_Rational_Functions(CF, ear) 102 % CARFAC_Rational_Functions(CF, ear)
102 % Return transfer functions of all stages as rational functions. 103 % Return transfer functions of all stages as rational functions.
105 ear = 1; 106 ear = 1;
106 end 107 end
107 108
108 n_ch = CF.n_ch; 109 n_ch = CF.n_ch;
109 coeffs = CF.ears(ear).CAR_coeffs; 110 coeffs = CF.ears(ear).CAR_coeffs;
110 min_zeta = CF.CAR_params.min_zeta;
111 111
112 a0 = coeffs.a0_coeffs; 112 a0 = coeffs.a0_coeffs;
113 c0 = coeffs.c0_coeffs; 113 c0 = coeffs.c0_coeffs;
114 zr = coeffs.zr_coeffs; 114 zr = coeffs.zr_coeffs;
115 115
116 % get r, adapted if we have state: 116 % get r, adapted if we have state:
117 r = coeffs.r1_coeffs; 117 r1 = coeffs.r1_coeffs; % max-damping condition
118 if isfield(CF.ears(ear), 'CAR_state') 118 if isfield(CF.ears(ear), 'CAR_state')
119 state = CF.ears(ear).CAR_state; 119 state = CF.ears(ear).CAR_state;
120 zB = state.zB_memory; % current extra damping 120 zB = state.zB_memory; % current delta-r from undamping
121 r = r - zr .* zB; 121 r = r1 + zB;
122 else 122 else
123 zB = 0; 123 zB = 0; % HIGH-level linear condition by default
124 end 124 end
125 125
126 g = CARFAC_Stage_g(coeffs, zB); 126 relative_undamping = zB ./ zr;
127 g = CARFAC_Stage_g(coeffs, relative_undamping);
127 a = a0 .* r; 128 a = a0 .* r;
128 c = c0 .* r; 129 c = c0 .* r;
129 r2 = r .* r; 130 r2 = r .* r;
130 h = coeffs.h_coeffs; 131 h = coeffs.h_coeffs;
131 132