Skip to content

Commit 2703a3e

Browse files
committed
Audio: TDFB: Tune: Add export of beamformer blobs for ALSA UCM
This change adds generate of multi-microphone beamformer blobs to apply with UCM2 rules for SOF. Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent fc21c47 commit 2703a3e

File tree

8 files changed

+54
-36
lines changed

8 files changed

+54
-36
lines changed

src/audio/tdfb/tune/sof_bf_defaults.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
bf.array_angle = [0 0 0]; % Array rotation angles for xyz
2020
bf.tplg_fn = '';
2121
bf.sofctl_fn = '';
22+
bf.ucmbin3_fn = '';
23+
bf.ucmbin4_fn = '';
2224
sof_tools = '../../../../tools';
2325
bf.tplg1_path = fullfile(sof_tools, 'topology/topology1/m4/tdfb');
2426
bf.tplg2_path = fullfile(sof_tools, 'topology/topology2/include/components/tdfb');

src/audio/tdfb/tune/sof_bf_export.m

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
% Inputs
44
% bf.sofctl3_fn .... filename of ascii text format blob
55
% bf.sofctl4_fn .... filename of ascii text format blob
6+
% bf.ucmbin3_fn .... filename of binary format blob for UCM (IPC3)
7+
% bf.ucmbin4_fn .... filename of binary format blob for UCM (IPC4)
68
% bf.tplg1_fn ...... filename of topology m4 format blob
79
% bf.tplg2_fn ...... filename of topology m4 format blob
810
% bf ............... the design procedure output
@@ -116,6 +118,18 @@
116118
tplg2_write(bf.tplg2_fn, bp4, "tdfb_config", export_note, bf.export_howto);
117119
end
118120

121+
if ~isempty(bf.ucmbin3_fn)
122+
fprintf(1, 'Exporting to %s\n', bf.ucmbin3_fn);
123+
mkdir_check(bf.sofctl3_path);
124+
sof_ucm_blob_write(bf.ucmbin3_fn, bp3);
125+
end
126+
127+
if ~isempty(bf.ucmbin4_fn)
128+
fprintf(1, 'Exporting to %s\n', bf.ucmbin4_fn);
129+
mkdir_check(bf.sofctl4_path);
130+
sof_ucm_blob_write(bf.ucmbin4_fn, bp4);
131+
end
132+
119133
sof_bf_paths(false);
120134

121135
end

src/audio/tdfb/tune/sof_bf_filenames_helper.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@
5353
bf.sofctl3_fn = fullfile(bf.sofctl3_path, sprintf('coef_%s.txt', idstr));
5454
bf.tplg1_fn = fullfile(bf.tplg1_path, sprintf('coef_%s.m4', idstr));
5555
bf.sofctl4_fn = fullfile(bf.sofctl4_path, sprintf('%s.txt', idstr));
56+
bf.ucmbin3_fn = fullfile(bf.sofctl3_path, sprintf('%s.bin', idstr));
57+
bf.ucmbin4_fn = fullfile(bf.sofctl4_path, sprintf('%s.bin', idstr));
5658
bf.tplg2_fn = fullfile(bf.tplg2_path, sprintf('%s.conf', idstr));
5759

5860

src/audio/tdfb/tune/sof_bf_line2_two_beams.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ function sof_bf_line2_two_beams(fs, d, a1, a2, fn, prm)
6363
bfm.sofctl3_fn = fullfile(bfm.sofctl3_path, fn.sofctl3_fn);
6464
bfm.tplg1_fn = fullfile(bfm.tplg1_path, fn.tplg1_fn);
6565
bfm.sofctl4_fn = fullfile(bfm.sofctl4_path, fn.sofctl4_fn);
66+
bfm.ucmbin3_fn = fullfile(bfm.sofctl3_path, fn.ucmbin3_fn);
67+
bfm.ucmbin4_fn = fullfile(bfm.sofctl4_path, fn.ucmbin4_fn);
6668
bfm.tplg2_fn = fullfile(bfm.tplg2_path, fn.tplg2_fn);
6769

