Mercurial > hg > aimc
annotate matlab/bmm/carfac/CARFAC_Cross_Couple.m @ 607:49eef19e4f1d
Added JSON output for use with node.js and backbone.js
author | sness@sness.net |
---|---|
date | Fri, 10 May 2013 20:12:49 +0000 |
parents | 896620d9d539 |
children | 586b0677aae8 |
rev | line source |
---|---|
dicklyon@500 | 1 function ears = CARFAC_Cross_Couple(ears); |
dicklyon@498 | 2 |
dicklyon@500 | 3 n_ears = length(ears); |
dicklyon@499 | 4 if n_ears > 1 |
dicklyon@500 | 5 n_stages = ears(1).AGC_coeffs.n_AGC_stages; |
dicklyon@499 | 6 % now cross-ear mix the stages that updated (leading stages at phase 0): |
dicklyon@500 | 7 for stage = 1:n_stages |
dicklyon@500 | 8 if ears(1).AGC_state.decim_phase(stage) > 0 |
dicklyon@499 | 9 break % all recently updated stages are finished |
dicklyon@499 | 10 else |
dicklyon@500 | 11 mix_coeff = ears(1).AGC_coeffs.AGC_mix_coeffs(stage); |
dicklyon@499 | 12 if mix_coeff > 0 % Typically stage 1 has 0 so no work on that one. |
dicklyon@499 | 13 this_stage_sum = 0; |
dicklyon@499 | 14 % sum up over the ears and get their mean: |
dicklyon@499 | 15 for ear = 1:n_ears |
dicklyon@500 | 16 stage_state = ears(ear).AGC_state.AGC_memory(:, stage); |
dicklyon@499 | 17 this_stage_sum = this_stage_sum + stage_state; |
dicklyon@499 | 18 end |
dicklyon@499 | 19 this_stage_mean = this_stage_sum / n_ears; |
dicklyon@499 | 20 % now move them all toward the mean: |
dicklyon@499 | 21 for ear = 1:n_ears |
dicklyon@500 | 22 stage_state = ears(ear).AGC_state.AGC_memory(:, stage); |
dicklyon@500 | 23 ears(ear).AGC_state.AGC_memory(:, stage) = ... |
dicklyon@499 | 24 stage_state + mix_coeff * (this_stage_mean - stage_state); |
dicklyon@499 | 25 end |
dicklyon@498 | 26 end |
dicklyon@498 | 27 end |
dicklyon@498 | 28 end |
dicklyon@498 | 29 end |