Line data Source code
1 : #pragma once
2 :
3 : // 3-band parametric equalizer for tone correction and pedal-chain shaping.
4 : // The Equalizer cascades active biquads H(z)=H_lowShelf(z)*H_peakMid(z)*H_highShelf(z),
5 : // giving independent low-shelf, peaking-mid, and high-shelf gain control.
6 :
7 : #include "audio/effects/effect.h"
8 : #include "audio/dsp/biquad.h"
9 :
10 : namespace Amplitron {
11 :
12 3 : class Equalizer : public Effect {
13 : public:
14 : Equalizer();
15 : void process(float* buffer, int num_samples) override;
16 : void set_sample_rate(int sample_rate) override;
17 : void reset() override;
18 125 : const char* name() const override { return "Equalizer"; }
19 3 : const char* type_id() const override { return "Equalizer"; }
20 170 : std::vector<EffectParam>& params() override { return params_; }
21 :
22 : private:
23 : std::vector<EffectParam> params_;
24 :
25 : Biquad low_shelf_;
26 : Biquad mid_peak_;
27 : Biquad high_shelf_;
28 :
29 : // One-pole smoothing states (avoids zipper noise on UI parameter jumps)
30 : float bass_state_ = 0.0f;
31 : float mid_state_ = 0.0f;
32 : float treble_state_ = 0.0f;
33 : float presence_state_ = 0.0f;
34 :
35 : // Cached parameter values for dirty-check
36 : float cached_bass_ = -999.0f;
37 : float cached_mid_ = -999.0f;
38 : float cached_treble_ = -999.0f;
39 : float cached_presence_ = -999.0f;
40 :
41 : void recompute_coefficients_if_dirty();
42 : };
43 :
44 : } // namespace Amplitron
|