6870
% Export files for topology and sof-ctl

src/audio/tdfb/tune/sof_bf_line4_two_beams.m

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ function sof_bf_line4_two_beams(fs, d, a1, a2, fn, prm)
6363
bfm.sofctl3_fn = fullfile(bfm.sofctl3_path, fn.sofctl3_fn);
6464
bfm.tplg1_fn = fullfile(bfm.tplg1_path, fn.tplg1_fn);
6565
bfm.sofctl4_fn = fullfile(bfm.sofctl4_path, fn.sofctl4_fn);
66+
bfm.ucmbin3_fn = fullfile(bfm.sofctl3_path, fn.ucmbin3_fn);
67+
bfm.ucmbin4_fn = fullfile(bfm.sofctl4_path, fn.ucmbin4_fn);
6668
bfm.tplg2_fn = fullfile(bfm.tplg2_path, fn.tplg2_fn);
6769

6870
% Export files for topology and sof-ctl

src/audio/tdfb/tune/sof_example_pass_config.m

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ function sof_example_pass_config()
3434
bf.sofctl3_fn = fullfile(bf.sofctl3_path, 'coef_line2_pass.txt');
3535
bf.tplg1_fn = fullfile(bf.tplg1_path, 'coef_line2_pass.m4');
3636
bf.sofctl4_fn = fullfile(bf.sofctl4_path, 'line2_pass.txt');
37+
bf.ucmbin3_fn = fullfile(bf.sofctl3_path, 'line2_pass.bin');
38+
bf.ucmbin4_fn = fullfile(bf.sofctl4_path, 'line2_pass.bin');
3739
bf.tplg2_fn = fullfile(bf.tplg2_path, 'line2_pass.conf');
3840
sof_bf_export(bf);
3941

@@ -52,6 +54,8 @@ function sof_example_pass_config()
5254
bf.sofctl3_fn = fullfile(bf.sofctl3_path, 'coef_line4_pass.txt');
5355
bf.tplg1_fn = fullfile(bf.tplg1_path, 'coef_line4_pass.m4');
5456
bf.sofctl4_fn = fullfile(bf.sofctl4_path, 'line4_pass.txt');
57+
bf.ucmbin3_fn = fullfile(bf.sofctl3_path, 'line4_pass.bin');
58+
bf.ucmbin4_fn = fullfile(bf.sofctl4_path, 'line4_pass.bin');
5559
bf.tplg2_fn = fullfile(bf.tplg2_path, 'line4_pass.conf');
5660
sof_bf_export(bf);
5761

@@ -72,6 +76,8 @@ function sof_example_pass_config()
7276
bf.sofctl3_fn = fullfile(bf.sofctl3_path, 'coef_line4to2_pass.txt');
7377
bf.tplg1_fn = fullfile(bf.tplg1_path, 'coef_line4to2_pass.m4');
7478
bf.sofctl4_fn = fullfile(bf.sofctl4_path, 'line4to2_pass.txt');
79+
bf.ucmbin3_fn = fullfile(bf.sofctl3_path, 'line4to2_pass.bin');
80+
bf.ucmbin4_fn = fullfile(bf.sofctl4_path, 'line4to2_pass.bin');
7581
bf.tplg2_fn = fullfile(bf.tplg2_path, 'line4to2_pass.conf');
7682
sof_bf_export(bf);
7783

src/audio/tdfb/tune/sof_example_two_beams.m

Lines changed: 22 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -29,65 +29,37 @@ function sof_example_two_beams()
2929
for fs = [16e3 48e3]
3030
%% Close all plots to avoid issues with large number of windows
3131
close all;
32+
a1 = az; % Azimuth +az deg
33+
a2 = -az; % Azimuth -az deg
3234

