Skip to content

Commit b55cb64

Browse files
singalsulgirdwood
authored andcommitted
Audio: EQIIR: Tune: Prefix top level functions with sof_
Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
1 parent 73de9de commit b55cb64

36 files changed

Lines changed: 231 additions & 217 deletions

src/audio/eq_iir/tune/cmocka_data_eq_fir.m renamed to src/audio/eq_iir/tune/sof_cmocka_data_eq_fir.m

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,21 @@
77
%
88
% Copyright (c) 2021, Intel Corporation. All rights reserved.
99

10-
function cmocka_data_eq_fir()
10+
function sof_cmocka_data_eq_fir()
1111

1212
% Output files and paths
13-
chirp_fn = '../../../test/cmocka/include/cmocka_chirp_2ch.h';
14-
ref_fn = '../../../test/cmocka/src/audio/eq_fir/cmocka_fir_ref.h';
15-
coef_fn = '../../../test/cmocka/src/audio/eq_fir/cmocka_fir_coef_2ch.h';
13+
sof_cmocka = '../../../../test/cmocka';
14+
15+
chirp_fn = fullfile(sof_cmocka, 'include/cmocka_chirp_2ch.h');
16+
ref_fn = fullfile(sof_cmocka, 'src/audio/eq_fir/cmocka_fir_ref.h');
17+
coef_fn = fullfile(sof_cmocka, 'src/audio/eq_fir/cmocka_fir_coef_2ch.h');
1618

1719
% Input data
1820
fs = 48e3;
1921
t = 100e-3;
2022
scale = 2^31;
2123
[x, yi] = get_chirp(fs, t);
22-
export_c_int32t(chirp_fn, 'chirp_2ch', 'CHIRP_2CH_LENGTH',yi)
24+
sof_export_c_int32t(chirp_fn, 'chirp_2ch', 'CHIRP_2CH_LENGTH',yi)
2325

2426
% Compute a test EQ
2527
eq = test_response(coef_fn, 'fir_coef_2ch', fs);
@@ -28,7 +30,7 @@ function cmocka_data_eq_fir()
2830
ref(:,1) = filter(eq.b_fir, 1, x(:,1));
2931
ref(:,2) = filter(eq.b_fir, 1, x(:,2));
3032
refi = scale_saturate(ref, scale);
31-
export_c_int32t(ref_fn, 'fir_ref_2ch', 'FIR_REF_2CH_LENGTH', refi)
33+
sof_export_c_int32t(ref_fn, 'fir_ref_2ch', 'FIR_REF_2CH_LENGTH', refi)
3234

3335
figure;
3436
plot(yi/scale)
@@ -82,23 +84,24 @@ function cmocka_data_eq_fir()
8284
function eq = test_response(fn, vn, fs)
8385

8486
%% Get EQ
85-
blob_fn = '../../ctl/eq_fir_loudness.txt';
86-
eq = eq_blob_plot(blob_fn, 'fir', fs, [], 0);
87+
sof_ctl = '../../../../tools/ctl';
88+
blob_fn = fullfile(sof_ctl, 'ipc3/eq_fir_loudness.txt');
89+
eq = sof_eq_blob_plot(blob_fn, 'fir', fs, [], 0);
8790

8891
%% Quantize and pack filter coefficients plus shifts etc.
89-
bq = eq_fir_blob_quant(eq.b_fir);
92+
bq = sof_eq_fir_blob_quant(eq.b_fir);
9093

