Skip to content

Audio: MFCC: Updates to run MFCC in sof-testbench4#10727

Open
singalsu wants to merge 5 commits intothesofproject:mainfrom
singalsu:mfcc_update
Open

Audio: MFCC: Updates to run MFCC in sof-testbench4#10727
singalsu wants to merge 5 commits intothesofproject:mainfrom
singalsu:mfcc_update

Conversation

@singalsu
Copy link
Copy Markdown
Collaborator

No description provided.

For capture topologies the file write component acts as the host
(sink endpoint). Its ipc_config.type was left as SOF_COMP_MODULE_ADAPTER,
which caused module_adapter_prepare() to fail with 'no sink present on
period size calculation' because the capture host has no downstream
sinks in its bsink_list.

As the fix set ipc_config.type to SOF_COMP_HOST for the capture host
file component (FILE_WRITE with capture direction) so the sink check
in module_adapter_prepare() is properly skipped, matching the behavior
of SOF_COMP_DAI set for the DAI-side file components.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
The files host_io_gateway_pipelines_s16/24/32.conf are obsolete
and are not used for current test topologies.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
@singalsu singalsu marked this pull request as ready for review April 27, 2026 15:05
Copilot AI review requested due to automatic review settings April 27, 2026 15:05
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 adds MFCC as a selectable component in the topology2 benchmark topologies (HDA + SDW) and updates MFCC tuning/run tooling to work with sof-testbench4.

Changes:

  • Add MFCC bench include files (widgets, routes, controls) plus 16 kHz host gateway/audio format snippets.
  • Register MFCC in benchmark CMake targets and benchmark top-level configs (cavs-benchmark-*.conf).
  • Update testbench file component init logic and refresh MFCC tuning scripts/docs (Octave/Matlab + run script + decoder helper).

Reviewed changes

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

Show a summary per file
File Description
tools/topology/topology2/include/bench/one_input_output_format_s32_16k.conf New 32-bit 16 kHz single-format I/O definition for bench components
tools/topology/topology2/include/bench/one_input_output_format_s24_16k.conf New 24-in-32 16 kHz single-format I/O definition for bench components
tools/topology/topology2/include/bench/one_input_output_format_s16_16k.conf New 16-bit 16 kHz single-format I/O definition for bench components
tools/topology/topology2/include/bench/mfcc_s32.conf New MFCC bench component include (s32) wiring widget + host gateway + routes
tools/topology/topology2/include/bench/mfcc_s24.conf New MFCC bench component include (s24) wiring widget + host gateway + routes
tools/topology/topology2/include/bench/mfcc_s16.conf New MFCC bench component include (s16) wiring widget + host gateway + routes
tools/topology/topology2/include/bench/mfcc_route.conf New bench routes connecting MFCC between host-copier and DAI copier
tools/topology/topology2/include/bench/mfcc_controls_playback.conf New bench playback control block for MFCC bytes control
tools/topology/topology2/include/bench/mfcc_controls_capture.conf New bench capture control block for MFCC bytes control
tools/topology/topology2/include/bench/host_io_gateway_pipelines_s32.conf Removed old host+io gateway pipeline definition (appears unused after changes)
tools/topology/topology2/include/bench/host_io_gateway_pipelines_s24.conf Removed old host+io gateway pipeline definition (appears unused after changes)
tools/topology/topology2/include/bench/host_gateway_pipelines_s32_16k.conf New 16 kHz host gateway pipelines for s32
tools/topology/topology2/include/bench/host_gateway_pipelines_s24_16k.conf New 16 kHz host gateway pipelines for s24
tools/topology/topology2/include/bench/host_gateway_pipelines_s16_16k.conf Switch to BENCH pipeline indices and add explicit 16 kHz rates
tools/topology/topology2/development/tplg-targets-bench.cmake Add mfcc to bench component list and parameters (BENCH_MFCC_PARAMS)
tools/topology/topology2/cavs-benchmark-sdw.conf Include MFCC component + add BENCH_CONFIG entries mfcc16/24/32
tools/topology/topology2/cavs-benchmark-hda.conf Include MFCC component + add BENCH_CONFIG entries mfcc16/24/32
tools/testbench/file.c Adjust file write init to set component type HOST for capture direction
src/audio/mfcc/tune/setup_mfcc.m Update output paths to repo tools/ dir and adjust addpath/rmpath locations
src/audio/mfcc/tune/run_mfcc.sh Update to run sof-testbench4 with a topology2 benchmark MFCC tplg
src/audio/mfcc/tune/decode_ceps.m New helper to parse MFCC output stream and plot cepstral coefficients
src/audio/mfcc/tune/README.txt New README documenting MFCC config generation, testbench run, and plotting
Comments suppressed due to low confidence (2)

