[SCM] calf/master: + EQ-5: refactoring to eliminate code duplication, side effect: stereo meters

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:39:51 UTC 2013


The following commit has been merged in the master branch:
commit 7b713aa896efba0dbf189d58aabdc9724b666ddc
Author: Krzysztof Foltman <wdev at foltman.com>
Date:   Wed Nov 18 20:03:36 2009 +0000

    + EQ-5: refactoring to eliminate code duplication, side effect: stereo meters

diff --git a/gui/gui-equalizer5band.xml b/gui/gui-equalizer5band.xml
index 862f6cc..5e06e35 100644
--- a/gui/gui-equalizer5band.xml
+++ b/gui/gui-equalizer5band.xml
@@ -2,9 +2,14 @@
     <vbox attach-x="0" attach-y="0">
         <frame label="Input">
             <vbox spacing="15">
-                <table rows="1" cols="3">
-                    <vumeter param="meter_in" hold="1.5" falloff="2.5"  attach-x="1" attach-y="0" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
-                    <led param="clip_in" attach-x="2" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" />
+                <table rows="2" cols="3">
+                    <label param="meter_inL" attach-x="0" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="L"/>
+                    <vumeter param="meter_inL" hold="1.5" falloff="2.5"  attach-x="1" attach-y="0" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+                    <led param="clip_inL" attach-x="2" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" />
+                    
+                    <label param="meter_inR" attach-x="0" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="R"/>
+                    <vumeter param="meter_inR" hold="1.5" falloff="2.5" attach-x="1" attach-y="1" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+                    <led param="clip_inR" attach-x="2" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0"/>
                 </table>
                 <hbox>
                     <vbox expand="0">
@@ -24,17 +29,17 @@
         <frame label="Lowshelf">
             <table rows="2" cols="2" homogeneous="1">
                 <vbox attach-x="0" attach-y="0">
-                    <label param="ls_freq" />
+                    <label param="ls_freq" text="Frequency" />
                     <knob param="ls_freq" />
                     <value param="ls_freq" />
                 </vbox>
                 <vbox attach-x="1" attach-y="0">
-                    <label param="ls_level" />
+                    <label param="ls_level" text="Level" />
                     <knob param="ls_level" type="1" />
                     <value param="ls_level" />
                 </vbox>
                 <vbox attach-x="1" attach-y="1" fill-y="0">
-                    <label param="ls_active"/>
+                    <label param="ls_active" text="Active"/>
                     <toggle size="1" param="ls_active" />
                 </vbox>
             </table>
@@ -51,22 +56,22 @@
         <frame label="Parametric 1">
             <table rows="2" cols="2" homogeneous="1">
                 <vbox attach-x="0" attach-y="0">
-                    <label param="p1_freq" />
+                    <label param="p1_freq" text="Frequency" />
                     <knob param="p1_freq" />
                     <value param="p1_freq" />
                 </vbox>
                 <vbox attach-x="1" attach-y="0">
-                    <label param="p1_level" />
+                    <label param="p1_level" text="Level" />
                     <knob param="p1_level" type="1" />
                     <value param="p1_level" />
                 </vbox>
                 <vbox attach-x="0" attach-y="1">
-                    <label param="p1_q" />
+                    <label param="p1_q" text="Q" />
                     <knob param="p1_q" />
                     <value param="p1_q" />
                 </vbox>
                 <vbox attach-x="1" attach-y="1" fill-y="0">
-                    <label param="p1_active" />
+                    <label param="p1_active" text="Active" />
                     <toggle size="1" param="p1_active" />
                 </vbox>
             </table>
@@ -74,22 +79,22 @@
         <frame label="Parametric 2">
             <table rows="2" cols="2" homogeneous="1">
                 <vbox attach-x="0" attach-y="0">
-                    <label param="p2_freq" />
+                    <label param="p2_freq" text="Frequency" />
                     <knob param="p2_freq" />
                     <value param="p2_freq" />
                 </vbox>
                 <vbox attach-x="1" attach-y="0">
-                    <label param="p2_level" />
+                    <label param="p2_level" text="Level" />
                     <knob param="p2_level" type="1" />
                     <value param="p2_level" />
                 </vbox>
                 <vbox attach-x="0" attach-y="1">
-                    <label param="p2_q" />
+                    <label param="p2_q" text="Q" />
                     <knob param="p2_q" />
                     <value param="p2_q" />
                 </vbox>
                 <vbox attach-x="1" attach-y="1" fill-y="0">
-                    <label param="p2_active" />
+                    <label param="p2_active" text="Active" />
                     <toggle size="1" param="p2_active" />
                 </vbox>
             </table>
@@ -97,22 +102,22 @@
         <frame label="Parametric 3">
             <table rows="2" cols="2" homogeneous="1">
                 <vbox attach-x="0" attach-y="0">
-                    <label param="p3_freq" />
+                    <label param="p3_freq" text="Frequency" />
                     <knob param="p3_freq" />
                     <value param="p3_freq" />
                 </vbox>
                 <vbox attach-x="1" attach-y="0">
-                    <label param="p3_level" />
+                    <label param="p3_level" text="Level" />
                     <knob param="p3_level" type="1" />
                     <value param="p3_level" />
                 </vbox>
                 <vbox attach-x="0" attach-y="1">
-                    <label param="p3_q" />
+                    <label param="p3_q" text="Q" />
                     <knob param="p3_q" />
                     <value param="p3_q" />
                 </vbox>
                 <vbox attach-x="1" attach-y="1" fill-y="0">
