Skip to content

audio: eq_iir: tune: add sof_mls_freq_resp_local.sh#10981

Open
singalsu wants to merge 2 commits into
thesofproject:mainfrom
singalsu:tune_improve_mls_freq_resp
Open

audio: eq_iir: tune: add sof_mls_freq_resp_local.sh#10981
singalsu wants to merge 2 commits into
thesofproject:mainfrom
singalsu:tune_improve_mls_freq_resp

Conversation

@singalsu

@singalsu singalsu commented Jul 9, 2026

Copy link
Copy Markdown
Collaborator

No description provided.

@singalsu singalsu marked this pull request as ready for review July 9, 2026 13:47
@singalsu singalsu requested review from Copilot, kv2019i and lgirdwood July 9, 2026 13:47

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR extends the MLS-based frequency response tuning workflow by making sof_mls_freq_resp.m more reusable (configurable config paths + output directory) and by adding a new helper script to generate local ALSA configs and optionally run the measurement end-to-end.

Changes:

  • Extend sof_mls_freq_resp.m to accept playback/capture config paths and an output directory, improve path handling, and save a PNG plot alongside the CSV.
  • Add sof_mls_freq_resp_local.sh to auto-detect local ALSA speaker/mic, generate mls_*_config.txt, optionally prep DSP controls, and optionally run Octave.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 6 comments.

File Description
src/audio/eq_iir/tune/sof_mls_freq_resp.m Adds config/output-dir parameters, improves path robustness, and adds PNG plot output.
src/audio/eq_iir/tune/sof_mls_freq_resp_local.sh New local helper to detect ALSA devices, generate configs, optionally prep DSP state, and run Octave.

Comment thread src/audio/eq_iir/tune/sof_mls_freq_resp.m Outdated
Comment thread src/audio/eq_iir/tune/sof_mls_freq_resp_local.sh Outdated
Comment thread src/audio/eq_iir/tune/sof_mls_freq_resp_local.sh
Comment thread src/audio/eq_iir/tune/sof_mls_freq_resp_local.sh Outdated
Comment thread src/audio/eq_iir/tune/sof_mls_freq_resp_local.sh
Comment thread src/audio/eq_iir/tune/sof_mls_freq_resp_local.sh Outdated
@singalsu singalsu force-pushed the tune_improve_mls_freq_resp branch from cfa0d5c to d014c03 Compare July 9, 2026 14:16
@singalsu singalsu requested a review from Copilot July 9, 2026 14:17

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

Comment thread src/audio/eq_iir/tune/sof_mls_freq_resp.m Outdated
Comment thread src/audio/eq_iir/tune/sof_mls_freq_resp_local.sh
@singalsu singalsu force-pushed the tune_improve_mls_freq_resp branch from d014c03 to 19b805d Compare July 9, 2026 15:04
singalsu added 2 commits July 9, 2026 18:08
Clean up a handful of latent bugs and rough edges in the MLS response
measurement helper without touching its behavior in the common paths.

The cell-array labels[] slots were being assigned with (), which wraps
the string into a nested cell instead of using it as the label under
Octave. The sync-marker overlay was calling plot(ts(si), r(si), 'g')
on a matrix r, so with more than one capture channel the linear
indexing wrapped into the wrong channel. addpath() used a CWD-relative
path and the matching rmpath at end-of-function never ran on error;
both are now resolved from mfilename('fullpath') and paired via
onCleanup. The system() wrappers now quote every path argument (new
shq helper, verified round-trippable) and go through a run_shell()
wrapper that raises on non-zero status instead of letting a broken
scp/aplay/arecord silently propagate as NaNs later on.

