Tools: Tune: EQ: Code cleanup with no functional changes

Use of isempty() instead of length() to the check for non-empty
variable can avoid warnings in executing code in Matlab.

The unnecessary print of variable to console is removed. E.g.
struct bs, or biquad transfer function zeros vector a.

In system() command no need to store the console output, just
check the return status.

In switch-case statements no need for comma after case and
otherwise.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This commit is contained in:
Seppo Ingalsuo 2023-02-02 13:35:57 +02:00 committed by Kai Vehmanen
parent 5ddbd34ba9
commit e26ef3a08c
4 changed files with 7 additions and 10 deletions

View File

@ -73,10 +73,10 @@ for i=1:sp(1)
otherwise
error('Unknown parametric EQ type');
end
if length(a0) > 0
if ~isempty(a0)
[z0, p0, k0] = tf2zp(b0, a0);
end
if length(k0) > 0
if ~isempty(k0)
z = [z ; z0(:)];
p = [p ; p0(:)];
k = k * k0;
@ -132,7 +132,7 @@ function [b, a] = peak_2nd(fhz, gdb, Q, fs)
% When Q = 0, the above formulas have problems. If we
% look at the z-transform, we can see that the limit
% as Q->0 is A^2, so set the filter that way.
b = [A * A, 0, 0]
b = [A * A, 0, 0];
a = [1, 0, 0];
return;
end

View File

@ -41,7 +41,6 @@ end
%% Channels count and assign vector length must be the same
if bs.channels_in_config ~= length( bs.assign_response)
bs
error("Channels # and response assign length must match");
end
@ -49,7 +48,6 @@ end
len = length(bs.all_coefficients);
len_no_header = len - 10 * bs.number_of_responses_defined;
if mod(len_no_header, 4) > 0
bs
error("Coefficient data vector length must be multiple of 4");
end

View File

@ -32,11 +32,11 @@ end
ipc4_use_sofctl = 0; % Set to 1 when sof-ctl update is merged
abifn = 'eq_get_abi.bin';
switch ipc_ver
case 3,
case 3
%% Use sof-ctl to write ABI header into a file
cmd = sprintf('sof-ctl -g %d -t %d -b -o %s', setsize, type, abifn);
[bytes, nbytes] = get_abi_with_sofctl(cmd, abifn);
case 4,
case 4
if ipc4_use_sofctl
cmd = sprintf('sof-ctl -I IPC4 -g %d -p %d -b -o %s', setsize, param_id, abifn);
[bytes, nbytes] = get_abi_with_sofctl(cmd, abifn);
@ -49,7 +49,7 @@ switch ipc_ver
bytes( 9:12) = w32b(setsize); % size
bytes(13:16) = [0x00 0xa0 0x01 0x03]; % ABI
end
otherwise,
otherwise
fprintf(1, 'Illegal ipc_ver %d\n', ipc_ver);
error('Failed.');
end
@ -58,7 +58,7 @@ end
function [bytes, nbytes] = get_abi_with_sofctl(cmd, abifn)
[ret, out] = system(cmd);
[ret, ~] = system(cmd);
if ret
error('Failed to run sof-ctl. Is it installed?');
end

View File

@ -24,7 +24,6 @@ end
%% Channels count and assign vector lengths must be the same
if bs.channels_in_config ~= length( bs.assign_response)
bs
error("Channels # and response assign length must match");
end