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

Mod Matrix does the Clampin' #768

Closed
baconpaul opened this issue Feb 19, 2024 · 1 comment · Fixed by #1386
Closed

Mod Matrix does the Clampin' #768

baconpaul opened this issue Feb 19, 2024 · 1 comment · Fixed by #1386

Comments

@baconpaul
Copy link
Contributor

Once we have #766 and #767 fully resolved, the mod matrix can clamp outputs for us rather than us having to sprinkle clamps through every part of the DSP code

@baconpaul
Copy link
Contributor Author

The way to do this is roughly as follows

in basic-blocks ModMatrix.h you see

        if constexpr (ModMatrix<TR>::supportsCurves)
            {
                auto offs = *(r.source) * sourceViaVal;
                if (r.curveFn)
                    *(r.target) += *(r.depth) * r.depthScale * r.curveFn(offs);
                else
                    *(r.target) += *(r.depth) * r.depthScale * offs;
            }
            else
            {
                *(r.target) += *(r.source) * *(r.depth) * r.depthScale * sourceViaVal;
            }

so right after that add basically an

if constexprt (ModMatrix<TR>::providesTargetlBounds)
  *(r.target) = std::clamp(*(r.target), r.targetMin, r.targetMax)

and add the min and max to that. Then in the VoiceMatrix in scxt set providesTargetBounds to true and set the min and max off the metadata when the target is changed or initialized.

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 a pull request may close this issue.

1 participant