-                    <label param="p3_active" />
+                    <label param="p3_active" text="Active" />
                     <toggle size="1" param="p3_active" />
                 </vbox>
             </table>
@@ -123,8 +128,13 @@
         <frame label="Output">
             <vbox spacing="15">
                 <table rows="2" cols="3">
-                    <vumeter param="meter_out" hold="1.5" falloff="2.5" attach-x="1" attach-y="0" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
-                    <led param="clip_out" mode="1" attach-x="2" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" />
+                    <label param="meter_outL"  attach-x="0" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="L"/>
+                    <vumeter param="meter_outL" hold="1.5" falloff="2.5" attach-x="1" attach-y="0" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+                    <led param="clip_outL" mode="1" attach-x="2" attach-y="0" fill-x="0" expand-x="0" fill-y="0" expand-y="0" />
+                    
+                    <label param="meter_outR"  attach-x="0" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0" text="R"/>
+                    <vumeter param="meter_outR" hold="1.5" falloff="2.5" attach-x="1" attach-y="1" fill-x="1" expand-x="1" fill-y="0" expand-y="0"/>
+                    <led param="clip_outR" mode="1" attach-x="2" attach-y="1" fill-x="0" expand-x="0" fill-y="0" expand-y="0"/>
                 </table>
                 <hbox>
                     <vbox>
@@ -140,17 +150,17 @@
         <frame label="Highshelf">
             <table rows="2" cols="2" homogeneous="1">
                 <vbox attach-x="0" attach-y="0">
-                    <label param="hs_freq" />
+                    <label param="hs_freq" text="Frequency"/>
                     <knob param="hs_freq" />
                     <value param="hs_freq" />
                 </vbox>
                 <vbox attach-x="1" attach-y="0">
-                    <label param="hs_level" />
+                    <label param="hs_level" text="Level"/>
                     <knob param="hs_level" type="1" />
                     <value param="hs_level" />
                 </vbox>
                 <vbox attach-x="1" attach-y="1" fill-y="0">
-                    <label param="hs_active" />
+                    <label param="hs_active" text="Active"/>
                     <toggle size="1" param="hs_active" />
                 </vbox>
             </table>
diff --git a/src/calf/metadata.h b/src/calf/metadata.h
index 2d0f3d3..a92bb64 100644
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@ -192,14 +192,18 @@ struct deesser_metadata: public plugin_metadata<deesser_metadata>
 struct equalizer5band_metadata: public plugin_metadata<equalizer5band_metadata>
 {
     enum { in_count = 2, out_count = 2, ins_optional = 0, outs_optional = 0, support_midi = false, require_midi = false, rt_capable = true };
-    enum { param_bypass, param_level_in, param_level_out, param_meter_in,
-           param_meter_out, param_clip_in, param_clip_out,
+    enum { param_bypass, param_level_in, param_level_out, param_meter_inL, param_meter_inR,
+           param_meter_outL, param_meter_outR, param_clip_inL, param_clip_outL, param_clip_inR, param_clip_outR,
            param_ls_active, param_ls_level, param_ls_freq,
            param_hs_active, param_hs_level, param_hs_freq,
            param_p1_active, param_p1_level, param_p1_freq, param_p1_q,
            param_p2_active, param_p2_level, param_p2_freq, param_p2_q,
            param_p3_active, param_p3_level, param_p3_freq, param_p3_q,
            param_count };
+    // dummy parameter numbers, shouldn't be used EVER, they're only there to avoid pushing LP/HP filters to a separate class
+    // and potentially making inlining and optimization harder for the compiler
+    enum { param_lp_active = 0xDEADBEEF, param_hp_active, param_hp_mode, param_lp_mode, param_hp_freq, param_lp_freq };
+    enum { PeakBands = 3, first_graph_param = param_ls_active, last_graph_param = param_p3_q };
     PLUGIN_NAME_ID_LABEL("equalizer5band", "equalizer5band", "Equalizer 5 Band")
 };
 /// Markus's 8-band EQ - metadata
diff --git a/src/calf/modules.h b/src/calf/modules.h
index 99202aa..d33fe95 100644
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@ -1039,7 +1039,7 @@ public:
 };
 
 /// Equalizer N Band by Markus Schmidt (based on Krzysztof's filters)
-template<class BaseClass>
+template<class BaseClass, bool has_lphp>
 class equalizerNband_audio_module: public audio_module<BaseClass>, public frequency_response_line_graph {
 public:
     typedef audio_module<BaseClass> AM;
@@ -1057,9 +1057,12 @@ private:
     float old_params_for_graph[graph_param_count];
     uint32_t clip_inL, clip_outL, clip_inR, clip_outR;
     float meter_inL, meter_outL, meter_inR, meter_outR;
+    CalfEqMode hp_mode, lp_mode;
     biquad_d2<float> hp[3][2], lp[3][2];
     biquad_d2<float> lsL, lsR, hsL, hsR;
     biquad_d2<float> pL[PeakBands], pR[PeakBands];
+    
+    inline void process_hplp(float &left, float &right);
 public:
     typedef std::complex<double> cfloat;
     float *ins[in_count];
@@ -1071,6 +1074,7 @@ public:
     equalizerNband_audio_module();
     void activate();
     void deactivate();
+
     void params_changed();
     float freq_gain(int index, double freq, uint32_t sr);
     void set_sample_rate(uint32_t sr)
@@ -1083,50 +1087,9 @@ public:
     int  get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline);
 };
 
