dicklyon@500: function ears = CARFAC_Cross_Couple(ears); dicklyon@498: dicklyon@500: n_ears = length(ears); dicklyon@499: if n_ears > 1 dicklyon@500: n_stages = ears(1).AGC_coeffs.n_AGC_stages; dicklyon@499: % now cross-ear mix the stages that updated (leading stages at phase 0): dicklyon@500: for stage = 1:n_stages dicklyon@500: if ears(1).AGC_state.decim_phase(stage) > 0 dicklyon@499: break % all recently updated stages are finished dicklyon@499: else dicklyon@500: mix_coeff = ears(1).AGC_coeffs.AGC_mix_coeffs(stage); dicklyon@499: if mix_coeff > 0 % Typically stage 1 has 0 so no work on that one. dicklyon@499: this_stage_sum = 0; dicklyon@499: % sum up over the ears and get their mean: dicklyon@499: for ear = 1:n_ears dicklyon@500: stage_state = ears(ear).AGC_state.AGC_memory(:, stage); dicklyon@499: this_stage_sum = this_stage_sum + stage_state; dicklyon@499: end dicklyon@499: this_stage_mean = this_stage_sum / n_ears; dicklyon@499: % now move them all toward the mean: dicklyon@499: for ear = 1:n_ears dicklyon@500: stage_state = ears(ear).AGC_state.AGC_memory(:, stage); dicklyon@500: ears(ear).AGC_state.AGC_memory(:, stage) = ... dicklyon@499: stage_state + mix_coeff * (this_stage_mean - stage_state); dicklyon@499: end dicklyon@498: end dicklyon@498: end dicklyon@498: end dicklyon@498: end