Commit Graph

114 Commits

Author SHA1 Message Date
Seppo Ingalsuo e4b4ac7b4c Tools: Tune: Common: Add checks for file open failures
This patch adds checks and errors for fopen() failures. The check
is useful with setup scripts paths changes. Aborting the script
avoids the errors in blob exports to be missed.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-07-04 14:32:50 +03:00
Seppo Ingalsuo 7f212411cc Audio: DRC: Tune: Move DRC setup scripts to module directory
The purpose of this patch is to consolidate all the files
those belong to the DRC module. The top level function names
are changed to have sof_ prefix to avoid conflict with possible
other similar files.

Note: A small fix is needed after similar patch for EQ
is merged since some functions for DRC blob are used from
there.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-07-04 14:32:50 +03:00
Seppo Ingalsuo f122cea825 Audio: SRC: Tune: Move SRC setup scripts to module directory
The purpose of this change is to consolidate the files those
belong to the SRC module. This commit only moves the files. The
next commits are fixing the issues caused by the move.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-06-26 14:42:11 +01:00
Seppo Ingalsuo 1ff7c36363 Tools: Tune DRC: Export DRC for DMIC capture and cleanup filenames
A DRC blob for capture dmic_default is created. It boosts the capture
by 10 dB when the signal level is low.

The name of speaker blob is changed to speaker_default. The name with
endpoint name first helps to organize them e.g. in UCMv2 blobs data
directories.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-05-22 16:20:03 +01:00
Seppo Ingalsuo 03dbc7ba2c Tools: Tune: EQ: Normalize IIR and FIR separately
This allows more freedom to scale the equalizers. Common criteria
resulted with safe scaling to unnecessarily silent result or
risk for audible clipping in the equalizer.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-05-03 21:02:34 +03:00
Seppo Ingalsuo e8fcaf6958 Tools: Tune: Crossover: Cleanup blob files paths
This patch moves blobs for crossover component into
sub-directory "crossover" to clean up clutter from
ctl/ipc3 and ipc4 level.

The patch also adds export of blobs for IPC4 mode that
was missing.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-04-29 14:07:25 +01:00
Seppo Ingalsuo 70449a3d70 Tools: Tune: EQ: Cleanup produced blob files structure
To remove clutter from upper level this patch changes
generated files naming from e.g. "ipc4/eq_fir_loudness.blob" to
"ipc4/eq_fir/loudness.blob". It helps to find the blob files
from directory that has same name as the target component.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-04-29 14:07:25 +01:00
Seppo Ingalsuo ec4e2a9cf9 Tools: Tune: EQ: Rename configuration blobs to use .blob
We have both .bin and .blob file name suffixes in use for
similar byte controls initialize files. The scripts those
generate files with .bin are changed to .blob.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-04-29 14:07:25 +01:00
Seppo Ingalsuo 4f46135fba Tools: Tune: EQ: The function eq_blob_write.m is deleted
The replacement is sof_ucm_blob_write.m.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-04-29 14:07:25 +01:00
Seppo Ingalsuo b5bd60c1f0 Tools: Tune: EQ: Create highpass blobs and add 100 Hz version
There were no bytes control binary blobs for highpass filters.
This patch adds export of them and adds a 100 Hz filter option.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-04-29 14:07:25 +01:00
Seppo Ingalsuo 25e105026d Tools: Tune: Use common/sof_ucm_blob_write.m for binary blob export
The sof_ucm_blob_write.m is an updated copy of blob_write that
exports binary blobs with header that is suitable for ALSA UCM's
cset-tlv command. The UCM requires binary files so the default
binary export is changed for every component setup script to this
format.

The ASCII decimal numbers .txt format export remains suitable for
sof-ctl tool.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-04-29 14:07:25 +01:00
Seppo Ingalsuo 6980cdd7b4 Tools: Tune: Eq: Fix IIR data files names in example_spk_eq.m
The IIR files export overwrites the FIR files due to mistake
in the script.

Fixes commit 5ddbd34ba9 ("Tools: Tune: EQ: Add tplg2 blobs create")

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-04-04 18:58:02 +03:00
Seppo Ingalsuo a9a05e2b3a Tools: Tune: SRC: Update generator to produce similar as edited
This patch makes to SRC coefficients tables generator same changes
as done in recent git commits.