-typedef equalizerNband_audio_module<equalizer8band_metadata> equalizer8band_audio_module;
-typedef equalizerNband_audio_module<equalizer12band_metadata> equalizer12band_audio_module;
-
-/// Equalizer 5 Band by Markus Schmidt (based on Krzysztof's filters)
-class equalizer5band_audio_module: public audio_module<equalizer5band_metadata>, public frequency_response_line_graph  {
-private:
-    float ls_level_old, ls_freq_old;
-    float hs_level_old, hs_freq_old;
-    float p_level_old[3], p_freq_old[3], p_q_old[3];
-    float ls_level_old1, ls_freq_old1, ls_active_old1;
-    float hs_level_old1, hs_freq_old1, hs_active_old1;
-    float p_level_old1[3], p_freq_old1[3], p_q_old1[3], p_active_old1[3];
-    uint32_t clip_in, clip_out;
-    float meter_in, meter_out;
-    biquad_d2<float> lsL, lsR, hsL, hsR;
-    biquad_d2<float> pL[3], pR[3];
-public:
-    typedef std::complex<double> cfloat;
-    float *ins[in_count];
-    float *outs[out_count];
-    float *params[param_count];
-    uint32_t srate;
-    bool is_active;
-    volatile int last_generation, last_calculated_generation;
-    equalizer5band_audio_module();
-    void activate();
-    void deactivate();
-    void params_changed();
-    float freq_gain(int index, double freq, uint32_t sr)
-    {
-        float ret = 1.f;
-        ret *= (*params[param_ls_active] > 0.f) ? lsL.freq_gain(freq, sr) : 1;
-        ret *= (*params[param_hs_active] > 0.f) ? hsL.freq_gain(freq, sr) : 1;
-        ret *= (*params[param_p1_active] > 0.f) ? pL[0].freq_gain(freq, sr) : 1;
-        ret *= (*params[param_p2_active] > 0.f) ? pL[1].freq_gain(freq, sr) : 1;
-        ret *= (*params[param_p3_active] > 0.f) ? pL[2].freq_gain(freq, sr) : 1;
-        return ret;
-    }
-    void set_sample_rate(uint32_t sr);
-    uint32_t process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask);
-    bool get_graph(int index, int subindex, float *data, int points, cairo_iface *context);
-    bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
-    int  get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline);
-};
+typedef equalizerNband_audio_module<equalizer5band_metadata, false> equalizer5band_audio_module;
+typedef equalizerNband_audio_module<equalizer8band_metadata, true> equalizer8band_audio_module;
+typedef equalizerNband_audio_module<equalizer12band_metadata, true> equalizer12band_audio_module;
 
 /// LFO by Markus
 class lfo_audio_module {
diff --git a/src/modules.cpp b/src/modules.cpp
index 309175e..abc024f 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -402,43 +402,38 @@ CALF_PORT_PROPS(deesser) = {
 CALF_PLUGIN_INFO(deesser) = { 0x8502, "Deesser", "Calf Deesser", "Markus Schmidt / Thor Harald Johansen", calf_plugins::calf_copyright_info, "CompressorPlugin" };
 
 ////////////////////////////////////////////////////////////////////////////
+// A few macros to make 
 
-CALF_PORT_NAMES(equalizer5band) = {"In L", "In R", "Out L", "Out R"};
-
-CALF_PORT_PROPS(equalizer5band) = {
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
-    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input Gain" },
+#define BYPASS_AND_LEVEL_PARAMS \
+    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" }, \
+    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input Gain" }, \
     { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_out", "Output Gain" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_in", "Input Level" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_out", "Output Level" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_in", "0dB-In" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_out", "0dB-Out" },
-
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "ls_active", "LS Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "ls_level", "Level L" },
-    { 200,         10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "ls_freq", "Freq L" },
-    
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "hs_active", "HS Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "hs_level", "Level H" },
-    { 4000,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hs_freq", "Freq H" },
-    
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "p1_active", "F1 Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p1_level", "Level 1" },
-    { 250,         10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "p1_freq", "Freq 1" },
-    { 1,           0.1,         100,   1,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p1_q", "Q 1" },
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "p2_active", "F2 Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p2_level", "Level 2" },
-    { 1000,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "p2_freq", "Freq 2" },
-    { 1,           0.1,         100,   1,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p2_q", "Q 2" },
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "p3_active", "F3 Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p3_level", "Level 3" },
-    { 2500,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "p3_freq", "Freq 3" },
-    { 1,           0.1,         100,   1,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p3_q", "Q 3" },
-};
 
-CALF_PLUGIN_INFO(equalizer5band) = { 0x8501, "Equalizer5Band", "Calf Equalizer 5 Band", "Markus Schmidt", calf_plugins::calf_copyright_info, "EqualizerPlugin" };
+#define METERING_PARAMS \
+    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inL", "Meter-InL" }, \
+    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inR", "Meter-InR" }, \
+    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outL", "Meter-OutL" }, \
+    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outR", "Meter-OutR" }, \
+    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inL", "0dB-InL" }, \
+    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inR", "0dB-InR" }, \
+    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outL", "0dB-OutL" }, \
+    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outR", "0dB-OutR" },
 
