feat(fx): add effect rack and effect units

This commit is contained in:
2026-09-08 14:55:22 +02:00
parent 4021b9cdf7
commit 5a80534a2e
21 changed files with 1104 additions and 0 deletions
+44
View File
@@ -0,0 +1,44 @@
#include "Distortion.h"
namespace serum
{
void DistortionUnit::prepare (double sampleRate, int)
{
sr = sampleRate;
lpL.setSampleRate (sr); lpR.setSampleRate (sr);
lpL.setLowpass (8000.0, 0.7071); lpR.setLowpass (8000.0, 0.7071);
reset();
}
void DistortionUnit::reset()
{
lpL.clear(); lpR.clear();
}
float DistortionUnit::shape (float x, float shapeParam) noexcept
{
if (shapeParam < 0.33f) return std::tanh (x);
if (shapeParam < 0.66f) return juce::jlimit (-1.0f, 1.0f, x);
return std::sin (x * 1.5707963267948966f); // sine fold
}
void DistortionUnit::process (float* l, float* r, int numSamples, const float p[4])
{
const float drive = 1.0f + p[0] * 24.0f;
const float shapeP = p[1];
const float output = 0.4f + p[3] * 1.2f;
// Tone: re-tune the lowpass from 800..16000 Hz.
const double toneHz = 800.0 + p[2] * 15200.0;
lpL.setLowpass (toneHz, 0.7071);
lpR.setLowpass (toneHz, 0.7071);
for (int i = 0; i < numSamples; ++i)
{
l[i] = lpL.process (shape (l[i] * drive, shapeP) * output);
r[i] = lpR.process (shape (r[i] * drive, shapeP) * output);
}
}
} // namespace serum