Skip to content

Commit

Permalink
Tools: Tune: dcblock: Fixes for Matlab compatibility
Browse files Browse the repository at this point in the history
The script can be run in both Matlab and Octave with these
changes.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
  • Loading branch information
singalsu authored and kv2019i committed Sep 14, 2023
1 parent 884bad4 commit e7816e9
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 18 deletions.
9 changes: 4 additions & 5 deletions tools/tune/dcblock/dcblock_build_blob.m
Original file line number Diff line number Diff line change
@@ -1,16 +1,15 @@
function blob8 = dcblock_build_blob(R_coeffs, endian, ipc_ver)

%% Settings
bits_R = 32; %Q2.30
qy_R = 30;

if nargin < 2
endian = 'little'
endif
endian = 'little';
end

if nargin < 3
ipc_ver = 3;
endif
end

%% Shift values for little/big endian
switch lower(endian)
Expand Down Expand Up @@ -44,7 +43,7 @@
j=j+4;
end

endfunction
end

function bytes = word2byte(word, sh)
bytes = uint8(zeros(1,4));
Expand Down
4 changes: 2 additions & 2 deletions tools/tune/dcblock/dcblock_plot_stepfn.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function dcblock_plot_stepfn(R, fs);
function 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 All @@ -13,4 +13,4 @@
tstr = sprintf("DC Blocking Filter Step Response, R = %i", R);
title(tstr);

endfunction
end
4 changes: 2 additions & 2 deletions tools/tune/dcblock/dcblock_plot_transferfn.m
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
function dcblock_plot_transferfn(R, fs);
function 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 All @@ -14,4 +14,4 @@
tstr = sprintf("DC Blocking Filter Frequency Response, R = %i", R);
title(tstr);

endfunction
end
18 changes: 9 additions & 9 deletions tools/tune/dcblock/example_dcblock.m
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
function example_dcblock();
function example_dcblock()

% Set the parameters here
tplg1_fn = "../../topology/topology1/m4/dcblock_coef_default.m4" % Control Bytes File
tplg2_fn = "../../topology/topology2/include/components/dcblock/default.conf"
tplg1_fn = "../../topology/topology1/m4/dcblock_coef_default.m4"; % Control Bytes File
tplg2_fn = "../../topology/topology2/include/components/dcblock/default.conf";
% Use those files with sof-ctl to update the component's configuration
blob3_fn = "../../ctl/ipc3/dcblock_coef.blob" % Blob binary file
alsa3_fn = "../../ctl/ipc3/dcblock_coef.txt" % ALSA CSV format file
blob4_fn = "../../ctl/ipc4/dcblock_coef.blob" % Blob binary file
alsa4_fn = "../../ctl/ipc4/dcblock_coef.txt" % ALSA CSV format file
blob3_fn = "../../ctl/ipc3/dcblock_coef.blob"; % Blob binary file
alsa3_fn = "../../ctl/ipc3/dcblock_coef.txt"; % ALSA CSV format file
blob4_fn = "../../ctl/ipc4/dcblock_coef.blob"; % Blob binary file
alsa4_fn = "../../ctl/ipc4/dcblock_coef.txt"; % ALSA CSV format file

endian = "little";
R_coeffs = [0.98, 0.98, 0.98, 0.98, 0.98, 0.98, 0.98, 0.98];
Expand All @@ -28,11 +28,11 @@

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

rmpath ./../common

endfunction
end

0 comments on commit e7816e9

Please sign in to comment.