commit 88fdb10e52 ("audio: src: rename sample rate converter
coefficient folder name") moved coefficients files location to
src/audio/src/coefs.

commit 90fef5afd2 ("src_lite: add module") removed include of
src.h from upper level due to another src-lite version.

'commit 7f4e6aed74 ("src: make coefficients constant")
added const to struct src_stage.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2024-02-23 13:13:28 +00:00
Seppo Ingalsuo 3d083e7ca7 Tools: Tune: DRC: Add calculation of blob for speaker processing
This patch adds generation of a blob that applies about
10 dB gain with compression and additional post gain of
3 dB for strong loudness boost effect.

The drc_gen_coefs.m script is changed to display
the master linear gain as decibels to help achieve
suitable gain when setting parameters.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-12-19 17:18:44 +00:00
Seppo Ingalsuo 18f170352d Tools: Tune: DRC: Add information how to create topology blobs
This patch updates the generator script example_drc.m with added
information how the blobs were created.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-12-19 17:18:44 +00:00
Seppo Ingalsuo b90ae24a88 Tools: Tune: TDFB: Use more silent command line options
These command line options for Octave and Matlab are the
most silent with no graphical plot windows opening during
batch job.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-11-03 16:20:25 +00:00
Seppo Ingalsuo 66e5c2cead Tools: Tune: TDFB: Add howto instructions to generated tplg blobs
Set field export_howto to instruction that was used to create
the blob. The tplg2 .conf and tplg1 .m4 files will contain the
command in the beginning of file.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-11-03 16:20:25 +00:00
Seppo Ingalsuo 3f2ebb81d0 Tools: Tune: TDFB: Add support for IPC4 and tplg2 blobs
This patch adds generation of.conf format blobs for tplg2
with IPC4 format blob. The blob ABI header retrieving is
changed to common helper functions path those already have
the support.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-10-20 12:05:11 +03:00
Seppo Ingalsuo d3b7e54f3f Tools: Tune: dcblock: Create set of cut-off frequencies
This patch modifies script example_dblock.m to create in
addition to existing default coefficients blob with parameter
R=0.98 a set of blobs those provide (-3 dB) cut-off frequencies
20, 30, 40, 50, 100, 200 Hz for 16 kHz and 48 kHz for various
usages. Human understandable parameters for blobs helps to select
the configuration for the needed dcblock usage.

The parameter value R for given frequencies is calculated
with iterative function dcblock_rval_calculate(). A closed
form equation might be possible to derive from the transfer
function. If such is found this function can be replaced with
quicker equation -- or with more advanced faster converging
iteration.

The topology blob export functions are also modified to add
comment line for exact build command.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-10-16 16:38:41 +01:00
Seppo Ingalsuo e7816e9e63 Tools: Tune: dcblock: Fixes for Matlab compatibility
The script can be run in both Matlab and Octave with these
changes.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-09-14 21:06:13 +03:00
Seppo Ingalsuo 884bad441e Tools: Tune: dcblock: Avoid warning about ignoring imaginary
The abs() function need to be added to plot the correct magnitude
response. Matlab warned in this case about ignoring imaginary
part.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-09-14 21:06:13 +03:00
Seppo Ingalsuo dec770dd8d Tools: Tune: Add tplg2 support to dcblock setup tool
This patch adds generate of blob for tplg2 and ipc4 in
formats .conf, text, and binary formats.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-09-14 21:06:13 +03:00
Seppo Ingalsuo f27085f046 Tools: Tune: Multiband-DRC: Add comment about generator script
This patch helps to find the right tool to create the setup blobs.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-09-13 14:54:15 +01:00
Seppo Ingalsuo 176aec773c Tools: Tune: DRC: Export ascii and binary IPC4 blobs for sof-ctl
The passthrough and enabled blobs are exported to tools/ctl/ipc4/drc.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-08-31 21:04:17 +01:00
Seppo Ingalsuo 356988e7ca Tools: Tune: Multiband-DRC: Changes for Matlab syntax
The code contains some m-language syntax that is not supported
by Matlab. The code lines are changed to compatible with both
Octave and Matlab. The blobs computation is not changed.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-08-28 09:42:36 +01:00
Seppo Ingalsuo 3d1275dc0d Tools: Tune: Multiband-DRC: Add support for tplg2 config files generation
This patch re-structures function example_multiband_drc() to
let it generate multiple differentiated configurations. The
computation of blob is moved to new function export_multiband_drc().
The script now generates default (same as before) and pass-through
blobs.

Inside the function the paths for tplg1 and tplg2 are updated as
well as locations of data blobs for sof-ctl. The run of export
function creates blobs for both tplg1 and tplg2 with SOF IPC
versions three and four.

check_create_dir() common function is added to avoid error with
missing directory for export and for warning message about
already existing directory that just using mkdir() would do.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-08-28 09:42:36 +01:00
Seppo Ingalsuo 39edc7a844 Tools: Tune: Update crossover configurations export for tplg2
The script example_crossover.m is converted to export 2, 3, and 4
way crossover configurations for tplg1 and tplg2.

The crossover parameters like number of sinks, pipeline ids of
sinks, sample rate, and band limits are added to generate blob
filenames.

The changes include fixes for running the script with Matlab in
addition to Octave.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-08-09 16:49:35 +03:00
Seppo Ingalsuo e7fc334bda Tools: Tune: DRC: Changes for Matlab compatibility
This patch enables running example_drc.m script with Matlab.
The endifs are changed to end. And mixed usage of endfunction
and end is corrected to just end. The unnecessary
semicolons from function declarations are deleted.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-05-29 10:12:16 +03:00
Seppo Ingalsuo 83a2ae813c Tools: Tune: DRC: Export configurations for topology2
This patch changes a bit structure of example_drc to export
conveniently several different blobs. The changed script
exports configurations blobs for disabled and enabled mode.

Two functions for IPC4 and topology2 compatibility are
generalized from EQ to common directory. The EQ and other
tools will be updated to later to use the common get_abi()
and tplg2_write() functions.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-05-29 10:12:16 +03:00
Seppo Ingalsuo 81060d9b88 Tools: Tune: Add to DMIC modes generate alsa-utils export
This patch adds export format for header file that alsa-utils
uses. Automatic generation is much more convenient than hand
editing when there is update need.

The patch also contains some cleanup of unused code and small
code improvement. There are no changes to exported coefficients
values.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-05-10 11:28:33 +03:00
Seppo Ingalsuo 63598ee054 Tools: Tune: EQ: Use updated sof-ctl for tplg2 blob export
No more need for hard-coded blob header, sof-ctl provides
an up-to-date header so better to use it.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-02-15 11:36:51 +00:00
Seppo Ingalsuo e26ef3a08c 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>
2023-02-08 12:01:32 +02:00
Seppo Ingalsuo 5ddbd34ba9 Tools: Tune: EQ: Add tplg2 blobs create
This patch contains the changes to export EQ blobs in both tplg1
IPC3 and tplg2 IPC4 formats.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-02-08 12:01:32 +02:00
Seppo Ingalsuo 5aa9a9e484 Tools: Tune: EQ: Matlab compatibility fix for parametric EQ
Every endif is changed to end. The endif works only in Octave.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2023-02-08 12:01:32 +02:00
Seppo Ingalsuo c11d99241d Tools: Tune: Fix erroneous fprintf() in src_get.m
This fprintf() with missing %d causes in Matlab and octave
messed up console output. This fix prints filter order
if this issue happens. This could be caused by too high
filter specification request that was not possible to reach.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-11-18 10:10:16 +00:00
Seppo Ingalsuo 4d35480c64 Tools: Tune: SRC: Change the SRC gain to 0 dB
This change aligns the gains in all other conversions sets
with IPC4 that already has the same setting. The max gain of a
converter is 0 dB. It also avoids the issue of 1 dB lower gain
in 2-stage vs. 1-stage conversions.

This changes only the generate scripts. The coefficients need a
separate patch.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-11-18 10:10:16 +00:00
Seppo Ingalsuo 40f78a9325 Tools: Tune: Add minimum THD+N performance check to snr_generate.m
This patch updates the SRC coefficients generator scripts with
add of parameter cfg.thdn that is the min. THD+N performance. The
target gain is set to 0 dB for all conversions to be generated.

in src_param.m the default stop-band is relaxed from 70 dB to 63 dB.
It can be done because the THD+N performance check will step up the
attenuation. The default lower attenuation saves RAM in easy
simple fractions conversions.

The main change is in src_generate.m. The conversions matrix is
two pass. In the first pass the converters are designed and the
converter for same fraction and other bandwidth parameters with
highest performance is preserved. In the second pass the table
of converters is constructed and the size of filters and buffers
and other information like MCPS estimate are collected.

Other changes include reduction of plots made during batch design
and remove of some commented out code.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-11-18 10:10:16 +00:00
Andrula Song ef62a50893 Cmocka: EQ: Fix the errors lead to eq-iir test failure
Fix the mistakes in scripts which would lead to eq-iir
test failure.

Signed-off-by: Andrula Song <xiaoyuan.song@intel.com>
2022-10-31 13:33:40 +00:00
Rander Wang b97fd67ef0 cmocka: add eq_fir unit test
This test uses module interface for eq_fir.

The use of decoded 16 bit FIR blob coefficients decreases a lot
the mismatch between float reference FIR vs. SOF fixed point
implementation.

This patch adds the script tools/tune/eq/cmocka_data_eq_fir.m that
generates the files cmocka_fir_coef_2ch.h and cmocka_fir_ref.h.

The script debug_files_plot.m can be used to visualize the unit
test result and error for data that is generated if macro
DEBUG_FILES is defined.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Signed-off-by: Andrula Song <xiaoyuan.song@intel.com>
Signed-off-by: Rander Wang <rander.wang@intel.com>
2022-10-27 21:12:37 +01:00
Seppo Ingalsuo d526f7372c Tools: Tune: Prevent topology1 blob export to increase blob size
The increase of non-32bit aligned blob sizes needs to be removed
because it can cause mismatch of blob binary header vs. actual
size. Instead error if blob size is not multiple of four bytes.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-10-05 13:07:10 +01:00
Seppo Ingalsuo e235fbf9be Tools: Tune: Matlab tool for creating configuration blob for MFCC
This patch adds initial version of MFCC setup tool setup_mfcc.m. It
outputs a configuration topology macro file that matches the current
Matlab concept code. The configuration can be tested in testbench
with the supplied scripts run_mfcc.sh and decode_ceps.m.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-10-05 13:07:10 +01:00
Seppo Ingalsuo 04aa27103e Math: FFT: Switch to script generated twiddle.h
This patch adds script tools/tune/fft/export_twiddle.m. Since
the data in original twiddle.h differs by one LSB in few
items the file is replaced with one generated with the script.

The identifier 32 is added to header name and variables names
as preparation to add 16 bit FFT version.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-08-26 10:46:50 +01:00
Seppo Ingalsuo b0336346f7 [SKIP CI] Tools: Tune: SRC: Add missing gain to generate scripts
Patch a0ff2bb277 added field .gain to configuration data for
src_generate() but the previous generator scripts were not
updated to set it. This patch fixes in them the error about
undefined gain by setting it to previous -1 dB default.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-08-01 11:11:56 +01:00
Seppo Ingalsuo 978827f7fc [SKIP CI] Tools: Tune: SRC: Add to coefficients data Doxygen cond comments
This patch updates the SRC tool to export same guidance for
Doxygen as added by a previous patch for coefficients
header files. The added comments to begin and end are:

/** \cond GENERATED_BY_TOOLS_TUNE_SRC */
/** \endcond */

The impacted headers remain identical so they don't need update.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-08-01 11:11:56 +01:00
Seppo Ingalsuo 0d5e731b19 Audio: SRC: Add IPC4 full conversions matrix to SRC comp and tools
This patch adds the Kconfig option COMP_SRC_IPC4_FULL_MATRIX and
adds handling to src.c. Testbench build was changed to use this
largest matrix.

The coefficients were generated with script src_ipc4_int32.m. The
new sample rates were added to test script src_test.m.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-04-29 12:42:38 +01:00
Seppo Ingalsuo a0ff2bb277 Tools: Tune: SRC: Allow pass of desired gain to src_generate()
There's need to have a 0 dB gain SRC conversion matrix while
earlier all defaulted to -1 dB. With this change the parameter
cfg.gain can be used with src_generate() function.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-04-29 12:42:38 +01:00
Seppo Ingalsuo 91afe67ae5 Tools: Tune: SRC: Add line break between structs in generated code
This patch helps to pass the code style check in generated header
file src_<profile>_<data type>_table.h. The error was:

CHECK: Please use a blank line after function/struct/union/enum
declarations

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-04-29 12:42:38 +01:00
Seppo Ingalsuo 5683382872 Tools: Tune: SRC: Avoid flood of plot windows with large SRC matrix
This patch forces open of every plot to the same picture window.
Earlier version could open hundreds of windows and freeze the
computer.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-04-29 12:42:38 +01:00
Seppo Ingalsuo 74fcc02ff5 Tools: Test, Tune: Improve Matlab scripts for EQ testing
The test scripts missed test component keyword change from e.g.
eqiir to eq-iir. Due to this the process_test() failed for IIR and
FIR for gain and frequency response due to wrong result expect.

The expected result is retrieved with the blob decode function. It
can be also used manually to check the filters defined in the
blob. The help texts in the decode functions needed fix. Also some
usage examples were added.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-02-18 21:47:16 +00:00
Seppo Ingalsuo e9048e4b7d Tools: Topology: Fix erratic FIR example response
The previous patch increased the FIR length but it also triggered
a numerical issue in FIR design with long minimum phase filters. The
filter became essentially a band-stop filter and causes difficulties
in test of EQ component. Also the equalizer sounds subjectively
bad. The fix is to change the design to linear phase that always
converges.

Fixes: 0d296ce7d1

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
2022-02-11 10:41:55 +00:00