audio: eq_iir: tune: add sof_mls_freq_resp_local.sh#10981
Open
singalsu wants to merge 2 commits into
Open
Conversation
Contributor
There was a problem hiding this comment.
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.mto 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.shto auto-detect local ALSA speaker/mic, generatemls_*_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. |
cfa0d5c to
d014c03
Compare
d014c03 to
19b805d
Compare
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>
19b805d to
5c20663
Compare
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.