3335
%% 2 mic 50 mm array
34-
fn.tplg1_fn = sprintf('coef_line2_50mm_pm%sdeg_%dkhz.m4', azstr, fs/1e3);
35-
fn.sofctl3_fn = sprintf('coef_line2_50mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
36-
fn.tplg2_fn = sprintf('line2_50mm_pm%sdeg_%dkhz.conf', azstr, fs/1e3);
37-
fn.sofctl4_fn = sprintf('line2_50mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
3836
d = 50e-3; % 50 mm spacing
39-
a1 = az; % Azimuth +az deg
40-
a2 = -az; % Azimuth -az deg
37+
fn = export_names_helper('line2', azstr, d, fs);
4138
sof_bf_line2_two_beams(fs, d, a1, a2, fn, prm);
4239

4340
%% 2 mic 68 mm array
44-
fn.tplg1_fn = sprintf('coef_line2_68mm_pm%sdeg_%dkhz.m4', azstr, fs/1e3);
45-
fn.sofctl3_fn = sprintf('coef_line2_68mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
46-
fn.tplg2_fn = sprintf('line2_68mm_pm%sdeg_%dkhz.conf', azstr, fs/1e3);
47-
fn.sofctl4_fn = sprintf('line2_68mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
4841
d = 68e-3; % 68 mm spacing
49-
a1 = az; % Azimuth +az deg
50-
a2 = -az; % Azimuth -az deg
42+
fn = export_names_helper('line2', azstr, d, fs);
5143
sof_bf_line2_two_beams(fs, d, a1, a2, fn, prm);
5244

5345
%% 2 mic 73.5 mm array
54-
fn.tplg1_fn = sprintf('coef_line2_74mm_pm%sdeg_%dkhz.m4', azstr, fs/1e3);
55-
fn.sofctl3_fn = sprintf('coef_line2_74mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
56-
fn.tplg2_fn = sprintf('line2_74mm_pm%sdeg_%dkhz.conf', azstr, fs/1e3);
57-
fn.sofctl4_fn = sprintf('line2_74mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
5846
d = 73.5e-3; % 73.5 mm spacing
59-
a1 = az; % Azimuth +az deg
60-
a2 = -az; % Azimuth -az deg
47+
fn = export_names_helper('line2', azstr, d, fs);
6148
sof_bf_line2_two_beams(fs, d, a1, a2, fn, prm);
6249

6350
%% 4 mic 28 mm spaced array
64-
fn.tplg1_fn = sprintf('coef_line4_28mm_pm%sdeg_%dkhz.m4', azstr, fs/1e3);
65-
fn.sofctl3_fn = sprintf('coef_line4_28mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
66-
fn.tplg2_fn = sprintf('line4_28mm_pm%sdeg_%dkhz.conf', azstr, fs/1e3);
67-
fn.sofctl4_fn = sprintf('line4_28mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
6851
d = 28e-3; % 28 mm spacing
69-
a1 = az; % Azimuth +az deg
70-
a2 = -az; % Azimuth -az deg
52+
fn = export_names_helper('line4', azstr, d, fs);
7153
sof_bf_line4_two_beams(fs, d, a1, a2, fn, prm);
7254

7355
%% 4 mic 68 mm spaced array
74-
fn.tplg1_fn = sprintf('coef_line4_68mm_pm%sdeg_%dkhz.m4', azstr, fs/1e3);
75-
fn.sofctl3_fn = sprintf('coef_line4_68mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
76-
fn.tplg2_fn = sprintf('line4_68mm_pm%sdeg_%dkhz.conf', azstr, fs/1e3);
77-
fn.sofctl4_fn = sprintf('line4_68mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
7856
d = 68e-3; % 68 mm spacing
79-
a1 = az; % Azimuth +az deg
80-
a2 = -az; % Azimuth -az deg
57+
fn = export_names_helper('line4', azstr, d, fs);
8158
sof_bf_line4_two_beams(fs, d, a1, a2, fn, prm);
8259

8360
%% 4 mic 78 mm spaced array
84-
fn.tplg1_fn = sprintf('coef_line4_78mm_pm%sdeg_%dkhz.m4', azstr, fs/1e3);
85-
fn.sofctl3_fn = sprintf('coef_line4_78mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
86-
fn.tplg2_fn = sprintf('line4_78mm_pm%sdeg_%dkhz.conf', azstr, fs/1e3);
87-
fn.sofctl4_fn = sprintf('line4_78mm_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
8861
d = 78e-3; % 78 mm spacing
89-
a1 = az; % Azimuth +az deg
90-
a2 = -az; % Azimuth -az deg
62+
fn = export_names_helper('line4', azstr, d, fs);
9163
sof_bf_line4_two_beams(fs, d, a1, a2, fn, prm);
9264
end
9365

@@ -268,3 +240,17 @@ function line_xyz(fs)
268240
sof_bf_export(bfm);
269241

270242
end
243+
244+
function fn = export_names_helper(arrayname, azstr, d, fs)
245+
246+
mmstr = sprintf('%dmm', round(d * 1e3));
247+
fsstr = sprintf('%dkhz', round(fs/1e3));
248+
fn.tplg1_fn = sprintf('coef_%s_%s_pm%sdeg_%s.m4', arrayname, mmstr, azstr, fsstr);
249+
fn.tplg2_fn = sprintf('%s_%s_pm%sdeg_%s.conf', arrayname, mmstr, azstr, fsstr);
250+
fn.sofctl3_fn = sprintf('%s_%s_pm%sdeg_%s.txt', arrayname, mmstr, azstr, fsstr);
251+
fn.sofctl4_fn = sprintf('%s_%s_pm%sdeg_%s.txt', arrayname, mmstr, azstr, fsstr);
252+
fn.ucmbin3_fn = sprintf('%s_%s_pm%sdeg_%s.bin', arrayname, mmstr, azstr, fsstr);
253+
fn.ucmbin4_fn = sprintf('%s_%s_pm%sdeg_%s.bin', arrayname, mmstr, azstr, fsstr);
254+
255+
end
256+

src/audio/tdfb/tune/sof_example_two_beams_default.m

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@ function sof_example_two_beams_default()
3535
fn.sofctl3_fn = sprintf('coef_line2_generic_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
3636
fn.tplg2_fn = sprintf('line2_generic_pm%sdeg_%dkhz.conf', azstr, fs/1e3);
3737
fn.sofctl4_fn = sprintf('line2_generic_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
38+
fn.ucmbin3_fn = sprintf('line2_generic_pm%sdeg_%dkhz.bin', azstr, fs/1e3);
39+
fn.ucmbin4_fn = sprintf('line2_generic_pm%sdeg_%dkhz.bin', azstr, fs/1e3);
3840
d = 50e-3; % 50 mm spacing
3941
a1 = az; % Azimuth +az deg
4042
a2 = -az; % Azimuth -az deg
@@ -45,6 +47,8 @@ function sof_example_two_beams_default()
4547
fn.sofctl3_fn = sprintf('coef_line4_generic_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
4648
fn.tplg2_fn = sprintf('line4_generic_pm%sdeg_%dkhz.conf', azstr, fs/1e3);
4749
fn.sofctl4_fn = sprintf('line4_generic_pm%sdeg_%dkhz.txt', azstr, fs/1e3);
50+
fn.ucmbin3_fn = sprintf('line4_generic_pm%sdeg_%dkhz.bin', azstr, fs/1e3);
51+
fn.ucmbin4_fn = sprintf('line4_generic_pm%sdeg_%dkhz.bin', azstr, fs/1e3);
4852
d = 40e-3; % 40 mm spacing
4953
a1 = az; % Azimuth +az deg
5054
a2 = -az; % Azimuth -az deg

0 commit comments

Comments
 (0)