-//////////////////////////////////////////////////////////////////////////////
+#define LPHP_PARAMS \
+    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "hp_active", "HP Active" }, \
+    { 30,          10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hp_freq", "HP Freq" }, \
+    { 1,           0,           2,     0,  PF_ENUM | PF_CTL_COMBO, rolloff_mode_names, "hp_mode", "HP Mode" }, \
+    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "lp_active", "LP Active" }, \
+    { 18000,       10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "lp_freq", "LP Freq" }, \
+    { 1,           0,           2,     0,  PF_ENUM | PF_CTL_COMBO, rolloff_mode_names, "lp_mode", "LP Mode" }, \
+
+#define SHELF_PARAMS \
+    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "ls_active", "LS Active" }, \
+    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "ls_level", "Level L" }, \
+    { 200,         10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "ls_freq", "Freq L" }, \
+    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "hs_active", "HS Active" }, \
+    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "hs_level", "Level H" }, \
+    { 4000,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hs_freq", "Freq H" },
 
 #define EQ_BAND_PARAMS(band, frequency) \
     { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "p" #band "_active", "F" #band " Active" }, \
@@ -446,38 +441,32 @@ CALF_PLUGIN_INFO(equalizer5band) = { 0x8501, "Equalizer5Band", "Calf Equalizer 5
     { frequency,   10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "p" #band "_freq", "Freq " #band }, \
     { 1,           0.1,         100,   1,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p" #band "_q", "Q " #band },
 
+////////////////////////////////////////////////////////////////////////////
+
+CALF_PORT_NAMES(equalizer5band) = {"In L", "In R", "Out L", "Out R"};
+
+CALF_PORT_PROPS(equalizer5band) = {
+    BYPASS_AND_LEVEL_PARAMS
+    METERING_PARAMS
+    SHELF_PARAMS
+    EQ_BAND_PARAMS(1, 250)
+    EQ_BAND_PARAMS(2, 1000)
+    EQ_BAND_PARAMS(3, 2500)
+};
+
+CALF_PLUGIN_INFO(equalizer5band) = { 0x8501, "Equalizer5Band", "Calf Equalizer 5 Band", "Markus Schmidt", calf_plugins::calf_copyright_info, "EqualizerPlugin" };
+
+//////////////////////////////////////////////////////////////////////////////
+
+
 CALF_PORT_NAMES(equalizer8band) = {"In L", "In R", "Out L", "Out R"};
 const char *rolloff_mode_names[] = {"12dB/oct", "24dB/oct", "36dB/oct"};
 
 CALF_PORT_PROPS(equalizer8band) = {
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
-    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input Gain" },
-    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_out", "Output Gain" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inL", "Meter-InL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inR", "Meter-InR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outL", "Meter-OutL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outR", "Meter-OutR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inL", "0dB-InL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inR", "0dB-InR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outL", "0dB-OutL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outR", "0dB-OutR" },
-
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "hp_active", "HP Active" },
-    { 30,          10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hp_freq", "HP Freq" },
-    { 1,           0,           2,     0,  PF_ENUM | PF_CTL_COMBO, rolloff_mode_names, "hp_mode", "HP Mode" },
-    
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "lp_active", "LP Active" },
-    { 18000,       10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "lp_freq", "LP Freq" },
-    { 1,           0,           2,     0,  PF_ENUM | PF_CTL_COMBO, rolloff_mode_names, "lp_mode", "LP Mode" },
-    
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "ls_active", "LS Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "ls_level", "LS Level" },
-    { 200,         10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "ls_freq", "LS Freq" },
-    
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "hs_active", "HS Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "hs_level", "HS Level" },
-    { 4000,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hs_freq", "HS Freq" },
-    
+    BYPASS_AND_LEVEL_PARAMS
+    METERING_PARAMS
+    LPHP_PARAMS
+    SHELF_PARAMS
     EQ_BAND_PARAMS(1, 250)
     EQ_BAND_PARAMS(2, 1000)
     EQ_BAND_PARAMS(3, 2500)
@@ -491,34 +480,10 @@ CALF_PLUGIN_INFO(equalizer8band) = { 0x8501, "Equalizer8Band", "Calf Equalizer 8
 CALF_PORT_NAMES(equalizer12band) = {"In L", "In R", "Out L", "Out R"};
 
 CALF_PORT_PROPS(equalizer12band) = {
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
-    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input" },
-    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_out", "Output" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inL", "InL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inR", "InR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outL", "OutL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outR", "OutR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inL", "0dB-InL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inR", "0dB-InR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outL", "0dB-OutL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outR", "0dB-OutR" },
-
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "hp_active", "HP Active" },
-    { 30,          10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hp_freq", "Freq HP" },
-    { 1,           0,           2,     0,  PF_ENUM | PF_CTL_COMBO, rolloff_mode_names, "hp_mode", "Mode HP" },
-    
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "lp_active", "LP Active" },
-    { 18000,       10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "lp_freq", "Freq LP" },
-    { 1,           0,           2,     0,  PF_ENUM | PF_CTL_COMBO, rolloff_mode_names, "lp_mode", "Mode LP" },
-    
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "ls_active", "LS Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "ls_level", "Level LS" },
-    { 200,         10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "ls_freq", "Freq LS" },
-    
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "hs_active", "LS Active" },
-    { 1,           0.015625,    64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "hs_level", "Level HS" },
-    { 4000,        10,          20000, 0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "hs_freq", "Freq HS" },
-    
+    BYPASS_AND_LEVEL_PARAMS
+    METERING_PARAMS
+    LPHP_PARAMS
+    SHELF_PARAMS
     EQ_BAND_PARAMS(1, 60)
     EQ_BAND_PARAMS(2, 120)
     EQ_BAND_PARAMS(3, 250)
@@ -538,17 +503,8 @@ CALF_PORT_NAMES(pulsator) = {"In L", "In R", "Out L", "Out R"};
 const char *pulsator_mode_names[] = { "Sine", "Triangle", "Square", "Saw up", "Saw down" };
 
 CALF_PORT_PROPS(pulsator) = {
-    { 0,           0,           1,     0,  PF_BOOL | PF_CTL_TOGGLE, NULL, "bypass", "Bypass" },
-    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_in", "Input" },
-    { 1,           0,           64,    0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_NOBOUNDS, NULL, "level_out", "Output" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inL", "InL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_inR", "InR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outL", "OutL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_SCALE_GAIN | PF_CTL_METER | PF_CTLO_LABEL | PF_UNIT_DB | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "meter_outR", "OutR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inL", "0dB-InL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_inR", "0dB-InR" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outL", "0dB-OutL" },
-    { 0,           0,           1,     0,  PF_FLOAT | PF_CTL_LED | PF_PROP_OUTPUT | PF_PROP_OPTIONAL, NULL, "clip_outR", "0dB-OutR" },
+    BYPASS_AND_LEVEL_PARAMS
+    METERING_PARAMS
     { 0,           0,           4,     0,  PF_ENUM | PF_CTL_COMBO, pulsator_mode_names, "mode", "Mode" },
     { 1,           0.01,        100,   0,  PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "freq", "Frequency" },
     { 1,           0,           1,     0,  PF_FLOAT | PF_SCALE_PERC, NULL, "amount", "Modulation" },
diff --git a/src/modules_dsp.cpp b/src/modules_dsp.cpp
index 1d827a6..dbdcc3d 100644
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@ -1730,8 +1730,8 @@ int gain_reduction_audio_module::get_changed_offsets(int generation, int &subind
 /// of different chained filters.
 ///////////////////////////////////////////////////////////////////////////////////////////////
 
-template<class BaseClass>
-equalizerNband_audio_module<BaseClass>::equalizerNband_audio_module()
+template<class BaseClass, bool has_lphp>
+equalizerNband_audio_module<BaseClass, has_lphp>::equalizerNband_audio_module()
 {
     is_active = false;
     srate = 0;
@@ -1740,16 +1740,16 @@ equalizerNband_audio_module<BaseClass>::equalizerNband_audio_module()
     meter_inL = meter_inR = meter_outL = meter_outR = 0.f;
 }
 
-template<class BaseClass>
-void equalizerNband_audio_module<BaseClass>::activate()
+template<class BaseClass, bool has_lphp>
+void equalizerNband_audio_module<BaseClass, has_lphp>::activate()
 {
     is_active = true;
     // set all filters
     params_changed();
 }
 
-template<class BaseClass>
-void equalizerNband_audio_module<BaseClass>::deactivate()
+template<class BaseClass, bool has_lphp>
+void equalizerNband_audio_module<BaseClass, has_lphp>::deactivate()
 {
     is_active = false;
 }
@@ -1762,26 +1762,31 @@ static inline void copy_lphp(biquad_d2<float> filters[3][2])
                 filters[i][j].copy_coeffs(filters[0][0]);
 }
 
-
-template<class BaseClass>
-void equalizerNband_audio_module<BaseClass>::params_changed()
+template<class BaseClass, bool has_lphp>
+void equalizerNband_audio_module<BaseClass, has_lphp>::params_changed()
 {
     // set the params of all filters
     
-    // lp/hp first
-    float hpfreq = *params[AM::param_hp_freq], lpfreq = *params[AM::param_lp_freq];
-    
-    if(hpfreq != hp_freq_old) {
-        hp[0][0].set_hp_rbj(hpfreq, 0.707, (float)srate, 1.0);
-        copy_lphp(hp);
-        hp_freq_old = hpfreq;
-    }
-    if(lpfreq != lp_freq_old) {
-        lp[0][0].set_lp_rbj(lpfreq, 0.707, (float)srate, 1.0);
-        copy_lphp(lp);
-        lp_freq_old = lpfreq;
-    }
+    // lp/hp first (if available)
+    if (has_lphp)
+    {
+        hp_mode = (CalfEqMode)(int)*params[AM::param_hp_mode];
+        lp_mode = (CalfEqMode)(int)*params[AM::param_lp_mode];
 
+        float hpfreq = *params[AM::param_hp_freq], lpfreq = *params[AM::param_lp_freq];
+        
+        if(hpfreq != hp_freq_old) {
+            hp[0][0].set_hp_rbj(hpfreq, 0.707, (float)srate, 1.0);
+            copy_lphp(hp);
+            hp_freq_old = hpfreq;
+        }
+        if(lpfreq != lp_freq_old) {
+            lp[0][0].set_lp_rbj(lpfreq, 0.707, (float)srate, 1.0);
+            copy_lphp(lp);
+            lp_freq_old = lpfreq;
+        }
+    }
+    
     // then shelves
     float hsfreq = *params[AM::param_hs_freq], hslevel = *params[AM::param_hs_level];
     float lsfreq = *params[AM::param_ls_freq], lslevel = *params[AM::param_ls_level];
@@ -1814,28 +1819,53 @@ void equalizerNband_audio_module<BaseClass>::params_changed()
     }
 }
 
-static void process_hplp(float &procL, float &procR, dsp::biquad_d2<float> filter[3][2], CalfEqMode mode)
+template<class BaseClass, bool has_lphp>
+inline void equalizerNband_audio_module<BaseClass, has_lphp>::process_hplp(float &left, float &right)
 {
-    switch(mode) {
-        case MODE12DB:
-            procL = filter[0][0].process(procL);
-            procR = filter[0][1].process(procR);
-            break;
-        case MODE24DB:
-            procL = filter[1][0].process(filter[0][0].process(procL));
-            procR = filter[1][1].process(filter[0][1].process(procR));
-            break;
-        case MODE36DB:
-            procL = filter[2][0].process(filter[1][0].process(filter[0][0].process(procL)));
-            procR = filter[2][1].process(filter[1][1].process(filter[0][1].process(procR)));
-            break;
+    if (!has_lphp)
+        return;
+    if (*params[AM::param_lp_active] > 0.f)
+    {
+        switch(lp_mode)
+        {
+            case MODE12DB:
+                left = lp[0][0].process(left);
+                right = lp[0][1].process(right);
+                break;
+            case MODE24DB:
+                left = lp[1][0].process(lp[0][0].process(left));
+                right = lp[1][1].process(lp[0][1].process(right));
+                break;
+            case MODE36DB:
+                left = lp[2][0].process(lp[1][0].process(lp[0][0].process(left)));
+                right = lp[2][1].process(lp[1][1].process(lp[0][1].process(right)));
+                break;
+        }
+    }
+    if (*params[AM::param_hp_active] > 0.f)
+    {
+        switch(hp_mode)
+        {
+            case MODE12DB:
+                left = hp[0][0].process(left);
+                right = hp[0][1].process(right);
+                break;
+            case MODE24DB:
+                left = hp[1][0].process(hp[0][0].process(left));
+                right = hp[1][1].process(hp[0][1].process(right));
+                break;
+            case MODE36DB:
+                left = hp[2][0].process(hp[1][0].process(hp[0][0].process(left)));
+                right = hp[2][1].process(hp[1][1].process(hp[0][1].process(right)));
+                break;
+        }
     }
 }
 
 #define SET_IF_CONNECTED(param) if (params[AM::param_##param] != NULL) *params[AM::param_##param] = param;
 
-template<class BaseClass>
-uint32_t equalizerNband_audio_module<BaseClass>::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
+template<class BaseClass, bool has_lphp>
+uint32_t equalizerNband_audio_module<BaseClass, has_lphp>::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
 {
     bool bypass = *params[AM::param_bypass] > 0.f;
     numsamples += offset;
@@ -1859,8 +1889,6 @@ uint32_t equalizerNband_audio_module<BaseClass>::process(uint32_t offset, uint32
         meter_inR = 0.f;
         meter_outL = 0.f;
         meter_outR = 0.f;
-        CalfEqMode hp_mode = (CalfEqMode)(int)*params[AM::param_hp_mode];
-        CalfEqMode lp_mode = (CalfEqMode)(int)*params[AM::param_lp_mode];
         
         // process
         while(offset < numsamples) {
@@ -1877,12 +1905,7 @@ uint32_t equalizerNband_audio_module<BaseClass>::process(uint32_t offset, uint32
             float procR = inR;
             
             // all filters in chain
-            if(*params[AM::param_hp_active] > 0.f) {
-                process_hplp(procL, procR, hp, hp_mode);
-            }
-            if(*params[AM::param_lp_active] > 0.f) {
-                process_hplp(procL, procR, lp, lp_mode);
-            }
+            process_hplp(procL, procR);
             if(*params[AM::param_ls_active] > 0.f) {
                 procL = lsL.process(procL);
                 procR = lsR.process(procR);
@@ -1965,8 +1988,8 @@ uint32_t equalizerNband_audio_module<BaseClass>::process(uint32_t offset, uint32
 
 #undef SET_IF_CONNECTED
 
-template<class BaseClass>
-bool equalizerNband_audio_module<BaseClass>::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
+template<class BaseClass, bool has_lphp>
+bool equalizerNband_audio_module<BaseClass, has_lphp>::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
 {
     if (!is_active)
         return false;
@@ -1977,8 +2000,8 @@ bool equalizerNband_audio_module<BaseClass>::get_graph(int index, int subindex,
     return false;
 }
 
-template<class BaseClass>
-bool equalizerNband_audio_module<BaseClass>::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
+template<class BaseClass, bool has_lphp>
+bool equalizerNband_audio_module<BaseClass, has_lphp>::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
 {
     if (!is_active) {
         return false;
@@ -1987,8 +2010,8 @@ bool equalizerNband_audio_module<BaseClass>::get_gridline(int index, int subinde
     }
 }
 
-template<class BaseClass>
-int equalizerNband_audio_module<BaseClass>::get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline)
+template<class BaseClass, bool has_lphp>
+int equalizerNband_audio_module<BaseClass, has_lphp>::get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline)
 {
     if (!is_active) {
         return false;
@@ -2036,12 +2059,15 @@ static inline float adjusted_lphp_gain(float **params, int param_active, int par
     return 1;
 }
 
-template<class BaseClass>
-float equalizerNband_audio_module<BaseClass>::freq_gain(int index, double freq, uint32_t sr)
+template<class BaseClass, bool use_hplp>
+float equalizerNband_audio_module<BaseClass, use_hplp>::freq_gain(int index, double freq, uint32_t sr)
 {
     float ret = 1.f;
-    ret *= adjusted_lphp_gain(params, AM::param_hp_active, AM::param_hp_mode, hp[0][0], freq, (float)sr);
-    ret *= adjusted_lphp_gain(params, AM::param_lp_active, AM::param_lp_mode, lp[0][0], freq, (float)sr);
+    if (use_hplp)
+    {
+        ret *= adjusted_lphp_gain(params, AM::param_hp_active, AM::param_hp_mode, hp[0][0], freq, (float)sr);
+        ret *= adjusted_lphp_gain(params, AM::param_lp_active, AM::param_lp_mode, lp[0][0], freq, (float)sr);
+    }
     ret *= (*params[AM::param_ls_active] > 0.f) ? lsL.freq_gain(freq, sr) : 1;
     ret *= (*params[AM::param_hs_active] > 0.f) ? hsL.freq_gain(freq, sr) : 1;
     for (int i = 0; i < PeakBands; i++)
@@ -2049,267 +2075,9 @@ float equalizerNband_audio_module<BaseClass>::freq_gain(int index, double freq,
     return ret;
 }
 
-template class equalizerNband_audio_module<equalizer8band_metadata>;
-template class equalizerNband_audio_module<equalizer12band_metadata>;
-
-/// Equalizer 5 Band by Markus Schmidt
-///
-/// This module is based on Krzysztof's filters. It provides a couple
-/// of different chained filters.
-///////////////////////////////////////////////////////////////////////////////////////////////
-
-equalizer5band_audio_module::equalizer5band_audio_module()
-{
-    is_active = false;
-    srate = 0;
-    last_generation = 0;
-    clip_in    = 0.f;
-    clip_out   = 0.f;
-    meter_in  = 0.f;
-    meter_out = 0.f;
-}
-
-void equalizer5band_audio_module::activate()
-{
-    is_active = true;
-    // set all filters
-    params_changed();
-}
-void equalizer5band_audio_module::deactivate()
-{
-    is_active = false;
-}
-
-void equalizer5band_audio_module::params_changed()
-{
-    // set the params of all filters
-    if(*params[param_ls_freq] != ls_freq_old or *params[param_ls_level] != ls_level_old) {
-        lsL.set_lowshelf_rbj(*params[param_ls_freq], 0.707, *params[param_ls_level], (float)srate);
-        lsR.copy_coeffs(lsL);
-        ls_level_old = *params[param_ls_level];
-        ls_freq_old = *params[param_ls_freq];
-    }
-    if(*params[param_hs_freq] != hs_freq_old or *params[param_hs_level] != hs_level_old) {
-        hsL.set_highshelf_rbj(*params[param_hs_freq], 0.707, *params[param_hs_level], (float)srate);
-        hsR.copy_coeffs(hsL);
-        hs_level_old = *params[param_hs_level];
-        hs_freq_old = *params[param_hs_freq];
-    }
-    if(*params[param_p1_freq] != p_freq_old[0] or *params[param_p1_level] != p_level_old[0] or *params[param_p1_q] != p_q_old[0]) {
-        pL[0].set_peakeq_rbj((float)*params[param_p1_freq], *params[param_p1_q], *params[param_p1_level], (float)srate);
-        pR[0].copy_coeffs(pL[0]);
-        p_freq_old[0] = *params[param_p1_freq];
-        p_level_old[0] = *params[param_p1_level];
-        p_q_old[0] = *params[param_p1_q];
-    }
-    if(*params[param_p2_freq] != p_freq_old[1] or *params[param_p2_level] != p_level_old[1] or *params[param_p2_q] != p_q_old[1]) {
-        pL[1].set_peakeq_rbj((float)*params[param_p2_freq], *params[param_p2_q], *params[param_p2_level], (float)srate);
-        pR[1].copy_coeffs(pL[1]);
-        p_freq_old[1] = *params[param_p2_freq];
-        p_level_old[1] = *params[param_p2_level];
-        p_q_old[1] = *params[param_p2_q];
-    }
-    if(*params[param_p3_freq] != p_freq_old[2] or *params[param_p3_level] != p_level_old[2] or *params[param_p3_q] != p_q_old[2]) {
-        pL[2].set_peakeq_rbj((float)*params[param_p3_freq], *params[param_p3_q], *params[param_p3_level], (float)srate);
-        pR[2].copy_coeffs(pL[2]);
-        p_freq_old[2] = *params[param_p3_freq];
-        p_level_old[2] = *params[param_p3_level];
-        p_q_old[2] = *params[param_p3_q];
-    }
-}
-
-void equalizer5band_audio_module::set_sample_rate(uint32_t sr)
-{
-    srate = sr;
-}
-
-uint32_t equalizer5band_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
-{
-    bool bypass = *params[param_bypass] > 0.5f;
-    numsamples += offset;
-    if(bypass) {
-        // everything bypassed
-        while(offset < numsamples) {
-            outs[0][offset] = ins[0][offset];
-            outs[1][offset] = ins[1][offset];
-            ++offset;
-        }
-        // displays, too
-        clip_in    = 0.f;
-        clip_out   = 0.f;
-        meter_in  = 0.f;
-        meter_out = 0.f;
-    } else {
-        
-        clip_in    -= std::min(clip_in,  numsamples);
-        clip_out   -= std::min(clip_out, numsamples);
-        meter_in = 0.f;
-        meter_out = 0.f;
-        
-        // process
-        while(offset < numsamples) {
-            // cycle through samples
-            float outL = 0.f;
-            float outR = 0.f;
-            float inL = ins[0][offset];
-            float inR = ins[1][offset];
-            // in level
-            inR *= *params[param_level_in];
-            inL *= *params[param_level_in];
-            
-            float procL = inL;
-            float procR = inR;
-            
-            // all filters in chain
-            if(*params[param_ls_active] > 0.f) {
-                procL = lsL.process(procL);
-                procR = lsR.process(procR);
-            }
-            if(*params[param_hs_active] > 0.f) {
-                procL = hsL.process(procL);
-                procR = hsR.process(procR);
-            }
-            if(*params[param_p1_active] > 0.f) {
-                procL = pL[0].process(procL);
-                procR = pR[0].process(procR);
-            }
-            if(*params[param_p2_active] > 0.f) {
-                procL = pL[1].process(procL);
-                procR = pR[1].process(procR);
-            }
-            if(*params[param_p3_active] > 0.f) {
-                procL = pL[2].process(procL);
-                procR = pR[2].process(procR);
-            }
-            
-            outL = procL * *params[param_level_out];
-            outR = procR * *params[param_level_out];
-            
-            // send to output
-            outs[0][offset] = outL;
-            outs[1][offset] = outR;
-            
-            // clip LED's
-            float maxIn = std::max(fabs(inL), fabs(inR));
-            float maxOut = std::max(fabs(outL), fabs(outR));
-            
-            if(maxIn > 1.f) {
-                clip_in  = srate >> 3;
-            }
-            if(maxOut > 1.f) {
-                clip_out = srate >> 3;
-            }
-            // set up in / out meters
-            if(maxIn > meter_in) {
-                meter_in = maxIn;
-            }
-            if(maxOut > meter_out) {
-                meter_out = maxOut;
-            }
-            
-            // next sample
-            ++offset;
-        } // cycle trough samples
-        // clean up
-        lsL.sanitize();
-        hsR.sanitize();
-        for(int i = 0; i < 3; ++i) {
-            pL[i].sanitize();
-            pR[i].sanitize();
-        }
-    }
-    // draw meters
-    if(params[param_clip_in] != NULL) {
-        *params[param_clip_in] = clip_in;
-    }
-    if(params[param_clip_out] != NULL) {
-        *params[param_clip_out] = clip_out;
-    }
-    
-    if(params[param_meter_in] != NULL) {
-        *params[param_meter_in] = meter_in;
-    }
-    if(params[param_meter_out] != NULL) {
-        *params[param_meter_out] = meter_out;
-    }
-    // whatever has to be returned x)
-    return outputs_mask;
-}
-bool equalizer5band_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
-{
-    if (!is_active)
-        return false;
-    if (index == param_p1_freq && !subindex) {
-        context->set_line_width(1.5);
-        return ::get_graph(*this, subindex, data, points);
-    }
-    return false;
-}
-
-bool equalizer5band_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
-{
-    if (!is_active) {
-        return false;
-    } else {
-        return get_freq_gridline(subindex, pos, vertical, legend, context);
-    }
-}
-
-int equalizer5band_audio_module::get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline)
-{
-    if (!is_active) {
-        return false;
-    } else {
-        if (*params[param_ls_freq] != ls_freq_old1
-            or *params[param_ls_level] != ls_level_old1
-            or *params[param_hs_freq] != hs_freq_old1
-            or *params[param_hs_level] != hs_level_old1
-            
-            or *params[param_p1_freq] != p_freq_old1[0]
-            or *params[param_p1_level] != p_level_old1[0]
-            or *params[param_p1_q] != p_q_old1[0]
-            
-            or *params[param_p2_freq] != p_freq_old1[1]
-            or *params[param_p2_level] != p_level_old1[1]
-            or *params[param_p2_q] != p_q_old1[1]
-                        
-            or *params[param_p3_freq] != p_freq_old1[2]
-            or *params[param_p3_level] != p_level_old1[2]
-            or *params[param_p3_q] != p_q_old1[2])
-        {
-            
-            ls_freq_old1 = *params[param_ls_freq];
-            ls_level_old1 = *params[param_ls_level];
-            hs_freq_old1 = *params[param_hs_freq];
-            hs_level_old1 = *params[param_hs_level];
-            
-            p_freq_old1[0] = *params[param_p1_freq];
-            p_level_old1[0] = *params[param_p1_level];
-            p_q_old1[0] = *params[param_p1_q];
-            
-            p_freq_old1[1] = *params[param_p2_freq];
-            p_level_old1[1] = *params[param_p2_level];
-            p_q_old1[1] = *params[param_p2_q];
-            
-            p_freq_old1[2] = *params[param_p3_freq];
-            p_level_old1[2] = *params[param_p3_level];
-            p_q_old1[2] = *params[param_p3_q];
-            
-            last_generation++;
-            subindex_graph = 0;
-            subindex_dot = INT_MAX;
-            subindex_gridline = INT_MAX;
-        }
-        else {
-            subindex_graph = 0;
-            subindex_dot = subindex_gridline = generation ? INT_MAX : 0;
-        }
-        if (generation == last_calculated_generation)
-            subindex_graph = INT_MAX;
-        return last_generation;
-    }
-    return false;
-}
+template class equalizerNband_audio_module<equalizer5band_metadata, false>;
+template class equalizerNband_audio_module<equalizer8band_metadata, true>;
+template class equalizerNband_audio_module<equalizer12band_metadata, true>;
 
 /// LFO module by Markus
 /// This module provides simple LFO's (sine=0, triangle=1, square=2, saw_up=3, saw_down=4)
@@ -2416,6 +2184,7 @@ bool lfo_audio_module::get_dot(float &x, float &y, int &size, cairo_iface *conte
         phs = fmod(phs, 1.f);
     x = phase;
     y = get_value_from_phase(phase, offset) * amount;
+    return true;
 }
 
 /// Pulsator by Markus Schmidt

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list