Skip to content

Commit

Permalink
Remove open_loop argument from CARFAC_Run, because it was removed fro…
Browse files Browse the repository at this point in the history
…m CARFAC_Run_Segment and moved to the CF parameters.

PiperOrigin-RevId: 581915968
  • Loading branch information
CARFAC Team authored and copybara-github committed Nov 13, 2023
1 parent 3d53aab commit 71c405e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 15 deletions.
6 changes: 4 additions & 2 deletions matlab/CARFAC_GenerateTestData.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ function CARFAC_GenerateTestData()

function WriteTestData(test_data_dir, test_name, signal, CF_struct, sai_struct, open_loop)
% function WriteTestData(test_data_dir, test_name, signal, CF_struct, sai_struct, open_loop)
%
%
% Helper function to run CARFAC and SAI over the given signal and
% save the results to text files in test_data_dir.

Expand All @@ -154,8 +154,10 @@ function WriteTestData(test_data_dir, test_name, signal, CF_struct, sai_struct,

WriteMatrixToFile([filename_prefix '-audio.txt'], signal);

CF_struct.open_loop = open_loop;

CF_struct = CARFAC_Init(CF_struct);
[CF_struct, nap_decim, nap, bm, ohc, agc] = CARFAC_Run(CF_struct, signal, 0, open_loop);
[CF_struct, nap_decim, nap, bm, ohc, agc] = CARFAC_Run(CF_struct, signal, 0);

% Store the data for each ear of each output signal in a separate file.
for ear = 1:CF_struct.n_ears
Expand Down
22 changes: 9 additions & 13 deletions matlab/CARFAC_Run.m
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
% limitations under the License.

function [CF, decim_naps, naps, BM, ohc, agc] = CARFAC_Run ...
(CF, input_waves, AGC_plot_fig_num, open_loop)
(CF, input_waves, AGC_plot_fig_num)
% function [CF, decim_naps, naps, BM, ohc, agc] = CARFAC_Run ...
% (CF, input_waves, AGC_plot_fig_num)
% This function runs the CARFAC; that is, filters a 1 or more channel
Expand All @@ -42,10 +42,6 @@
[n_samp, n_ears] = size(input_waves);
n_ch = CF.n_ch;

if nargin < 4
open_loop = 0;
end

if nargin < 3
AGC_plot_fig_num = 0;
end
Expand Down Expand Up @@ -102,46 +98,46 @@
% Process a segment to get a slice of decim_naps, and plot AGC state:
if ~isempty(BM)
% ask for everything in this case, for laziness:
[seg_naps, CF, seg_BM, seg_ohc, seg_agc] = CARFAC_Run_Segment(CF, input_waves(k_range, :), open_loop);
[seg_naps, CF, seg_BM, seg_ohc, seg_agc] = CARFAC_Run_Segment(CF, input_waves(k_range, :));
else
[seg_naps, CF] = CARFAC_Run_Segment(CF, input_waves(k_range, :), open_loop);
[seg_naps, CF] = CARFAC_Run_Segment(CF, input_waves(k_range, :));
end

if ~isempty(BM)
for ear = 1:n_ears
% Accumulate segment BM to make full BM
BM(k_range, :, ear) = seg_BM(:, :, ear);
end
end

if ~isempty(naps)
for ear = 1:n_ears
% Accumulate segment naps to make full naps
naps(k_range, :, ear) = seg_naps(:, :, ear);
end
end

if ~isempty(ohc)
for ear = 1:n_ears
% Accumulate segment naps to make full naps
ohc(k_range, :, ear) = seg_ohc(:, :, ear);
end
end

if ~isempty(agc)
for ear = 1:n_ears
% Accumulate segment naps to make full naps
agc(k_range, :, ear) = seg_agc(:, :, ear);
end
end

if ~isempty(decim_naps)
for ear = 1:n_ears
decim_naps(seg_num, :, ear) = CF.ears(ear).IHC_state.ihc_accum / seglen;
CF.ears(ear).IHC_state.ihc_accum = zeros(n_ch,1);
end
end

if AGC_plot_fig_num
figure(AGC_plot_fig_num); hold off; clf
maxmax = 0;
Expand Down

0 comments on commit 71c405e

Please sign in to comment.