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
+39
View File
@@ -0,0 +1,39 @@
#include "EQ.h"
namespace serum
{
void EQUnit::prepare (double sampleRate, int)
{
sr = sampleRate;
lowL.setSampleRate (sr); lowR.setSampleRate (sr);
midL.setSampleRate (sr); midR.setSampleRate (sr);
highL.setSampleRate (sr); highR.setSampleRate (sr);
reset();
}
void EQUnit::reset()
{
lowL.clear(); lowR.clear(); midL.clear(); midR.clear(); highL.clear(); highR.clear();
}
void EQUnit::process (float* l, float* r, int numSamples, const float p[4])
{
const double lowGain = (p[0] - 0.5f) * 2.0f * 15.0;
const double midGain = (p[1] - 0.5f) * 2.0f * 12.0;
const double highGain = (p[2] - 0.5f) * 2.0f * 15.0;
const double midFreq = 200.0 + p[3] * 4800.0;
lowL.setLowShelf (200.0, lowGain); lowR.setLowShelf (200.0, lowGain);
midL.setPeak (midFreq, midGain, 0.8); midR.setPeak (midFreq, midGain, 0.8);
highL.setHighShelf (4000.0, highGain); highR.setHighShelf (4000.0, highGain);
for (int i = 0; i < numSamples; ++i)
{
const float xL = l[i], xR = r[i];
l[i] = highL.process (midL.process (lowL.process (xL)));
r[i] = highR.process (midR.process (lowR.process (xR)));
}
}
} // namespace serum