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
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>
@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 thread src/audio/eq_iir/tune/sof_mls_freq_resp.m
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

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 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 Outdated

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 no new comments.

@singalsu

Copy link
Copy Markdown
Collaborator Author

An issue seen with one PC, fixing it ...

Add a 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.
All artifacts (configs, MLS reference, per-channel captures, CSV, PNG
plot) land under a per-run data subdirectory so the tune directory
does not fill up with per-machine files.

aplay -l and arecord -l are parsed to enumerate PCM devices. Speaker
preference is: descriptor named "Speaker" first (SOF SDW cards
advertise literal endpoint names), then SOF+Analog, then any Analog,
then the first non-HDMI/DP/Deepbuffer device. Mic preference is a
known calibrated measurement mic (UMM-6, UMIK, MiniDSP, EMM-6,
ECM8000) first, then any non-webcam USB card, then SOF DMIC, then
analog. --speaker / --mic override both. The auto id is
sanitize(DMI vendor + product) plus a mic tag, and gets a -2/-3/...
suffix when a prior run's outputs are already in the data dir so
re-measuring at a new mic position never clobbers old captures.

Capture format and channel count are probed with
arecord --dump-hw-params. S32_LE is preferred over S16_LE so the SOF
DMIC PCM (which only exposes S32_LE) works out of the box, and the
default channel count is the mic's advertised maximum. Optional
--cal PATH threads a two-column [freq_hz, mag_db] microphone
calibration file into rec.cal for sof_mls_freq_resp.m.

Opt-in --prep loads IPC4 pass-through blobs into the speaker card's
IIR/FIR bytes controls and turns DRC/MBDRC/TDFB switches off. Both
amixer and sof-ctl are invoked via the iface=MIXER,name='...' /
-c name='...' forms because numid-based access misreports max sizes
and trips a snd_ctl_elem_info() assertion on current alsa-utils.
Every external ioctl is wrapped in timeout(1), and each bytes
control's actual max size is probed before writing so 1-byte topology
stubs get skipped instead of crashing sof-ctl.

sof_mls_freq_resp.m gains three optional arguments (play_config_fn,
rec_config_fn, data_dir), a `pkg load signal;` up front so distros
where octave-signal is separate fail cleanly, and an mls-<id>.png
plot next to the CSV. Existing callers using the old positional
signature keep working via defaults.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu force-pushed the tune_improve_mls_freq_resp branch from 705cdfc to 72a7b24 Compare July 10, 2026 15:40
@singalsu

Copy link
Copy Markdown
Collaborator Author

An issue seen with one PC, fixing it ...

Now it's OK.

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