MCPcopy Create free account
hub / github.com/VCVRack/Befaco / onSampleRateChange

Method onSampleRateChange

src/Bandit.cpp:100–119  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

98 }
99
100 void onSampleRateChange() override {
101 const float sr = APP->engine->getSampleRate();
102 const float lowFc = 300.f / sr;
103 const float lowMidFc = 750.f / sr;
104 const float highMidFc = 1500.f / sr;
105 const float highFc = 3800.f / sr;
106 // Qs for cascaded biquads to get Butterworth response, see https://www.earlevel.com/main/2016/09/29/cascading-filters/
107 // technically only for LOWPASS and HIGHPASS, but seems to work well for BANDPASS too
108 const float Q[2] = {0.54119610f, 1.3065630f};
109 const float V = 1.f;
110
111 for (int i = 0; i < 4; ++i) {
112 for (int stage = 0; stage < 2; ++stage) {
113 filterLow[i][stage].setParameters(dsp::TBiquadFilter<float_4>::Type::LOWPASS, lowFc, Q[stage], V);
114 filterLowMid[i][stage].setParameters(dsp::TBiquadFilter<float_4>::Type::BANDPASS, lowMidFc, Q[stage], V);
115 filterHighMid[i][stage].setParameters(dsp::TBiquadFilter<float_4>::Type::BANDPASS, highMidFc, Q[stage], V);
116 filterHigh[i][stage].setParameters(dsp::TBiquadFilter<float_4>::Type::HIGHPASS, highFc, Q[stage], V);
117 }
118 }
119 }
120
121 void processBypass(const ProcessArgs& args) override {
122 const int maxPolyphony = std::max({1, inputs[ALL_INPUT].getChannels(), inputs[LOW_INPUT].getChannels(),

Callers

nothing calls this directly

Calls 2

getSampleRateMethod · 0.80
setParametersMethod · 0.45

Tested by

no test coverage detected