Skip to content

Gain effect - #15955

Merged
daschuer merged 2 commits into
mixxxdj:mainfrom
pri-yan-shu:gain-effect
Mar 26, 2026
Merged

Gain effect#15955
daschuer merged 2 commits into
mixxxdj:mainfrom
pri-yan-shu:gain-effect

Conversation

@pri-yan-shu

Copy link
Copy Markdown
Contributor

Simple one knob effect for audio gain.

@pri-yan-shu

Copy link
Copy Markdown
Contributor Author

Currently it allows to change the gain from -24 db to 24 db, would it be better to have additional parameters to set the range of the gain, like minimum and maximum gain?

@Eve00000

Eve00000 commented Feb 7, 2026

Copy link
Copy Markdown
Contributor

Welcome at Mixxx!
As a first-time contributor we need you to sign the Mixxx Contributor Agreement and comment here when you have done so. It gives us permission to distribute your contribution under the GPL v2 or later license and the Apple Mac App Store. It is also helpful for us to have contact information for contributors in case we may need it in the future.

What do you understand as 'gain'?
Gain is not an effect, what would a gain-effect do in your opinion?
See the manual for more info about gain.

IMO if you want to adjust the gain of the samplers in a more visible way than in the smaller control in the GUI (and maybe eq, pan ...) it would be better to add a dedicated sampler-channel in the mixer. A powerful gain can create distorted music and even damage equipment, there should be a safety/limiter to not 'overgain' the input (clipping).

@pri-yan-shu

Copy link
Copy Markdown
Contributor Author

Thanks for the response, I signed the agreement.

I forgot to mention, this effect is related to the issue #14679, about having a dedicated utility effect for controlling the gain at any stage in the effect chain itself. I'm open to discussing and implementing a better way to implement this if possible.

About overgain safety, I can add clipping to this effect as a toggle button.

pOutput[i] = pInput[i] * gain_ramped;

if (clip) {
pOutput[i] = math_clamp(pOutput[i], -1.0f, 1.0f);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hard clipping like that creates extra audible artefacts.
It sounds better if you introduce a tanh clipper.

inline CSAMPLE tanh_approx(CSAMPLE input) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Makes sense

@pri-yan-shu

Copy link
Copy Markdown
Contributor Author

@daschuer can you review the changes?

@acolombier

Copy link
Copy Markdown
Member

@daschuer could you please confirm your change request has been addressed?

@acolombier acolombier linked an issue Mar 5, 2026 that may be closed by this pull request
@daschuer

Copy link
Copy Markdown
Member

The clipping feature works good:

Here a the clipped 440 Hz sine:
grafik

This is the same without clipping:
grafik

Ramping when enabling this effect cause a crackling because of missing ramping:

grafik

We need to avoid rectangular changes, because they contain all frequencies.

The same happens when the effect is stopped:

grafik

Gain changes itself are already well ramped:

grafik

@daschuer

Copy link
Copy Markdown
Member

Btw. I use Audacity to create a 440 Hz test sound and to visualize the recordings.

@daschuer

Copy link
Copy Markdown
Member

TODO: Add ramping when enabling and disabling.

@pri-yan-shu

Copy link
Copy Markdown
Contributor Author

Good tip about audacity, much more accurate than judging by ear. I'll keep this in mind while testing for ramping or similar issues.

@pri-yan-shu

Copy link
Copy Markdown
Contributor Author

@daschuer Can you review the changes made?

@daschuer daschuer left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Works like a charm now. And LGTM. Well done.

@daschuer
daschuer merged commit 8327e8b into mixxxdj:main Mar 26, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Wishlist: Gain effect

4 participants