9194
%% Build blob
9295
channels_in_config = 2; % Setup max 2 channels EQ
9396
assign_response = [0 0]; % Same response for L and R
9497
num_responses = 1; % One response
95-
bm = eq_fir_blob_merge(channels_in_config, ...
98+
bm = sof_eq_fir_blob_merge(channels_in_config, ...
9699
num_responses, ...
97100
assign_response, ...
98101
bq);
99102

100103
%% Pack and write file
101-
bp = eq_fir_blob_pack(bm);
102-
export_c_eq_uint32t(fn, bp, vn, 0);
104+
bp = sof_eq_fir_blob_pack(bm);
105+
sof_export_c_eq_uint32t(fn, bp, vn, 0);
103106

104107
end

src/audio/eq_iir/tune/cmocka_data_eq_iir.m renamed to src/audio/eq_iir/tune/sof_cmocka_data_eq_iir.m

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,20 @@
77
%
88
% Copyright (c) 2021, Intel Corporation. All rights reserved.
99

10-
function cmocka_data_eq_iir()
10+
function sof_cmocka_data_eq_iir()
1111

1212
% Output files and paths
13-
chirp_fn = '../../../test/cmocka/include/cmocka_chirp_2ch.h';
14-
ref_fn = '../../../test/cmocka/src/audio/eq_iir/cmocka_chirp_iir_ref_2ch.h';
15-
coef_fn = '../../../test/cmocka/src/audio/eq_iir/cmocka_iir_coef_2ch.h';
13+
sof_cmocka = '../../../../test/cmocka';
14+
chirp_fn = fullfile(sof_cmocka, 'include/cmocka_chirp_2ch.h');
15+
ref_fn = fullfile(sof_cmocka, 'src/audio/eq_iir/cmocka_chirp_iir_ref_2ch.h');
16+
coef_fn = fullfile(sof_cmocka, 'src/audio/eq_iir/cmocka_iir_coef_2ch.h');
1617

1718
% Input data
1819
fs = 48e3;
1920
t = 100e-3;
2021
scale = 2^31;
2122
[x, yi] = get_chirp(fs, t);
22-
export_c_int32t(chirp_fn, 'chirp_2ch', 'CHIRP_2CH_LENGTH',yi)
23+
sof_export_c_int32t(chirp_fn, 'chirp_2ch', 'CHIRP_2CH_LENGTH',yi)
2324

2425
% Compute a test EQ
2526
eq = test_response(coef_fn, 'iir_coef_2ch', fs);
@@ -30,7 +31,7 @@ function cmocka_data_eq_iir()
3031
ref(:,2) = filter(b, a, x(:,2));
3132
[b, a] = zp2tf(eq.p_z, eq.p_p, eq.p_k);
3233
refi = scale_saturate(ref, scale);
33-
export_c_int32t(ref_fn, 'chirp_iir_ref_2ch', 'CHIRP_IIR_REF_2CH_LENGTH', refi)
34+
sof_export_c_int32t(ref_fn, 'chirp_iir_ref_2ch', 'CHIRP_IIR_REF_2CH_LENGTH', refi)
3435

3536
figure;
3637
plot(yi/scale)
@@ -84,7 +85,7 @@ function cmocka_data_eq_iir()
8485
function eq = test_response(fn, vn, fs)
8586

8687
%% Get defaults for equalizer design
87-
eq = eq_defaults();
88+
eq = sof_eq_defaults();
8889
eq.fs = fs;
8990
eq.enable_iir = 1;
9091
eq.iir_norm_type = 'peak';
@@ -99,25 +100,25 @@ function cmocka_data_eq_iir()
99100
];
100101

101102
%% Design EQ
102-
eq = eq_compute(eq);
103+
eq = sof_eq_compute(eq);
103104

104105
%% Plot
105-
eq_plot(eq);
106+
sof_eq_plot(eq);
106107

107108
%% Quantize and pack filter coefficients plus shifts etc.
108-
bq = eq_iir_blob_quant(eq.p_z, eq.p_p, eq.p_k);
109+
bq = sof_eq_iir_blob_quant(eq.p_z, eq.p_p, eq.p_k);
109110