Smaller items: y is preallocated and asserted for consistent nt across
playback channels; the 1 kHz normalization frequency becomes a named
f_align_hz constant with an empty-bin guard; get_calibration() uses
onCleanup(fclose), handles an empty description, and prefers ~isempty
over length()>0; local variable dir renamed to tmp_dir to stop
shadowing the builtin; capture_level_min_db comment typo fixed; the
docstring header now matches the actual function name; get_config()
carries a warning comment documenting that config files are executed
via eval and must be locally trusted.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Add a POSIX-friendly bash driver that turns the older manually-edited
mls_play_config.txt / mls_rec_config.txt workflow into a one-shot
"detect + configure + optionally measure" script for the local host.
Everything (configs, MLS reference, per-channel captures, CSV, plot)
lands under a data subdirectory (default sof_mls_freq_resp_data/) so
the tune directory does not fill up with per-machine artifacts.

Device discovery. aplay -l and arecord -l are parsed to enumerate the
PCM devices. Speaker preference is SOF analog first, any other analog
second, first non-HDMI/DP as a last resort; HDMI and Deepbuffer outputs
are always skipped. Microphone preference is a known calibrated
measurement mic (UMM-6, UMIK, MiniDSP, EMM-6, ECM8000) first, any other
USB audio card that does not look like a webcam second, SOF DMIC array
third, any analog capture fourth. Both picks can be overridden with
--speaker and --mic, and the script prints which rule fired.

Measurement id and file naming. The id is derived from DMI sys_vendor
+ product_name (sanitized to [a-z0-9_]) and then extended with a
sanitized microphone tag so measuring the same laptop with a UMM-6
and with the internal DMIC produces distinct output files instead of
overwriting. --no-mic-tag disables the suffix and --id STR passes the
whole id verbatim. The report block also echoes the raw DMI strings
because the UCM blob generator expects them exactly as they appear in
/sys/devices/virtual/dmi/id.

Capture parameters are probed at runtime. arecord --dump-hw-params is
scanned for FORMAT and CHANNELS. The format is picked as S32_LE if
supported, otherwise S16_LE, otherwise the first advertised value;
this fixes the "Sample format non available" error the SOF DMIC PCM
would otherwise raise because it only exposes S32_LE. Channel count
defaults to the max the mic advertises so DMIC arrays end up recorded
at their native width. --rec-fmt / --mic-ch override each of these,
and --cal PATH threads a two-column [freq_hz, mag_db] microphone
calibration file into rec.cal so sof_mls_freq_resp.m compensates the
measurement with it.

Opt-in DSP prep. --prep programs the speaker card's IIR and FIR bytes
controls with the IPC4 pass-through blobs from tools/ctl/ipc4 and
turns any DRC / MBDRC / TDFB switch off via amixer, so the signal
path is as flat as possible while the MLS is playing. Blob paths
default to tools/ctl/ipc4/eq_{iir,fir}/pass.txt and can be overridden
with --iir-blob / --fir-blob; sof-ctl is invoked with -i 4 so the ABI
header matches an IPC4 topology.

sof_mls_freq_resp.m companion changes. Three optional arguments are
added (play_config_fn, rec_config_fn, data_dir) that default to the
previous hard-coded values so existing callers keep working. The
config helpers thread the file name through, the persistent outputs
(mls-<id>.wav, mls-<id>.txt, mls-ref.wav) go through data_dir, and
the script now also writes mls-<id>.png with the aligned response
plot. The title uses Interpreter 'none' so underscores in the id
render literally instead of as TeX subscripts. meas_remote_rec_config
honors rec.fmt_name / rec.bits from the config when present.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu force-pushed the tune_improve_mls_freq_resp branch from 19b805d to 5c20663 Compare July 9, 2026 15:09
@singalsu singalsu requested a review from Copilot July 9, 2026 15:22

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

Comment on lines +261 to +263
try
print(main_fig, '-dpng', '-r150', plot_fn);
fprintf('Wrote %s\n', plot_fn);
Comment on lines +186 to +187
% nt is the sample count of the test signal, so the range
% highlighted here must is r(d:d+nt-1, :).
Comment on lines +118 to +121
need aplay
need arecord
need awk
need octave
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants