comparison matlab/bmm/carfac/CARFAC_CAR_Step.m @ 504:a0869cb1c99b

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 37c007925536
children
comparison
equal deleted inserted replaced
502:37c007925536 504:a0869cb1c99b
15 % distributed under the License is distributed on an "AS IS" BASIS, 15 % distributed under the License is distributed on an "AS IS" BASIS,
16 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 % WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 % See the License for the specific language governing permissions and 17 % See the License for the specific language governing permissions and
18 % limitations under the License. 18 % limitations under the License.
19 19
20 function [zY, state] = CARFAC_CAR_Step(x_in, CAR_coeffs, state) 20 function [car_out, state] = CARFAC_CAR_Step(x_in, CAR_coeffs, state)
21 % function [zY, state] = CARFAC_CAR_Step(x_in, CAR_coeffs, state) 21 % function [zY, state] = CARFAC_CAR_Step(x_in, CAR_coeffs, state)
22 % 22 %
23 % One sample-time update step for the filter part of the CARFAC. 23 % One sample-time update step for the filter part of the CARFAC.
24 24
25 % Most of the update is parallel; finally we ripple inputs at the end. 25 % Most of the update is parallel; finally we ripple inputs at the end.
26 26
27 % Local nonlinearity zA and AGC feedback zB reduce pole radius: 27
28 % do the DOHC stuff:
29
30 g = state.g_memory + state.dg_memory; % interp g
31 zB = state.zB_memory + state.dzB_memory; % AGC interpolation state
32 % update the nonlinear function of "velocity", and zA (delay of z2):
28 zA = state.zA_memory; 33 zA = state.zA_memory;
29 zB = state.zB_memory + state.dzB_memory; % AGC interpolation 34 v = state.z2_memory - zA;
30 r1 = CAR_coeffs.r1_coeffs; 35 % nlf = CARFAC_OHC_NLF(v .* widen, CAR_coeffs); % widen v with feedback
31 g = state.g_memory + state.dg_memory; % interp g 36 nlf = CARFAC_OHC_NLF(v, CAR_coeffs);
37 % zB * nfl is "undamping" delta r:
38 r = CAR_coeffs.r1_coeffs + zB .* nlf;
39 zA = state.z2_memory;
32 40
33 % zB and zA are "extra damping", and multiply zr (compressed theta):
34 r = r1 - CAR_coeffs.zr_coeffs .* (zA + zB);
35 41
36 % now reduce state by r and rotate with the fixed cos/sin coeffs: 42 % now reduce state by r and rotate with the fixed cos/sin coeffs:
37 z1 = r .* (CAR_coeffs.a0_coeffs .* state.z1_memory - ... 43 z1 = r .* (CAR_coeffs.a0_coeffs .* state.z1_memory - ...
38 CAR_coeffs.c0_coeffs .* state.z2_memory); 44 CAR_coeffs.c0_coeffs .* state.z2_memory);
39 % z1 = z1 + inputs; 45 % z1 = z1 + inputs;
40 z2 = r .* (CAR_coeffs.c0_coeffs .* state.z1_memory + ... 46 z2 = r .* (CAR_coeffs.c0_coeffs .* state.z1_memory + ...
41 CAR_coeffs.a0_coeffs .* state.z2_memory); 47 CAR_coeffs.a0_coeffs .* state.z2_memory);
42
43 % update the nonlinear function of "velocity", into zA:
44 zA = CARFAC_OHC_NLF(state.z2_memory - z2, CAR_coeffs);
45 48
46 zY = CAR_coeffs.h_coeffs .* z2; % partial output 49 zY = CAR_coeffs.h_coeffs .* z2; % partial output
47 50
48 % Ripple input-output path, instead of parallel, to avoid delay... 51 % Ripple input-output path, instead of parallel, to avoid delay...
49 % this is the only part that doesn't get computed "in parallel": 52 % this is the only part that doesn't get computed "in parallel":
55 in_out = g(ch) * (in_out + zY(ch)); 58 in_out = g(ch) * (in_out + zY(ch));
56 zY(ch) = in_out; 59 zY(ch) = in_out;
57 end 60 end
58 61
59 % put new state back in place of old 62 % put new state back in place of old
60 % (z1 and z2 are genuine temps; the others can update by reference in C) 63 % (z1 is a genuine temp; the others can update by reference in C)
61 state.z1_memory = z1; 64 state.z1_memory = z1;
62 state.z2_memory = z2; 65 state.z2_memory = z2;
63 state.zA_memory = zA; 66 state.zA_memory = zA;
64 state.zB_memory = zB; 67 state.zB_memory = zB;
65 state.zY_memory = zY; 68 state.zY_memory = zY;
66 state.g_memory = g; 69 state.g_memory = g;
67 70
71 car_out = zY;
72
73