110111
%% Build blob
111112
channels_in_config = 2; % Setup max 2 channels EQ
112113
assign_response = [0 0]; % Same response for L and R
113114
num_responses = 1; % One response
114-
bm = eq_iir_blob_merge(channels_in_config, ...
115+
bm = sof_eq_iir_blob_merge(channels_in_config, ...
115116
num_responses, ...
116117
assign_response, ...
117118
bq);
118119

119120
%% Pack and write file
120-
bp = eq_iir_blob_pack(bm);
121-
export_c_eq_uint32t(fn, bp, vn, 0);
121+
bp = sof_eq_iir_blob_pack(bm);
122+
sof_export_c_eq_uint32t(fn, bp, vn, 0);
122123

123124
end
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [am, offs, p] = eq_align(f, m, f_align, m_align)
1+
function [am, offs, p] = sof_eq_align(f, m, f_align, m_align)
22

33
%% [am, offs, p] = eq_align(f, m, f_align, m_align)
44
%

src/audio/eq_iir/tune/eq_alsactl_write.m renamed to src/audio/eq_iir/tune/sof_eq_alsactl_write.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function eq_alsactl_write(fn, blob8)
1+
function sof_eq_alsactl_write(fn, blob8)
22

33
%%
44
% Copyright (c) 2016, Intel Corporation
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
function eq = eq_blob_plot(blobfn, eqtype, fs, f, doplot)
1+
function eq = sof_eq_blob_plot(blobfn, eqtype, fs, f, doplot)
22

3-
% eq = eq_blob_plot(blobfn, eqtype, fs, f, doplot)
3+
% eq = sof_eq_blob_plot(blobfn, eqtype, fs, f, doplot)
44
%
55
% Plot frequency response of IIR or FIR EQ coefficients blob
66
%
@@ -20,9 +20,9 @@
2020
% eq.a - IIR denominator coefficients
2121
%
2222
% Examples
23-
% eq_blob_plot('../../topology/topology1/m4/eq_iir_coef_loudness.m4', 'iir');
24-
% eq_blob_plot('../../ctl/eq_fir_mid.bin', 'fir');
25-
% eq_blob_plot('../../ctl/eq_iir_bassboost.txt', 'iir');
23+
% sof_eq_blob_plot('../../topology/topology1/m4/eq_iir_coef_loudness.m4', 'iir');
24+
% sof_eq_blob_plot('../../ctl/eq_fir_mid.bin', 'fir');
25+
% sof_eq_blob_plot('../../ctl/eq_iir_bassboost.txt', 'iir');
2626

2727
% SPDX-License-Identifier: BSD-3-Clause
2828
%
@@ -62,7 +62,7 @@
6262
end
6363

6464
%% Read blob as 32 bit integers
65-
blob = eq_blob_read(blobfn);
65+
blob = sof_eq_blob_read(blobfn);
6666

6767
%% Group delay with grpdelay() is not working in Octave
6868
do_group_delay = ~exist('OCTAVE_VERSION', 'builtin');
@@ -72,10 +72,10 @@
7272
eq.gd = [];
7373
switch lower(eqtype)
7474
case 'fir'
75-
hd = eq_fir_blob_decode(blob);
75+
hd = sof_eq_fir_blob_decode(blob);
7676
eq.m = zeros(length(eq.f), hd.channels_in_config);
7777
for i = 1:hd.channels_in_config
78-
decoded_eq = eq_fir_blob_decode(blob, hd.assign_response(i));
78+
decoded_eq = sof_eq_fir_blob_decode(blob, hd.assign_response(i));
7979
eq.b_fir = decoded_eq.b;
8080
eq.b = 1;
8181
eq.a = 1;
@@ -88,10 +88,10 @@
8888
end
8989

9090
case 'iir'
91-
hd = eq_iir_blob_decode(blob);
91+
hd = sof_eq_iir_blob_decode(blob);
9292
eq.m = zeros(length(eq.f), hd.channels_in_config);
9393
for i = 1:hd.channels_in_config
94-
decoded_eq = eq_iir_blob_decode(blob, hd.assign_response(i));
94+
decoded_eq = sof_eq_iir_blob_decode(blob, hd.assign_response(i));
9595
eq.b = decoded_eq.b;
9696
eq.a = decoded_eq.a;
9797
h = freqz(eq.b, eq.a, eq.f, fs);
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function blob = eq_blob_read(blobfn, fntype)
1+
function blob = sof_eq_blob_read(blobfn, fntype)
22

33
% SPDX-License-Identifier: BSD-3-Clause
44
%
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function qc = eq_coef_quant(c, bits, qf)
1+
function qc = sof_eq_coef_quant(c, bits, qf)
22

33
%%
44
% Copyright (c) 2016, Intel Corporation
Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function eq = eq_compute( eq )
1+
function eq = sof_eq_compute( eq )
22

33
%%
44
% Copyright (c) 2016, Intel Corporation
@@ -42,20 +42,20 @@
4242
%% Define target (e.g. speaker) response as parametric filter. This could also
4343
% be numerical data interpolated to the grid.
4444
if length(eq.parametric_target_response) > 0
45-
[eq.t_z, eq.t_p, eq.t_k] = eq_define_parametric_eq( ...
45+
[eq.t_z, eq.t_p, eq.t_k] = sof_eq_define_parametric_eq( ...
4646
eq.parametric_target_response, eq.fs);
47-
eq.t_db = eq_compute_response(eq.t_z, eq.t_p, eq.t_k, eq.f, eq.fs);
47+
eq.t_db = sof_eq_compute_response(eq.t_z, eq.t_p, eq.t_k, eq.f, eq.fs);
4848
end
4949

5050
if isempty(eq.t_db)
5151
fprintf('Warning: No target response is defined.\n');
5252
end
5353

5454
%% Align responses at some frequency and dB
55-
[eq.m_db_s, offs] = eq_align(eq.f, eq.m_db_s, eq.f_align, eq.db_align);
55+
[eq.m_db_s, offs] = sof_eq_align(eq.f, eq.m_db_s, eq.f_align, eq.db_align);
5656
eq.raw_m_db = eq.raw_m_db + offs;
5757
eq.m_db = eq.m_db + offs;
58-
eq.t_db = eq_align(eq.f, eq.t_db, eq.f_align, eq.db_align);
58+
eq.t_db = sof_eq_align(eq.f, eq.t_db, eq.f_align, eq.db_align);
5959

6060
%% Error to equalize = target - raw response, apply 1/N octave smoothing to
6161
% soften the EQ shape
@@ -64,14 +64,14 @@
6464

6565
%% Parametric IIR EQ definition
6666
if eq.enable_iir
67-
[eq.p_z, eq.p_p, eq.p_k] = eq_define_parametric_eq(eq.peq, eq.fs);
67+
[eq.p_z, eq.p_p, eq.p_k] = sof_eq_define_parametric_eq(eq.peq, eq.fs);
6868
if max(length(eq.p_z), length(eq.p_p)) > 2*eq.iir_biquads_max
6969
error('Maximum number of IIR biquads is exceeded');
7070
end
7171
else
7272
[eq.p_z, eq.p_p, eq.p_k] = tf2zp(1, 1);
7373
end
74-
[eq.iir_eq_db, eq.iir_eq_ph, eq.iir_eq_gd] = eq_compute_response(eq.p_z, ...
74+
[eq.iir_eq_db, eq.iir_eq_ph, eq.iir_eq_gd] = sof_eq_compute_response(eq.p_z, ...
7575
eq.p_p, eq.p_k, eq.f, eq.fs);
7676

7777

@@ -101,10 +101,10 @@
101101
end
102102

103103
%% Update all responses
104-
eq = eq_compute_tot_response(eq);
104+
eq = sof_eq_compute_tot_response(eq);
105105

106106
%% Normalize
107-
eq = eq_norm(eq);
107+
eq = sof_eq_norm(eq);
108108

109109
end
110110

src/audio/eq_iir/tune/eq_compute_response.m renamed to src/audio/eq_iir/tune/sof_eq_compute_response.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [m, ph, gd] = eq_compute_response(z, p, k, f, fs)
1+
function [m, ph, gd] = sof_eq_compute_response(z, p, k, f, fs)
22

33
%%
44
% Copyright (c) 2016, Intel Corporation

0 commit comments

Comments
 (0)