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
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
function drc_coefs = drc_gen_quant_coefs(num_bands, sample_rate, params);

addpath ../drc

for i = 1:num_bands
coefs = drc_gen_coefs(params(i), sample_rate);
drc_coefs(i) = drc_generate_config(coefs);
end

rmpath ../drc

end
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,17 @@ function example_multiband_drc()

function export_multiband_drc(prm)

multiband_drc_paths(true);

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

endian = "little";

Expand Down Expand Up @@ -116,6 +119,8 @@ function export_multiband_drc(prm)
drc_params(4).band_lower_freq = prm.band_lower_freq(4) / nyquist;

% Generate Emphasis/Deemphasis IIR filter quantized coefs struct from parameters


[emp_coefs, deemp_coefs] = iir_gen_quant_coefs(iir_params);

% Generate Crossover quantized coefs struct from parameters
Expand All @@ -128,7 +133,6 @@ function export_multiband_drc(prm)
drc_coefs = drc_gen_quant_coefs(num_bands, sample_rate, drc_params);

% Generate output files
addpath ../common

% Convert quantized coefs structs to binary blob
blob8 = multiband_drc_build_blob(num_bands, enable_emp_deemp, emp_coefs, ...
Expand All @@ -145,6 +149,6 @@ function export_multiband_drc(prm)
sof_ucm_blob_write(blob4_fn, blob8_ipc4);
alsactl_write(alsa4_fn, blob8_ipc4);

rmpath ../common
multiband_drc_paths(false);

end
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,6 @@
bits_gain = 16; % Q2.14
qf_gain = 14;

addpath ../eq

quant_coefs = cell(1, 2);
for i = 1:length(coefs)
coef = cell2mat(coefs(i));
Expand All @@ -88,8 +86,6 @@

quant_coefs = cell2mat(quant_coefs);

rmpath ../eq

end

function [bq1, bq2] = stage_gain_adjust(prev_bq1, prev_bq2)
Expand Down
33 changes: 33 additions & 0 deletions src/audio/multiband_drc/tune/multiband_drc_paths.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
function multiband_drc_paths(enable)

% multiband_drc_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';
crossover = '../../../../tools/tune/crossover';
drc = '../../../../tools/tune/drc';
eq = '../../../../tools/tune/eq';
# After #9215 merge use this:
# crossover = '../../crossover/tune';
# After #9188 merge use this:
# drc = '../../drc/tune';
# After #9187 merge use this:
# eq = '../../eq_iir/tune';
Comment on lines +12 to +21
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, does Matlab/Octave support PATHs via environment variable ? If so, might be easiest to have a script that sets these for the (like Zephyr has convenience script to setup build environment)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the environment variables can be supported:

octave:1> getenv('SOF_WORKSPACE')
ans = /home/singalsu/work/current/sof

Would above be better e.g. as tune = sprintf('%s/sof/tools/tune', getenv('SOF_WORKSPACE')); ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Btw, lets track this as a long term feature - ideally long term west would enable this when we configure the environment.

if enable
addpath(common);
addpath(crossover);
addpath(drc);
addpath(eq);
else
rmpath(common);
rmpath(crossover);
rmpath(drc);
rmpath(eq);
end
end