Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function blob8 = dcblock_build_blob(R_coeffs, endian, ipc_ver)
function blob8 = sof_dcblock_build_blob(R_coeffs, endian, ipc_ver)

%% Settings
qy_R = 30;
Expand Down
18 changes: 18 additions & 0 deletions src/audio/dcblock/tune/sof_dcblock_paths.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
function sof_dcblock_paths(enable)

% dcblock_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. All rights reserved.

common = '../../../../tools/tune/common';
if enable
addpath(common);
else
rmpath(common);
end
end
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function dcblock_plot_stepfn(R, fs)
function sof_dcblock_plot_stepfn(R, fs)
% Plot the step response of a DC Blocking Filter
% For a DC Blocking filter: H(z) = (1-1/z)/(1 - R/z)
% Therefore the coefficients are b = [1 -1], a = [1 -R]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function dcblock_plot_transferfn(R, fs)
function sof_dcblock_plot_transferfn(R, fs)
% Plot the transfer function.
% For a DC Blocking filter: H(z) = (1-1/z)/(1 - R/z)
% Therefore the coefficients are b = [1 -1], a = [1 -R]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function example_dcblock()
function sof_example_dcblock()

% Default blob, about 150 Hz cut-off @ 48 kHz
prm.fc = [];
Expand Down Expand Up @@ -31,13 +31,16 @@ function example_dcblock()
function dcblock_blob_calculate(prm)

% Set the parameters here
tplg1_fn = sprintf("../../topology/topology1/m4/dcblock_coef_%s.m4", prm.id); % Control Bytes File
tplg2_fn = sprintf("../../topology/topology2/include/components/dcblock/%s.conf", prm.id);
sof_tools = '../../../../tools';
sof_tplg = fullfile(sof_tools, 'topology');
sof_ctl = fullfile(sof_tools, 'ctl');
tplg1_fn = sprintf("%s/topology1/m4/dcblock_coef_%s.m4", sof_tplg, prm.id); % Control Bytes File
tplg2_fn = sprintf("%s/topology2/include/components/dcblock/%s.conf", sof_tplg, prm.id);
% Use those files with sof-ctl to update the component's configuration
blob3_fn = sprintf("../../ctl/ipc3/dcblock/coef_%s.blob", prm.id); % Blob binary file
alsa3_fn = sprintf("../../ctl/ipc3/dcblock/coef_%s.txt", prm.id); % ALSA CSV format file
blob4_fn = sprintf("../../ctl/ipc4/dcblock/coef_%s.blob", prm.id); % Blob binary file
alsa4_fn = sprintf("../../ctl/ipc4/dcblock/coef_%s.txt", prm.id); % ALSA CSV format file
blob3_fn = sprintf("%s/ipc3/dcblock/coef_%s.blob", sof_ctl, prm.id); % Blob binary file
alsa3_fn = sprintf("%s/ipc3/dcblock/coef_%s.txt", sof_ctl, prm.id); % ALSA CSV format file
blob4_fn = sprintf("%s/ipc4/dcblock/coef_%s.blob", sof_ctl, prm.id); % Blob binary file
alsa4_fn = sprintf("%s/ipc4/dcblock/coef_%s.txt", sof_ctl, prm.id); % ALSA CSV format file

endian = "little";

Expand All @@ -49,32 +52,32 @@ function dcblock_blob_calculate(prm)
R_coeffs = R * ones(1, channels);
end

addpath ./../common
sof_dcblock_paths(true);

blob8 = dcblock_build_blob(R_coeffs, endian);
blob8_ipc4 = dcblock_build_blob(R_coeffs, endian, 4);
blob8 = sof_dcblock_build_blob(R_coeffs, endian);
blob8_ipc4 = sof_dcblock_build_blob(R_coeffs, endian, 4);

% Generate output files
tplg_write(tplg1_fn, blob8, "DCBLOCK", ...
"Exported with script example_dcblock.m", ...
"cd tools/tune/dcblock; octave example_dcblock.m");
"Exported with script sof_example_dcblock.m", ...
"cd tools/tune/dcblock; octave sof_example_dcblock.m");
sof_ucm_blob_write(blob3_fn, blob8);
alsactl_write(alsa3_fn, blob8);

tplg2_write(tplg2_fn, blob8_ipc4, "dcblock_config", ...
"Exported with script example_dcblock.m" , ...
"cd tools/tune/dcblock; octave example_dcblock.m");
"Exported with script sof_example_dcblock.m" , ...
"cd tools/tune/dcblock; octave sof_example_dcblock.m");
sof_ucm_blob_write(blob4_fn, blob8_ipc4);
alsactl_write(alsa4_fn, blob8_ipc4);

% Plot Filter's Transfer Function and Step Response
% As an example, plot the graphs of the first coefficient
fs = 48e3;
dcblock_plot_transferfn(R_coeffs(1), fs);
sof_dcblock_plot_transferfn(R_coeffs(1), fs);
figure
dcblock_plot_stepfn(R_coeffs(1), fs);
sof_dcblock_plot_stepfn(R_coeffs(1), fs);

rmpath ./../common
sof_dcblock_paths(false);

end

Expand Down