src/audio/mfcc/tune/run_mfcc.sh:19

  • OPT already contains “-i $RAW_INPUT -o $RAW_OUTPUT”, but the testbench invocation also appends another “-i … -o …”. This duplicates CLI options and can lead to parsing errors or unintended overrides; keep input/output specified in only one place.
    src/audio/mfcc/tune/run_mfcc.sh:16
  • The script generates a mono raw input (sox uses “-c 1”), but OPT configures the testbench for 2 channels (“-c 2”) and the preceding comment also says “1 channel”. Align channel count across the sox conversion, the testbench options, and the comment.

Comment thread tools/topology/topology2/include/bench/one_input_output_format_s16_16k.conf Outdated
Comment thread tools/topology/topology2/include/bench/one_input_output_format_s24_16k.conf Outdated
Comment thread tools/topology/topology2/include/bench/one_input_output_format_s32_16k.conf Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 21 out of 23 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

src/audio/mfcc/tune/run_mfcc.sh:15

  • The script sets -c 2 in OPT but the sox conversion generates a 1-channel raw file (-c 1). This will misconfigure the testbench run. Align the channel count between sox and the testbench options (and update the nearby comment accordingly).
    src/audio/mfcc/tune/run_mfcc.sh:18
  • OPT already includes -i $RAW_INPUT -o $RAW_OUTPUT, but the testbench invocation appends -i/-o again. This double-specification can lead to confusing behavior depending on argument parsing; keep -i/-o in one place only.

Comment on lines +447 to +459

"mfcc16" {
<include/bench/mfcc_s16.conf>
}

"mfcc24" {
<include/bench/mfcc_s24.conf>
}

"mfcc32" {
<include/bench/mfcc_s32.conf>
}

Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

The new MFCC bench configs include 16 kHz audio formats (*_16k.conf), but in this SDW benchmark topology the ALH DAI/coprocessor widgets are explicitly constrained to $JACK_RATE (default 48000) for both input/output formats. This will create a hard sample-rate mismatch on routes that connect mfcc.* to $BENCH_*_DAI_COPIER. Consider overriding JACK_RATE to 16000 for the mfcc* BENCH_CONFIGs (or inserting SRC/conversion), or omit MFCC from the SDW benchmark until the rate domains match.

Suggested change
"mfcc16" {
<include/bench/mfcc_s16.conf>
}
"mfcc24" {
<include/bench/mfcc_s24.conf>
}
"mfcc32" {
<include/bench/mfcc_s32.conf>
}
# MFCC benchmark configs are intentionally not enabled in the SDW
# benchmark topology because the SDW ALH DAI/coprocessor side is
# constrained to $JACK_RATE while MFCC bench configs operate in a
# different rate domain. Re-enable only after adding a matching rate
# override or explicit sample-rate conversion.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Right, I'll do as suggested and remove for now MFCC from SDW. It can be done since it's not usable and HDA variant is sufficient for testbench runs.

There was earlier only topology1 for MFCC. This patch adds
topologies sof-hda-benchmark-mfcc16/24/32.tplg to be able to
test the component in testbench environment.

Note: Due to the set 16 kHz DAI rate these can't be used in real
devices. It will need a capture pipeline with 48 kHz to 16 kHz SRC.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch updates the run script run_mfcc.sh to use topology2
and the current sof-testbech4.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
This patch moves the files from tools/tune/mfcc to directory
src/audio/mfcc/tune. The patchs are fixed for the new location.

Signed-off-by: Seppo Ingalsuo <seppo.ingalsuo@linux.intel.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 21 out of 23 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (2)

src/audio/mfcc/tune/run_mfcc.sh:12

  • run_mfcc.sh assumes SOF_WORKSPACE is set when constructing TESTBENCH and TOPOLOGY paths. If it is unset/empty, the script will fail later with confusing file-not-found errors. Consider adding an early check that SOF_WORKSPACE is set (and points to a valid tree) and print a clear error message if not.
    src/audio/mfcc/tune/run_mfcc.sh:15
  • The script converts the input into a 1-channel raw file (sox ... -c 1 ... "$RAW_INPUT") but then invokes sof-testbench4 with -c 2 (input channels). This channel-count mismatch will cause the testbench to interpret the raw stream incorrectly. Align these (either generate 2-channel raw from sox or run the testbench with -c 1 and use a 1-channel topology).

"gain"
"igo_nr"
"level_multiplier"
"mfcc"
Copy link

Copilot AI Apr 27, 2026

Choose a reason for hiding this comment

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

mfcc is now included in the generic components list, which means this CMake loop will also generate SDW benchmark targets for MFCC. However cavs-benchmark-sdw.conf intentionally does not define any BENCH_CONFIG keys for mfcc16/24/32, so those generated SDW topologies will silently omit MFCC and produce misleading/incorrect artifacts. Consider either excluding MFCC from the SDW target generation here (special-case comp == mfcc) or adding properly rate-matched MFCC entries to the SDW IncludeByKey.BENCH_CONFIG block.

Suggested change
"mfcc"

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I don't prefer to do that to not create CMake complexity that would be changed again later. The tests are not running the SDW benchmark variants. The topology built for SDW now is just empty. I'll create in later phase topologies for real devices with SRC in a split pipeline from the module copier.

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.

3 participants