1 /* Calf DSP plugin pack
2 * Equalization related plugins
4 * Copyright (C) 2001-2010 Krzysztof Foltman, Markus Schmidt, Thor Harald Johansen and others
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General
17 * Public License along with this program; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 * Boston, MA 02111-1307, USA.
21 #ifndef CALF_MODULES_EQ_H
22 #define CALF_MODULES_EQ_H
31 #include "plugin_tools.h"
33 namespace calf_plugins
{
35 /// Equalizer N Band by Markus Schmidt (based on Krzysztof's filters)
36 template<class BaseClass
, bool has_lphp
>
37 class equalizerNband_audio_module
: public audio_module
<BaseClass
>, public frequency_response_line_graph
{
39 typedef audio_module
<BaseClass
> AM
;
45 using AM::param_count
;
48 enum { graph_param_count
= BaseClass::last_graph_param
- BaseClass::first_graph_param
+ 1, params_per_band
= AM::param_p2_active
- AM::param_p1_active
};
49 float hp_mode_old
, hp_freq_old
;
50 float lp_mode_old
, lp_freq_old
;
51 float ls_level_old
, ls_freq_old
;
52 float hs_level_old
, hs_freq_old
;
53 float p_level_old
[PeakBands
], p_freq_old
[PeakBands
], p_q_old
[PeakBands
];
54 mutable float old_params_for_graph
[graph_param_count
];
55 dual_in_out_metering
<BaseClass
> meters
;
56 CalfEqMode hp_mode
, lp_mode
;
57 dsp::biquad_d2
<float> hp
[3][2], lp
[3][2];
58 dsp::biquad_d2
<float> lsL
, lsR
, hsL
, hsR
;
59 dsp::biquad_d2
<float> pL
[PeakBands
], pR
[PeakBands
];
62 inline void process_hplp(float &left
, float &right
);
64 typedef std::complex<double> cfloat
;
67 mutable volatile int last_generation
, last_calculated_generation
;
68 equalizerNband_audio_module();
72 void params_changed();
73 float freq_gain(int index
, double freq
, uint32_t sr
) const;
74 void set_sample_rate(uint32_t sr
)
77 meters
.set_sample_rate(sr
);
79 uint32_t process(uint32_t offset
, uint32_t numsamples
, uint32_t inputs_mask
, uint32_t outputs_mask
);
80 bool get_graph(int index
, int subindex
, float *data
, int points
, cairo_iface
*context
, int *mode
) const;
81 bool get_gridline(int index
, int subindex
, float &pos
, bool &vertical
, std::string
&legend
, cairo_iface
*context
) const;
82 int get_changed_offsets(int index
, int generation
, int &subindex_graph
, int &subindex_dot
, int &subindex_gridline
) const;
85 typedef equalizerNband_audio_module
<equalizer5band_metadata
, false> equalizer5band_audio_module
;
86 typedef equalizerNband_audio_module
<equalizer8band_metadata
, true> equalizer8band_audio_module
;
87 typedef equalizerNband_audio_module
<equalizer12band_metadata
, true> equalizer12band_audio_module
;