From 166453b17bbb0dde1b190e2c575e63bcb9a53c3b Mon Sep 17 00:00:00 2001 From: Seppo Ingalsuo Date: Tue, 4 Jun 2024 17:01:20 +0300 Subject: [PATCH] Audio: TDFB: Tune: Move beamformer setup scripts to module directory The change is done to consolidate the files belonging to the module. The files are moved from directory tools/tune/tdfb into src/audio/tdfb/tune. There are no functional changes but the impacts of naming the scripts with sof prefix and move of directory locations is fixed. A new script sof_bf_paths is added to make add and remove needed paths more convenient. Signed-off-by: Seppo Ingalsuo --- .../audio/tdfb/tune/sof_bf_array_circ.m | 4 +- .../audio/tdfb/tune/sof_bf_array_line.m | 4 +- .../audio/tdfb/tune/sof_bf_array_lshape.m | 4 +- .../audio/tdfb/tune/sof_bf_array_rect.m | 4 +- .../audio/tdfb/tune/sof_bf_array_rot.m | 4 +- .../audio/tdfb/tune/sof_bf_array_xyz.m | 4 +- .../audio/tdfb/tune/sof_bf_blob_pack.m | 2 +- .../audio/tdfb/tune/sof_bf_defaults.m | 11 +-- .../audio/tdfb/tune/sof_bf_design.m | 21 +++--- .../audio/tdfb/tune/sof_bf_export.m | 22 +++--- .../audio/tdfb/tune/sof_bf_filenames_helper.m | 4 +- .../audio/tdfb/tune/sof_bf_merge.m | 4 +- src/audio/tdfb/tune/sof_bf_paths.m | 29 ++++++++ .../audio/tdfb/tune/sof_example_all.sh | 4 +- .../tdfb/tune/sof_example_circular_array.m | 14 ++-- .../tune/sof_example_direction_emphasis.m | 0 .../tune/sof_example_line_0mm36mm146mm182mm.m | 10 +-- .../audio/tdfb/tune/sof_example_line_array.m | 14 ++-- .../audio/tdfb/tune/sof_example_pass_config.m | 12 +-- .../audio/tdfb/tune/sof_example_two_beams.m | 74 +++++++++---------- 20 files changed, 135 insertions(+), 110 deletions(-) rename tools/tune/tdfb/bf_array_circ.m => src/audio/tdfb/tune/sof_bf_array_circ.m (91%) rename tools/tune/tdfb/bf_array_line.m => src/audio/tdfb/tune/sof_bf_array_line.m (89%) rename tools/tune/tdfb/bf_array_lshape.m => src/audio/tdfb/tune/sof_bf_array_lshape.m (92%) rename tools/tune/tdfb/bf_array_rect.m => src/audio/tdfb/tune/sof_bf_array_rect.m (92%) rename tools/tune/tdfb/bf_array_rot.m => src/audio/tdfb/tune/sof_bf_array_rot.m (95%) rename tools/tune/tdfb/bf_array_xyz.m => src/audio/tdfb/tune/sof_bf_array_xyz.m (90%) rename tools/tune/tdfb/bf_blob_pack.m => src/audio/tdfb/tune/sof_bf_blob_pack.m (98%) rename tools/tune/tdfb/bf_defaults.m => src/audio/tdfb/tune/sof_bf_defaults.m (83%) rename tools/tune/tdfb/bf_design.m => src/audio/tdfb/tune/sof_bf_design.m (98%) rename tools/tune/tdfb/bf_export.m => src/audio/tdfb/tune/sof_bf_export.m (88%) rename tools/tune/tdfb/bf_filenames_helper.m => src/audio/tdfb/tune/sof_bf_filenames_helper.m (97%) rename tools/tune/tdfb/bf_merge.m => src/audio/tdfb/tune/sof_bf_merge.m (96%) create mode 100644 src/audio/tdfb/tune/sof_bf_paths.m rename tools/tune/tdfb/example_all.sh => src/audio/tdfb/tune/sof_example_all.sh (80%) rename tools/tune/tdfb/example_circular_array.m => src/audio/tdfb/tune/sof_example_circular_array.m (87%) rename tools/tune/tdfb/example_direction_emphasis.m => src/audio/tdfb/tune/sof_example_direction_emphasis.m (100%) rename tools/tune/tdfb/example_line_0mm36mm146mm182mm.m => src/audio/tdfb/tune/sof_example_line_0mm36mm146mm182mm.m (91%) rename tools/tune/tdfb/example_line_array.m => src/audio/tdfb/tune/sof_example_line_array.m (88%) rename tools/tune/tdfb/example_pass_config.m => src/audio/tdfb/tune/sof_example_pass_config.m (91%) rename tools/tune/tdfb/example_two_beams.m => src/audio/tdfb/tune/sof_example_two_beams.m (90%) diff --git a/tools/tune/tdfb/bf_array_circ.m b/src/audio/tdfb/tune/sof_bf_array_circ.m similarity index 91% rename from tools/tune/tdfb/bf_array_circ.m rename to src/audio/tdfb/tune/sof_bf_array_circ.m index 43d059b95d27..db6fab035db1 100644 --- a/tools/tune/tdfb/bf_array_circ.m +++ b/src/audio/tdfb/tune/sof_bf_array_circ.m @@ -1,4 +1,4 @@ -% bf = bf_array_circ(bf) +% bf = sof_bf_array_circ(bf) % % Inputs % bf.mic_n ... number of microphones @@ -15,7 +15,7 @@ % % Author: Seppo Ingalsuo -function bf = bf_array_circ(bf) +function bf = sof_bf_array_circ(bf) bf.mic_angle = (0:bf.mic_n-1)*360/bf.mic_n; % Mic 1 at 0 deg idx = find(bf.mic_angle > 180); % wrap > 180 deg to -180 .. 0 diff --git a/tools/tune/tdfb/bf_array_line.m b/src/audio/tdfb/tune/sof_bf_array_line.m similarity index 89% rename from tools/tune/tdfb/bf_array_line.m rename to src/audio/tdfb/tune/sof_bf_array_line.m index 67d377265e75..db9f66809d74 100644 --- a/tools/tune/tdfb/bf_array_line.m +++ b/src/audio/tdfb/tune/sof_bf_array_line.m @@ -1,4 +1,4 @@ -% bf = bf_array_line(bf) +% bf = sof_bf_array_line(bf) % % Inputs % bf.mic_n ... number of microphones @@ -15,7 +15,7 @@ % % Author: Seppo Ingalsuo -function bf = bf_array_line(bf) +function bf = sof_bf_array_line(bf) bf.mic_y = linspace(0, -(bf.mic_n-1) * bf.mic_d, bf.mic_n) ... + (bf.mic_n-1) * bf.mic_d / 2; diff --git a/tools/tune/tdfb/bf_array_lshape.m b/src/audio/tdfb/tune/sof_bf_array_lshape.m similarity index 92% rename from tools/tune/tdfb/bf_array_lshape.m rename to src/audio/tdfb/tune/sof_bf_array_lshape.m index 21ae84f08c1a..965e8c3100bc 100644 --- a/tools/tune/tdfb/bf_array_lshape.m +++ b/src/audio/tdfb/tune/sof_bf_array_lshape.m @@ -1,4 +1,4 @@ -% bf = bf_array_lshape(bf) +% bf = sof_bf_array_lshape(bf) % % Inputs % bf.mic_nxy ... vector of two with number of microphones along x and y @@ -15,7 +15,7 @@ % % Author: Seppo Ingalsuo -function bf = bf_array_lshape(bf) +function bf = sof_bf_array_lshape(bf) bf.mic_x = []; bf.mic_y = []; diff --git a/tools/tune/tdfb/bf_array_rect.m b/src/audio/tdfb/tune/sof_bf_array_rect.m similarity index 92% rename from tools/tune/tdfb/bf_array_rect.m rename to src/audio/tdfb/tune/sof_bf_array_rect.m index 1f2d1c7ace18..cab63190a1dd 100644 --- a/tools/tune/tdfb/bf_array_rect.m +++ b/src/audio/tdfb/tune/sof_bf_array_rect.m @@ -1,4 +1,4 @@ -% bf = bf_array_rect(bf) +% bf = sof_bf_array_rect(bf) % % Inputs % bf.mic_nxy ... vector of two with number of microphones along x and y @@ -15,7 +15,7 @@ % % Author: Seppo Ingalsuo -function bf = bf_array_rect(bf) +function bf = sof_bf_array_rect(bf) bf.mic_x = []; bf.mic_y = []; diff --git a/tools/tune/tdfb/bf_array_rot.m b/src/audio/tdfb/tune/sof_bf_array_rot.m similarity index 95% rename from tools/tune/tdfb/bf_array_rot.m rename to src/audio/tdfb/tune/sof_bf_array_rot.m index 850e4b52a59c..6bdde5f0a49d 100644 --- a/tools/tune/tdfb/bf_array_rot.m +++ b/src/audio/tdfb/tune/sof_bf_array_rot.m @@ -1,4 +1,4 @@ -% bf = bf_array_rot(bf) +% bf = sof_bf_array_rot(bf) % % Inputs % bf.array_angle ... three element vector for x, y, z rotation [degrees] @@ -17,7 +17,7 @@ % % Author: Seppo Ingalsuo -function bf = bf_array_rot(bf) +function bf = sof_bf_array_rot(bf) % Equations reference % https://en.wikipedia.org/wiki/Rotation_matrix#Basic_rotations diff --git a/tools/tune/tdfb/bf_array_xyz.m b/src/audio/tdfb/tune/sof_bf_array_xyz.m similarity index 90% rename from tools/tune/tdfb/bf_array_xyz.m rename to src/audio/tdfb/tune/sof_bf_array_xyz.m index 75ad5f3911ba..6426b651c3e1 100644 --- a/tools/tune/tdfb/bf_array_xyz.m +++ b/src/audio/tdfb/tune/sof_bf_array_xyz.m @@ -1,4 +1,4 @@ -% bf = bf_array_xyz(bf) +% bf = sof_bf_array_xyz(bf) % % Inputs % bf.mic_x ... x coordinates [m] @@ -17,7 +17,7 @@ % % Author: Seppo Ingalsuo -function bf = bf_array_xyz(bf) +function bf = sof_bf_array_xyz(bf) bf.mic_n = length(bf.mic_x); bf.mic_x = bf.mic_x - mean(bf.mic_x); diff --git a/tools/tune/tdfb/bf_blob_pack.m b/src/audio/tdfb/tune/sof_bf_blob_pack.m similarity index 98% rename from tools/tune/tdfb/bf_blob_pack.m rename to src/audio/tdfb/tune/sof_bf_blob_pack.m index 306c16a6ad99..2717595aa10a 100644 --- a/tools/tune/tdfb/bf_blob_pack.m +++ b/src/audio/tdfb/tune/sof_bf_blob_pack.m @@ -1,4 +1,4 @@ -function blob8 = bf_blob_pack(bf, ipc_version) +function blob8 = sof_bf_blob_pack(bf, ipc_version) %% Pack TDFB struct to bytes % diff --git a/tools/tune/tdfb/bf_defaults.m b/src/audio/tdfb/tune/sof_bf_defaults.m similarity index 83% rename from tools/tune/tdfb/bf_defaults.m rename to src/audio/tdfb/tune/sof_bf_defaults.m index 862721041cc8..f8222b597da3 100644 --- a/tools/tune/tdfb/bf_defaults.m +++ b/src/audio/tdfb/tune/sof_bf_defaults.m @@ -1,4 +1,4 @@ -function bf = bf_defaults() +function bf = sof_bf_defaults() % Recording array general setup bf.taylorwin_sidelobe = -30; @@ -19,10 +19,11 @@ bf.array_angle = [0 0 0]; % Array rotation angles for xyz bf.tplg_fn = ''; bf.sofctl_fn = ''; -bf.tplg1_path = '../../topology/topology1/m4/tdfb'; -bf.tplg2_path = '../../topology/topology2/include/components/tdfb'; -bf.sofctl3_path = '../../ctl/ipc3/tdfb'; -bf.sofctl4_path = '../../ctl/ipc4/tdfb'; +sof_tools = '../../../../tools'; +bf.tplg1_path = fullfile(sof_tools, 'topology/topology1/m4/tdfb'); +bf.tplg2_path = fullfile(sof_tools, 'topology/topology2/include/components/tdfb'); +bf.sofctl3_path = fullfile(sof_tools, 'ctl/ipc3/tdfb'); +bf.sofctl4_path = fullfile(sof_tools, 'ctl/ipc4/tdfb'); bf.data_path = './data'; bf.endian = 'little'; bf.fn = 1; diff --git a/tools/tune/tdfb/bf_design.m b/src/audio/tdfb/tune/sof_bf_design.m similarity index 98% rename from tools/tune/tdfb/bf_design.m rename to src/audio/tdfb/tune/sof_bf_design.m index 08da294ca17f..010e48b2c94d 100644 --- a/tools/tune/tdfb/bf_design.m +++ b/src/audio/tdfb/tune/sof_bf_design.m @@ -1,4 +1,4 @@ -% bf = bf_design(bf) +% bf = sof_bf_design(bf) % % This script calculates beamformer filters with superdirective design % criteria. @@ -9,10 +9,9 @@ % % Author: Seppo Ingalsuo -function bf = bf_design(bf) +function bf = sof_bf_design(bf) -addpath('../../test/audio/test_utils'); -addpath('../../test/audio/std_utils'); +sof_bf_paths(true); mkdir_check('plots'); mkdir_check('data'); @@ -30,15 +29,15 @@ switch lower(bf.array) case 'line' - bf = bf_array_line(bf); + bf = sof_bf_array_line(bf); case 'circular' - bf = bf_array_circ(bf); + bf = sof_bf_array_circ(bf); case 'rectangle' - bf = bf_array_rect(bf); + bf = sof_bf_array_rect(bf); case 'lshape' - bf = bf_array_lshape(bf); + bf = sof_bf_array_lshape(bf); case 'xyz' - bf = bf_array_xyz(bf); + bf = sof_bf_array_xyz(bf); otherwise error('Invalid array type') end @@ -51,7 +50,7 @@ end end -bf = bf_array_rot(bf); +bf = sof_bf_array_rot(bf); % The design function handles only single (az, el) value, so need to % loop every steer angle. @@ -88,11 +87,11 @@ bf.mat_fn = all_mat_fn; bf.w = w_all; +sof_bf_paths(false); end function bf = bf_one_design(bf) - %% Defaults j = complex(0,-1); fs = bf.fs; diff --git a/tools/tune/tdfb/bf_export.m b/src/audio/tdfb/tune/sof_bf_export.m similarity index 88% rename from tools/tune/tdfb/bf_export.m rename to src/audio/tdfb/tune/sof_bf_export.m index f7d3666af4af..faf4cef3feb9 100644 --- a/tools/tune/tdfb/bf_export.m +++ b/src/audio/tdfb/tune/sof_bf_export.m @@ -1,4 +1,4 @@ -% bf_export(bf) +% sof_bf_export(bf) % % Inputs % bf.sofctl3_fn .... filename of ascii text format blob @@ -13,12 +13,10 @@ % % Author: Seppo Ingalsuo -function bf = bf_export(bf) +function bf = sof_bf_export(bf) -% Use functionc from common, test utils -addpath('../common'); -addpath('../eq'); -addpath('../../test/audio/test_utils'); +% Use functions from common, test utils +sof_bf_paths(true); %% Add needed default controls if missing @@ -60,7 +58,7 @@ for j=1:bf.num_angles for i=1:bf.num_filters coefs = squeeze(bf.w(:,i,j)); - bq = eq_fir_blob_quant(coefs, 16, 0); + bq = sof_eq_fir_blob_quant(coefs, 16, 0); filters = [filters bq ]; end end @@ -68,7 +66,7 @@ %% Add beam-off preset if bf.beam_off_defined b_pass = [1]; - bq = eq_fir_blob_quant(b_pass, 16, 0); + bq = sof_eq_fir_blob_quant(b_pass, 16, 0); for i=1:bf.num_filters filters = [filters bq ]; end @@ -76,8 +74,8 @@ %% Build blob bf.all_filters = filters; -bp3 = bf_blob_pack(bf, 3); -bp4 = bf_blob_pack(bf, 4); +bp3 = sof_bf_blob_pack(bf, 3); +bp4 = sof_bf_blob_pack(bf, 4); %% Export if isempty(bf.sofctl3_fn) @@ -118,8 +116,6 @@ tplg2_write(bf.tplg2_fn, bp4, "tdfb_config", export_note, bf.export_howto); end -rmpath('../../test/audio/test_utils'); -rmpath('../eq'); -rmpath('../common'); +sof_bf_paths(false); end diff --git a/tools/tune/tdfb/bf_filenames_helper.m b/src/audio/tdfb/tune/sof_bf_filenames_helper.m similarity index 97% rename from tools/tune/tdfb/bf_filenames_helper.m rename to src/audio/tdfb/tune/sof_bf_filenames_helper.m index 7fd446df37b3..2a206c2e9d51 100644 --- a/tools/tune/tdfb/bf_filenames_helper.m +++ b/src/audio/tdfb/tune/sof_bf_filenames_helper.m @@ -1,4 +1,4 @@ -% bf = bf_filenames_helper(bf, id) +% bf = sof_bf_filenames_helper(bf, id) % % Automatically defines output files names based on array geometry % and steer angle. @@ -9,7 +9,7 @@ % % Author: Seppo Ingalsuo -function bf = bf_filenames_helper(bf, id) +function bf = sof_bf_filenames_helper(bf, id) switch lower(bf.array) case {'rectangle' 'lshape'} diff --git a/tools/tune/tdfb/bf_merge.m b/src/audio/tdfb/tune/sof_bf_merge.m similarity index 96% rename from tools/tune/tdfb/bf_merge.m rename to src/audio/tdfb/tune/sof_bf_merge.m index 5358d72bf7a0..a82d2edf47ac 100644 --- a/tools/tune/tdfb/bf_merge.m +++ b/src/audio/tdfb/tune/sof_bf_merge.m @@ -1,4 +1,4 @@ -% bfm = bf_merge(bf1, bf2) +% bfm = sof_bf_merge(bf1, bf2) % SPDX-License-Identifier: BSD-3-Clause % @@ -6,7 +6,7 @@ % % Author: Seppo Ingalsuo -function bfm = bf_merge(bf1, bf2) +function bfm = sof_bf_merge(bf1, bf2) if nargin > 2 error('Current implementation can merge only two beams configuration'); diff --git a/src/audio/tdfb/tune/sof_bf_paths.m b/src/audio/tdfb/tune/sof_bf_paths.m new file mode 100644 index 000000000000..9a6a351bdf7d --- /dev/null +++ b/src/audio/tdfb/tune/sof_bf_paths.m @@ -0,0 +1,29 @@ +function sof_bf_paths(enable) + +% sof_bf_paths(enable) +% enable - set to true to enable needed search path +% set to false to disable the search paths +% + +% SPDX-License-Identifier: BSD-3-Clause +% +% Copyright (c) 2024, Intel Corporation. + + sof_tools = '../../../../tools'; + sof_modules = '../..'; + common = fullfile(sof_tools, 'tune/common'); + eq = fullfile(sof_modules, 'eq_iir/tune'); + test_utils = fullfile(sof_tools, 'test/audio/test_utils'); + std_utils = fullfile(sof_tools, 'test/audio/std_utils'); + if enable + addpath(common); + addpath(eq); + addpath(test_utils); + addpath(std_utils); + else + rmpath(common); + rmpath(eq); + rmpath(test_utils); + rmpath(std_utils); + end +end diff --git a/tools/tune/tdfb/example_all.sh b/src/audio/tdfb/tune/sof_example_all.sh similarity index 80% rename from tools/tune/tdfb/example_all.sh rename to src/audio/tdfb/tune/sof_example_all.sh index ad99fcea299d..eb9c6f2ab74f 100755 --- a/tools/tune/tdfb/example_all.sh +++ b/src/audio/tdfb/tune/sof_example_all.sh @@ -5,8 +5,8 @@ set -e -CONFIG_LIST=( example_pass_config example_line_array - example_line_0mm36mm146mm182mm example_circular_array example_two_beams ) +CONFIG_LIST=( sof_example_pass_config sof_example_line_array + sof_example_line_0mm36mm146mm182mm sof_example_circular_array sof_example_two_beams ) OCTAVE_CMD=( octave --no-window-system ) MATLAB_CMD=( matlab -nodisplay -batch ) diff --git a/tools/tune/tdfb/example_circular_array.m b/src/audio/tdfb/tune/sof_example_circular_array.m similarity index 87% rename from tools/tune/tdfb/example_circular_array.m rename to src/audio/tdfb/tune/sof_example_circular_array.m index 3a0accfaba8f..dcc2bd52579d 100644 --- a/tools/tune/tdfb/example_circular_array.m +++ b/src/audio/tdfb/tune/sof_example_circular_array.m @@ -1,4 +1,4 @@ -function example_circular_array() +function sof_example_circular_array() % example_circular_array() % @@ -27,7 +27,7 @@ function example_circular_array() function circular_one_beam(fs, r, n, fir_length, az); % Get defaults -bf = bf_defaults(); +bf = sof_bf_defaults(); bf.input_channel_select = 0:(n-1); % Input all n channels to filters bf.output_channel_mix_beam_off = zeros(1, n); % For some stereo symmetry bf.output_channel_mix_beam_off(2) = 1; % Mic2 to channel 2^0 @@ -47,9 +47,9 @@ function example_circular_array() bf.fir_length = fir_length; % Design -bf = bf_filenames_helper(bf); -bf = bf_design(bf); -bf.export_note = 'Created with script example_circular_array.m'; -bf.export_howto = 'cd tools/tune/tdfb; octave --no-window-system example_circular_array.m'; -bf_export(bf); +bf = sof_bf_filenames_helper(bf); +bf = sof_bf_design(bf); +bf.export_note = 'Created with script sof_example_circular_array.m'; +bf.export_howto = 'cd tools/tune/tdfb; octave --no-window-system sof_example_circular_array.m'; +sof_bf_export(bf); end diff --git a/tools/tune/tdfb/example_direction_emphasis.m b/src/audio/tdfb/tune/sof_example_direction_emphasis.m similarity index 100% rename from tools/tune/tdfb/example_direction_emphasis.m rename to src/audio/tdfb/tune/sof_example_direction_emphasis.m diff --git a/tools/tune/tdfb/example_line_0mm36mm146mm182mm.m b/src/audio/tdfb/tune/sof_example_line_0mm36mm146mm182mm.m similarity index 91% rename from tools/tune/tdfb/example_line_0mm36mm146mm182mm.m rename to src/audio/tdfb/tune/sof_example_line_0mm36mm146mm182mm.m index 2ee0fc965c6e..62e5cae7172f 100644 --- a/tools/tune/tdfb/example_line_0mm36mm146mm182mm.m +++ b/src/audio/tdfb/tune/sof_example_line_0mm36mm146mm182mm.m @@ -1,4 +1,4 @@ -function example_line_0mm36mm146mm182mm() +function sof_example_line_0mm36mm146mm182mm() % Creates beamformer for device with device with microphones % at 0, 36, 146, 182mm locations @@ -23,7 +23,7 @@ function line_xyz(fs, fir_length, az) % Get defaults close all; -bf = bf_defaults(); +bf = sof_bf_defaults(); bf.fs = fs; bf.beta = 5; @@ -50,12 +50,12 @@ function line_xyz(fs, fir_length, az) %bf.sofctl_fn = fullfile(bf.sofctl_path, sofctl_fn); %bf.tplg_fn = fullfile(bf.tplg_path, tplg_fn); -bf = bf_filenames_helper(bf, 'line4_0mm36mm146mm182mm'); -bf = bf_design(bf); +bf = sof_bf_filenames_helper(bf, 'line4_0mm36mm146mm182mm'); +bf = sof_bf_design(bf); % Export files for topology and sof-ctl bf.export_note = 'Created with script example_line_0mm36mm146mm182mm.m'; bf.export_howto = 'cd tools/tune/tdfb; octave --no-window-system example_line_0mm36mm146mm182mm.m'; -bf_export(bf); +sof_bf_export(bf); end diff --git a/tools/tune/tdfb/example_line_array.m b/src/audio/tdfb/tune/sof_example_line_array.m similarity index 88% rename from tools/tune/tdfb/example_line_array.m rename to src/audio/tdfb/tune/sof_example_line_array.m index f29364f06365..be8b60acf3fc 100644 --- a/tools/tune/tdfb/example_line_array.m +++ b/src/audio/tdfb/tune/sof_example_line_array.m @@ -1,4 +1,4 @@ -function example_line_array() +function sof_example_line_array() % example_line_array() % @@ -32,7 +32,7 @@ function example_line_array() function line_one_beam(fs, d, az, n_mic, n_fir) % Get defaults - bf = bf_defaults(); + bf = sof_bf_defaults(); bf.input_channel_select = 0:(n_mic-1); % Input all n channels to filters bf.output_channel_mix = 3 * ones(1, n_mic); % Mix all filters to channel 1 and 2 bf.output_stream_mix = zeros(1, n_mic); % Mix filters to stream 0 @@ -56,9 +56,9 @@ function line_one_beam(fs, d, az, n_mic, n_fir) end % Design - bf = bf_filenames_helper(bf); - bf = bf_design(bf); - bf.export_note = 'Created with script example_line_array.m'; - bf.export_howto = 'cd tools/tune/tdfb; octave --no-window-system example_line_array.m'; - bf_export(bf); + bf = sof_bf_filenames_helper(bf); + bf = sof_bf_design(bf); + bf.export_note = 'Created with script sof_example_line_array.m'; + bf.export_howto = 'cd tools/tune/tdfb; octave --no-window-system sof_example_line_array.m'; + sof_bf_export(bf); end diff --git a/tools/tune/tdfb/example_pass_config.m b/src/audio/tdfb/tune/sof_example_pass_config.m similarity index 91% rename from tools/tune/tdfb/example_pass_config.m rename to src/audio/tdfb/tune/sof_example_pass_config.m index 34cba3a07933..d3e1fabc39b9 100644 --- a/tools/tune/tdfb/example_pass_config.m +++ b/src/audio/tdfb/tune/sof_example_pass_config.m @@ -1,4 +1,4 @@ -function example_pass_config() +function sof_example_pass_config() % example_pass_config() % @@ -13,7 +13,7 @@ function example_pass_config() % Author: Seppo Ingalsuo % Setup for two channels -bf = bf_defaults(); +bf = sof_bf_defaults(); bf.input_channel_select = [0 1]; % Input two channels bf.output_channel_mix = [1 2]; % Filter1 -> ch0, filter2 -> ch1 bf.output_stream_mix = [0 0]; % Mix both filters to stream 0 @@ -27,13 +27,13 @@ function example_pass_config() bf.w = [1 0 0 0; 1 0 0 0]'; % Two FIR filters with first tap set to one % Files -bf.export_note = 'Exported with script example_pass_config.m'; -bf.export_howto = 'cd tools/tune/tdfb; octave --no-window-system example_pass_config.m'; +bf.export_note = 'Exported with script sof_example_pass_config.m'; +bf.export_howto = 'cd tools/tune/tdfb; octave --no-window-system sof_example_pass_config.m'; bf.sofctl3_fn = fullfile(bf.sofctl3_path, 'coef_line2_pass.txt'); bf.tplg1_fn = fullfile(bf.tplg1_path, 'coef_line2_pass.m4'); bf.sofctl4_fn = fullfile(bf.sofctl4_path, 'line2_pass.txt'); bf.tplg2_fn = fullfile(bf.tplg2_path, 'line2_pass.conf'); -bf_export(bf); +sof_bf_export(bf); % Setup for four channels bf.input_channel_select = [0 1 2 3]; % Input two channels @@ -51,6 +51,6 @@ function example_pass_config() bf.tplg1_fn = fullfile(bf.tplg1_path, 'coef_line4_pass.m4'); bf.sofctl4_fn = fullfile(bf.sofctl4_path, 'line4_pass.txt'); bf.tplg2_fn = fullfile(bf.tplg2_path, 'line4_pass.conf'); -bf_export(bf); +sof_bf_export(bf); end diff --git a/tools/tune/tdfb/example_two_beams.m b/src/audio/tdfb/tune/sof_example_two_beams.m similarity index 90% rename from tools/tune/tdfb/example_two_beams.m rename to src/audio/tdfb/tune/sof_example_two_beams.m index 96f4f9554041..dc081593fb44 100644 --- a/tools/tune/tdfb/example_two_beams.m +++ b/src/audio/tdfb/tune/sof_example_two_beams.m @@ -1,4 +1,4 @@ -function example_two_beams() +function sof_example_two_beams() % example_two_beams() % @@ -129,7 +129,7 @@ function example_two_beams() function line2_two_beams(fs, d, a1, a2, fn, add_beam_off); % Get defaults -bf1 = bf_defaults(); +bf1 = sof_bf_defaults(); bf1.fs = fs; bf1.beam_off_defined = add_beam_off; @@ -151,8 +151,8 @@ function example_two_beams() bf1.output_stream_mix = [0 0]; % Mix both filters to stream 0 bf1.num_output_channels = 2; bf1.fn = 10; % Figs 10.... -bf1 = bf_filenames_helper(bf1); -bf1 = bf_design(bf1); +bf1 = sof_bf_filenames_helper(bf1); +bf1 = sof_bf_design(bf1); % Design beamformer 2 (right) bf2.steer_az = a2; @@ -163,27 +163,27 @@ function example_two_beams() bf2.output_stream_mix = [0 0]; % Mix both filters to stream 0 bf2.num_output_channels = 2; bf2.fn = 20; % Figs 20.... -bf2 = bf_filenames_helper(bf2); -bf2 = bf_design(bf2); +bf2 = sof_bf_filenames_helper(bf2); +bf2 = sof_bf_design(bf2); % Merge two beamformers into single description, set file names -bfm = bf_merge(bf1, bf2); +bfm = sof_bf_merge(bf1, bf2); bfm.sofctl3_fn = fullfile(bfm.sofctl3_path, fn.sofctl3_fn); bfm.tplg1_fn = fullfile(bfm.tplg1_path, fn.tplg1_fn); bfm.sofctl4_fn = fullfile(bfm.sofctl4_path, fn.sofctl4_fn); bfm.tplg2_fn = fullfile(bfm.tplg2_path, fn.tplg2_fn); % Export files for topology and sof-ctl -bfm.export_note = 'Created with script example_two_beams.m'; -bfm.export_howto = 'cd tools/tune/tdfb; matlab -nodisplay -nosplash -nodesktop -r example_two_beams'; -bf_export(bfm); +bfm.export_note = 'Created with script sof_example_two_beams.m'; +bfm.export_howto = 'cd tools/tune/tdfb; matlab -nodisplay -nosplash -nodesktop -r sof_example_two_beams'; +sof_bf_export(bfm); end function line4_two_beams(fs, d, a1, a2, fn, add_beam_off); % Get defaults -bf1 = bf_defaults(); +bf1 = sof_bf_defaults(); bf1.fs = fs; bf1.beam_off_defined = add_beam_off; @@ -204,8 +204,8 @@ function example_two_beams() bf1.output_stream_mix = [0 0 0 0]; % Mix filters to stream 0 bf1.num_output_channels = 2; bf1.fn = 10; % Figs 10.... -bf1 = bf_filenames_helper(bf1); -bf1 = bf_design(bf1); +bf1 = sof_bf_filenames_helper(bf1); +bf1 = sof_bf_design(bf1); % Design beamformer 2 (right) bf2.steer_az = a2; @@ -216,27 +216,27 @@ function example_two_beams() bf2.output_stream_mix = [0 0 0 0]; % Mix filters to stream 0 bf2.num_output_channels = 2; bf2.fn = 20; % Figs 20.... -bf2 = bf_filenames_helper(bf2); -bf2 = bf_design(bf2); +bf2 = sof_bf_filenames_helper(bf2); +bf2 = sof_bf_design(bf2); % Merge two beamformers into single description, set file names -bfm = bf_merge(bf1, bf2); +bfm = sof_bf_merge(bf1, bf2); bfm.sofctl3_fn = fullfile(bfm.sofctl3_path, fn.sofctl3_fn); bfm.tplg1_fn = fullfile(bfm.tplg1_path, fn.tplg1_fn); bfm.sofctl4_fn = fullfile(bfm.sofctl4_path, fn.sofctl4_fn); bfm.tplg2_fn = fullfile(bfm.tplg2_path, fn.tplg2_fn); % Export files for topology and sof-ctl -bfm.export_note = 'Created with script example_two_beams.m'; -bfm.export_howto = 'cd tools/tune/tdfb; matlab -nodisplay -nosplash -nodesktop -r example_two_beams'; -bf_export(bfm); +bfm.export_note = 'Created with script sof_example_two_beams.m'; +bfm.export_howto = 'cd tools/tune/tdfb; matlab -nodisplay -nosplash -nodesktop -r sof_example_two_beams'; +sof_bf_export(bfm); end function circular_two_beams(fs, r, n, a1, a2, fn, add_beam_off) % Get defaults and common settings -bf1 = bf_defaults(); +bf1 = sof_bf_defaults(); bf1.beam_off_defined = add_beam_off; bf1.fs = fs; bf1.mic_r = r; @@ -256,34 +256,34 @@ function circular_two_beams(fs, r, n, a1, a2, fn, add_beam_off) bf1.output_channel_mix_beam_off(n) = 2; % Mic2 to channel 2^1 bf1.output_channel_mix = 1 * ones(1, n); % Mix all filters to channel 1 bf1.steer_az = a1; -bf1 = bf_filenames_helper(bf1); -bf1 = bf_design(bf1); +bf1 = sof_bf_filenames_helper(bf1); +bf1 = sof_bf_design(bf1); % Design beamformer 2 (right) bf2.output_channel_mix_beam_off = zeros(1, n); % No channels input bf2.output_channel_mix = 2 * ones(1, n); % Mix all filters to channel 2 bf2.steer_az = a2; -bf2 = bf_filenames_helper(bf2); -bf2 = bf_design(bf2); +bf2 = sof_bf_filenames_helper(bf2); +bf2 = sof_bf_design(bf2); % Merge two beamformers into single description, set file names -bfm = bf_merge(bf1, bf2); +bfm = sof_bf_merge(bf1, bf2); bfm.sofctl3_fn = fullfile(bfm.sofctl3_path, fn.sofctl3_fn); bfm.tplg1_fn = fullfile(bfm.tplg1_path, fn.tplg1_fn); bfm.sofctl4_fn = fullfile(bfm.sofctl4_path, fn.sofctl4_fn); bfm.tplg2_fn = fullfile(bfm.tplg2_path, fn.tplg2_fn); % Export files for topology and sof-ctl -bfm.export_note = 'Created with script example_two_beams.m'; -bfm.export_howto = 'cd tools/tune/tdfb; matlab -nodisplay -nosplash -nodesktop -r example_two_beams'; -bf_export(bfm); +bfm.export_note = 'Created with script sof_example_two_beams.m'; +bfm.export_howto = 'cd tools/tune/tdfb; matlab -nodisplay -nosplash -nodesktop -r sof_example_two_beams'; +sof_bf_export(bfm); end function line_xyz(fs) % Get defaults -bf1 = bf_defaults(); +bf1 = sof_bf_defaults(); bf1.fs = fs; bf1.beta = 5; @@ -330,8 +330,8 @@ function line_xyz(fs) bf1.output_stream_mix = [0 0 0 0]; % Mix filters to stream 0 bf1.num_output_channels = 2; % Stereo bf1.fn = 10; % Figs 10.... -bf1 = bf_filenames_helper(bf1); -bf1 = bf_design(bf1); +bf1 = sof_bf_filenames_helper(bf1); +bf1 = sof_bf_design(bf1); % Design beamformer 2 (right) bf2.steer_az = a2; @@ -342,19 +342,19 @@ function line_xyz(fs) bf2.output_stream_mix = [0 0 0 0]; % Mix filters to stream 0 bf2.num_output_channels = 2; % Stereo bf2.fn = 20; % Figs 20.... -bf2 = bf_filenames_helper(bf2); -bf2 = bf_design(bf2); +bf2 = sof_bf_filenames_helper(bf2); +bf2 = sof_bf_design(bf2); % Merge two beamformers into single description, set file names -bfm = bf_merge(bf1, bf2); +bfm = sof_bf_merge(bf1, bf2); bfm.sofctl3_fn = fullfile(bfm.sofctl3_path, sofctl3_fn); bfm.tplg1_fn = fullfile(bfm.tplg1_path, tplg1_fn); bfm.sofctl4_fn = fullfile(bfm.sofctl4_path, sofctl4_fn); bfm.tplg2_fn = fullfile(bfm.tplg2_path, tplg2_fn); % Export files for topology and sof-ctl -bfm.export_note = 'Created with script example_two_beams.m'; -bfm.export_howto = 'cd tools/tune/tdfb; matlab -nodisplay -nosplash -nodesktop -r example_two_beams'; -bf_export(bfm); +bfm.export_note = 'Created with script sof_example_two_beams.m'; +bfm.export_howto = 'cd tools/tune/tdfb; matlab -nodisplay -nosplash -nodesktop -r sof_example_two_beams'; +sof_bf_export(bfm); end