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

Fix gain compensation for the Moog filter #11177

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions src/engine/filters/enginefiltermoogladder4.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,11 +93,23 @@ class EngineFilterMoogLadderBase : public EngineObjectConstIn {
// Resonance correction for self oscillation ~4
m_kacrNew = resonance * (-3.9364f * (kfc * kfc) + 1.8409f * kfc + 0.9968f);

// See https://github.com/mixxxdj/mixxx/pull/11177 for the Jupyter
// notebook used to derive this
if (MODE == MoogMode::HighPassOversampling || MODE == MoogMode::HighPass) {
m_postGainNew = 1;
// This for all intents and purposes is just 1.0, so let's just stick with that
// m_postGainNew = 0.9999999983339118f + (4.58745459575558e-13f * resonance);
m_postGainNew = 1.0;
} else {
m_postGainNew = (1 + resonance / 4 * (1.1f + cutoff / sampleRate * 3.5f))
* (2 - (1.0f - resonance / 4) * (1.0f - resonance / 4));
// Analyzing this filter as a linear system will show a small dip in
// passband/DC gain when the cutoff frequency is around 10 kHz:
// https://github.com/mixxxdj/mixxx/pull/11177#issuecomment-1374833386
//
// In practice this is either not a noticeable issue when running
// music through the filter, or it might even be desirable as it
// keeps the overall gain increase a bit lower when the resonance is
// turned up and the cutoff frequency is around 10 kHz. This may be
// worth more experimentation in the future.
m_postGainNew = 1.0001784074555027f + (0.9331585678097162f * resonance);
}

m_doRamping = true;
Expand Down