#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