Merge 3 virtual calls into 1

This commit is contained in:
Jean Pierre Cimalando 2020-02-07 19:17:21 +01:00
parent 39e150f3d0
commit c2307cd459
2 changed files with 36 additions and 25 deletions

View file

@ -116,9 +116,7 @@ void Filter::process(const float *const in[], float *const out[], float cutoff,
return; return;
} }
dsp->setCutoff(cutoff); dsp->configureStandard(cutoff, q, pksh);
dsp->setQ(q);
dsp->setPkShGain(pksh);
dsp->compute(nframes, const_cast<float **>(in), const_cast<float **>(out)); dsp->compute(nframes, const_cast<float **>(in), const_cast<float **>(out));
} }
@ -148,9 +146,7 @@ void Filter::processModulated(const float *const in[], float *const out[], const
current_out[c] = out[c] + frame; current_out[c] = out[c] + frame;
} }
dsp->setCutoff(cutoff[frame]); dsp->configureStandard(cutoff[frame], q[frame], pksh[frame]);
dsp->setQ(q[frame]);
dsp->setPkShGain(pksh[frame]);
dsp->compute(current, const_cast<float **>(current_in), const_cast<float **>(current_out)); dsp->compute(current, const_cast<float **>(current_in), const_cast<float **>(current_out));
frame += current; frame += current;
@ -289,9 +285,7 @@ void FilterEq::process(const float *const in[], float *const out[], float cutoff
return; return;
} }
dsp->setCutoff(cutoff); dsp->configureEq(cutoff, bw, pksh);
dsp->setBandwidth(bw);
dsp->setPkShGain(pksh);
dsp->compute(nframes, const_cast<float **>(in), const_cast<float **>(out)); dsp->compute(nframes, const_cast<float **>(in), const_cast<float **>(out));
} }
@ -321,9 +315,7 @@ void FilterEq::processModulated(const float *const in[], float *const out[], con
current_out[c] = out[c] + frame; current_out[c] = out[c] + frame;
} }
dsp->setCutoff(cutoff[frame]); dsp->configureEq(cutoff[frame], bw[frame], pksh[frame]);
dsp->setBandwidth(bw[frame]);
dsp->setPkShGain(pksh[frame]);
dsp->compute(current, const_cast<float **>(current_in), const_cast<float **>(current_out)); dsp->compute(current, const_cast<float **>(current_in), const_cast<float **>(current_out));
frame += current; frame += current;

View file

@ -18,10 +18,8 @@ public:
virtual void instanceClear() = 0; virtual void instanceClear() = 0;
virtual void compute(int, float **, float **) = 0; virtual void compute(int, float **, float **) = 0;
virtual void setCutoff(float) {} virtual void configureStandard(float, float, float) {}
virtual void setQ(float) {} virtual void configureEq(float, float, float) {}
virtual void setBandwidth(float) {}
virtual void setPkShGain(float) {}
}; };
#if defined(__GNUC__) || defined(__clang__) #if defined(__GNUC__) || defined(__clang__)
@ -88,8 +86,12 @@ public:
Parameterized by cutoff and Q Parameterized by cutoff and Q
*/ */
template <class F> struct sfzFilter : public F { template <class F> struct sfzFilter : public F {
void setCutoff(float v) override { F::fCutoff = v; } void configureStandard(float cutoff, float q, float pksh) override
void setQ(float v) override { F::fQ = v; } {
F::fCutoff = cutoff;
F::fQ = q;
(void)pksh;
}
}; };
/** /**
@ -97,7 +99,12 @@ template <class F> struct sfzFilter : public F {
Parameterized by cutoff only Parameterized by cutoff only
*/ */
template <class F> struct sfzFilterNoQ : public F { template <class F> struct sfzFilterNoQ : public F {
void setCutoff(float v) override { F::fCutoff = v; } void configureStandard(float cutoff, float q, float pksh) override
{
F::fCutoff = cutoff;
(void)q;
(void)pksh;
}
}; };
/** /**
@ -105,6 +112,12 @@ template <class F> struct sfzFilterNoQ : public F {
Not parameterized Not parameterized
*/ */
template <class F> struct sfzFilterNoCutoff : public F { template <class F> struct sfzFilterNoCutoff : public F {
void configureStandard(float cutoff, float q, float pksh) override
{
(void)cutoff;
(void)q;
(void)pksh;
}
}; };
/** /**
@ -112,9 +125,12 @@ template <class F> struct sfzFilterNoCutoff : public F {
Parameterized by cutoff, Q, peak/shelf gain Parameterized by cutoff, Q, peak/shelf gain
*/ */
template <class F> struct sfzFilterPkSh : public F { template <class F> struct sfzFilterPkSh : public F {
void setCutoff(float v) override { F::fCutoff = v; } void configureStandard(float cutoff, float q, float pksh) override
void setQ(float v) override { F::fQ = v; } {
void setPkShGain(float v) override { F::fPkShGain = v; } F::fCutoff = cutoff;
F::fQ = q;
F::fPkShGain = pksh;
}
}; };
/** /**
@ -122,9 +138,12 @@ template <class F> struct sfzFilterPkSh : public F {
Parameterized by cutoff, bandwidth, peak/shelf gain Parameterized by cutoff, bandwidth, peak/shelf gain
*/ */
template <class F> struct sfzFilterEq : public F { template <class F> struct sfzFilterEq : public F {
void setCutoff(float v) override { F::fCutoff = v; } void configureEq(float cutoff, float bw, float pksh) override
void setBandwidth(float v) override { F::fBandwidth = v; } {
void setPkShGain(float v) override { F::fPkShGain = v; } F::fCutoff = cutoff;
F::fBandwidth = bw;
F::fPkShGain = pksh;
}
}; };
struct sfzLpf1p final : public sfzFilterNoQ<faustLpf1p> {}; struct sfzLpf1p final : public sfzFilterNoQ<faustLpf1p> {};