Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tools: Topology2: Swap gain and eqiir in DMIC capture #9700

Merged
merged 1 commit into from
Dec 4, 2024

Conversation

singalsu
Copy link
Collaborator

@singalsu singalsu commented Dec 2, 2024

This patch swaps the order of IIR and gain components in capture pipeline. In IPC4 systems the gain component can only attenuate the signal, largest gain is 0 dB (pass-through). The IIR component can be set up to amplify the signal by e.g. +20 dB that is currently default in many topologies. The gain can possibly distort the signal in loud environment.

With current "dai-copier -> eqiir -> gain -> module-copier" topology the user configurable gain (ALSA mixer control) can't prevent clipping of audio signal in IIR. While with swapped order "dai-copier -> gain -> eqiir -> module-copier" using attenuation in gain component can be used to prevent audio signal clipping in IIR. It would be useful in capturing audio in a very loud environment.

Since the pipeline is 32-bits there is no practical loss of audio quality even if there would be first attenuation and then gain. Plus normally the gain control for Dmic0 is set to maximum.

@singalsu
Copy link
Collaborator Author

singalsu commented Dec 2, 2024

An example of this is in the plot below. The recordings were done with sof-hda-generic-2ch.tplg with simulating very loud sound by rubbing the microphone ports in notebook lid (no yelling in home office :) . The upper plot is before and and lower after this change. In upper with amplifying IIR the peaks are clipped to max. PCM codes and then brought down with volume set to -10 dB. In lower plot with proposed topology change the capture is more linear with no saturated intermediate PCM codes values.

Screenshot from 2024-12-02 12-34-56

This patch swaps the order of IIR and gain components in capture
pipeline. In IPC4 systems the gain component can only attenuate the
signal, largest gain is 0 dB (pass-through). The IIR component can be
set up to amplify the signal by e.g. +20 dB that is currently default
in many topologies. The gain can possibly distort the signal in loud
environment.

With current "dai-copier -> eqiir -> gain -> module-copier" topology
the user configurable gain (ALSA mixer control) can't prevent clipping
of audio signal in IIR. While with swapped order "dai-copier -> gain
-> eqiir -> module-copier" using attenuation in gain component can be
used to prevent audio signal clipping in IIR. It would be useful in
capturing audio in a very loud environment.

Since the pipeline is 32-bits there is no practical loss of audio
quality even if there would be first attenuation and then gain. Plus
normally the gain control for Dmic0 is set to maximum.

Signed-off-by: Seppo Ingalsuo <[email protected]>
@singalsu singalsu force-pushed the dmic_capture_swap_iir_gain branch from ea8855e to 99e857a Compare December 2, 2024 11:06
Copy link
Member

@lgirdwood lgirdwood left a comment

Choose a reason for hiding this comment

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

LGTM, nice fix @singalsu

@singalsu singalsu marked this pull request as ready for review December 2, 2024 17:29
@singalsu singalsu requested a review from kv2019i December 2, 2024 17:31
@lgirdwood
Copy link
Member

SOFCI TEST

@lgirdwood
Copy link
Member

Unrelated CI failure for pause and alsabat on LNL

@lgirdwood lgirdwood merged commit 26782ab into thesofproject:main Dec 4, 2024
43 of 47 checks passed
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