[SCM] calf/master: Merge branch 'master' into pulsator
js at users.alioth.debian.org
js at users.alioth.debian.org
Tue May 7 15:39:50 UTC 2013
+ EQ-12: fix labels
+ EQ-8: correct overrides for input and output VU meters
+ Equalizers: convert lists of per-band parameters using macros (ugly, but effective)
+ EQ-8, EQ-12: reduce copypasta by using a class template
+ EQ-8: use label overrides to cover up the cover up of GStreamer bug ;)
+ GUI: make 'text' attribute for labels higher-priority than 'param' attribute
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
X-Git-Refname: refs/heads/master
X-Git-Reftype: branch
X-Git-Oldrev: d6a3c1a63a147948535a50da009275278ad5e6a3
X-Git-Newrev: 34569260c452f0fa4c543155ebba174a42a343dc
The following commit has been merged in the master branch:
commit 693c4511f79976c9da1342251e1b527ff3443ded
Merge: 4a2de1ac65eb14d5eb27d64f233528fecf61b714 5882b0684b10f778d220f6f02f929e20477aab06
Author: Markus Schmidt <schmidt at boomshop.net>
Date: Mon Nov 16 09:45:29 2009 +0100
Merge branch 'master' into pulsator
diff --combined src/calf/metadata.h
index bf181a7,a992590..2d0f3d3
--- a/src/calf/metadata.h
+++ b/src/calf/metadata.h
@@@ -92,6 -92,12 +92,12 @@@ public
PLUGIN_NAME_ID_LABEL("multichorus", "multichorus", "Multi Chorus")
};
+ enum CalfEqMode {
+ MODE12DB,
+ MODE24DB,
+ MODE36DB
+ };
+
/// Monosynth - metadata
struct monosynth_metadata: public plugin_metadata<monosynth_metadata>
{
@@@ -211,6 -217,7 +217,7 @@@ struct equalizer8band_metadata: public
param_p3_active, param_p3_level, param_p3_freq, param_p3_q,
param_p4_active, param_p4_level, param_p4_freq, param_p4_q,
param_count };
+ enum { PeakBands = 4, first_graph_param = param_hp_active, last_graph_param = param_p4_q };
PLUGIN_NAME_ID_LABEL("equalizer8band", "equalizer8band", "Equalizer 8 Band")
};
/// Markus's 12-band EQ - metadata
@@@ -232,19 -239,10 +239,20 @@@ struct equalizer12band_metadata: publi
param_p7_active, param_p7_level, param_p7_freq, param_p7_q,
param_p8_active, param_p8_level, param_p8_freq, param_p8_q,
param_count };
+ enum { PeakBands = 8, first_graph_param = param_hp_active, last_graph_param = param_p8_q };
PLUGIN_NAME_ID_LABEL("equalizer12band", "equalizer12band", "Equalizer 12 Band")
};
+/// Markus's Pulsator - metadata
+struct pulsator_metadata: public plugin_metadata<pulsator_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_inL, param_meter_inR,
+ param_meter_outL, param_meter_outR, param_clip_inL, param_clip_inR, param_clip_outL, param_clip_outR,
+ param_mode, param_freq, param_amount, param_offset, param_mono, param_count };
+ PLUGIN_NAME_ID_LABEL("pulsator", "pulsator", "Pulsator")
+};
+
/// Organ - enums for parameter IDs etc. (this mess is caused by organ split between plugin and generic class - which was
/// a bad design decision and should be sorted out some day) XXXKF @todo
struct organ_enums
diff --combined src/calf/modules.h
index 879dbc1,6c9008a..99202aa
--- a/src/calf/modules.h
+++ b/src/calf/modules.h
@@@ -37,7 -37,7 +37,7 @@@ namespace calf_plugins
using namespace dsp;
struct ladspa_plugin_info;
-
+
#if 0
class amp_audio_module: public null_audio_module
{
@@@ -1038,120 -1038,28 +1038,28 @@@ public
int get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline);
};
- /// Equalizer 12 Band by Markus Schmidt (based on Krzysztof's filters)
- class equalizer12band_audio_module: public audio_module<equalizer12band_metadata>, public frequency_response_line_graph {
- private:
- float hp_mode_old, hp_freq_old;
- float lp_mode_old, lp_freq_old;
- float ls_level_old, ls_freq_old;
- float hs_level_old, hs_freq_old;
- float p_level_old[8], p_freq_old[8], p_q_old[8];
- float hp_mode_old1, hp_freq_old1, hp_active_old1;
- float lp_mode_old1, lp_freq_old1, lp_active_old1;
- float ls_level_old1, ls_freq_old1, ls_active_old1;
- float hs_level_old1, hs_freq_old1, hs_active_old1;
- float p_level_old1[8], p_freq_old1[8], p_q_old1[8], p_active_old1[8];
- enum CalfEqModes {
- MODE12DB,
- MODE24DB,
- MODE36DB
- };
- CalfEqModes eq_mode, eq_mode_old1[2];
- uint32_t clip_inL, clip_outL, clip_inR, clip_outR;
- float meter_inL, meter_outL, meter_inR, meter_outR;
- biquad_d2<float> hpL[3], hpR[3], lpL[3], lpR[3];
- biquad_d2<float> lsL, lsR, hsL, hsR;
- biquad_d2<float> pL[8], pR[8];
+ /// Equalizer N Band by Markus Schmidt (based on Krzysztof's filters)
+ template<class BaseClass>
+ class equalizerNband_audio_module: public audio_module<BaseClass>, public frequency_response_line_graph {
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;
- equalizer12band_audio_module();
- void activate();
- void deactivate();
- void params_changed();
- float freq_gain(int index, double freq, uint32_t sr)
- {
- float ret = 1.f;
- if(*params[param_hp_active] > 0.f) {
- switch((int)*params[param_hp_mode]) {
- case MODE12DB:
- ret *= hpL[0].freq_gain(freq, sr);
- ret *= hpR[0].freq_gain(freq, sr);
- break;
- case MODE24DB:
- ret *= hpL[0].freq_gain(freq, sr) * hpL[0].freq_gain(freq, sr);
- ret *= hpR[0].freq_gain(freq, sr) * hpR[0].freq_gain(freq, sr);
- break;
- case MODE36DB:
- ret *= hpL[0].freq_gain(freq, sr) * hpL[0].freq_gain(freq, sr) * hpL[0].freq_gain(freq, sr);
- ret *= hpR[0].freq_gain(freq, sr) * hpR[0].freq_gain(freq, sr) * hpR[0].freq_gain(freq, sr);
- break;
- }
- }
- if(*params[param_lp_active] > 0.f) {
- switch((int)*params[param_lp_mode]) {
- case MODE12DB:
- ret *= lpL[0].freq_gain(freq, sr);
- ret *= lpR[0].freq_gain(freq, sr);
- break;
- case MODE24DB:
- ret *= lpL[0].freq_gain(freq, sr) * lpL[0].freq_gain(freq, sr);
- ret *= lpR[0].freq_gain(freq, sr) * lpR[0].freq_gain(freq, sr);
- break;
- case MODE36DB:
- ret *= lpL[0].freq_gain(freq, sr) * lpL[0].freq_gain(freq, sr) * lpL[0].freq_gain(freq, sr);
- ret *= lpR[0].freq_gain(freq, sr) * lpR[0].freq_gain(freq, sr) * lpR[0].freq_gain(freq, sr);
- break;
- }
- }
- 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;
- ret *= (*params[param_p4_active] > 0.f) ? pL[3].freq_gain(freq, sr) : 1;
- ret *= (*params[param_p5_active] > 0.f) ? pL[4].freq_gain(freq, sr) : 1;
- ret *= (*params[param_p6_active] > 0.f) ? pL[5].freq_gain(freq, sr) : 1;
- ret *= (*params[param_p7_active] > 0.f) ? pL[6].freq_gain(freq, sr) : 1;
- ret *= (*params[param_p8_active] > 0.f) ? pL[7].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);
- };
-
- /// Equalizer 8 Band by Markus Schmidt (based on Krzysztof's filters)
- class equalizer8band_audio_module: public audio_module<equalizer8band_metadata>, public frequency_response_line_graph {
+ typedef audio_module<BaseClass> AM;
+ using AM::in_count;
+ using AM::out_count;
+ using AM::param_count;
+ using AM::PeakBands;
private:
+ enum { graph_param_count = BaseClass::last_graph_param - BaseClass::first_graph_param + 1, params_per_band = AM::param_p2_active - AM::param_p1_active };
float hp_mode_old, hp_freq_old;
float lp_mode_old, lp_freq_old;
float ls_level_old, ls_freq_old;
float hs_level_old, hs_freq_old;
- float p_level_old[4], p_freq_old[4], p_q_old[4];
- float hp_mode_old1, hp_freq_old1, hp_active_old1;
- float lp_mode_old1, lp_freq_old1, lp_active_old1;
- float ls_level_old1, ls_freq_old1, ls_active_old1;
- float hs_level_old1, hs_freq_old1, hs_active_old1;
- float p_level_old1[4], p_freq_old1[4], p_q_old1[4], p_active_old1[4];
- enum CalfEqModes {
- MODE12DB,
- MODE24DB,
- MODE36DB
- };
- CalfEqModes eq_mode, eq_mode_old1[2];
+ float p_level_old[PeakBands], p_freq_old[PeakBands], p_q_old[PeakBands];
+ 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;
- biquad_d2<float> hpL[3], hpR[3], lpL[3], lpR[3];
+ biquad_d2<float> hp[3][2], lp[3][2];
biquad_d2<float> lsL, lsR, hsL, hsR;
- biquad_d2<float> pL[4], pR[4];
+ biquad_d2<float> pL[PeakBands], pR[PeakBands];
public:
typedef std::complex<double> cfloat;
float *ins[in_count];
@@@ -1160,60 -1068,24 +1068,24 @@@
uint32_t srate;
bool is_active;
volatile int last_generation, last_calculated_generation;
- equalizer8band_audio_module();
+ equalizerNband_audio_module();
void activate();
void deactivate();
void params_changed();
- float freq_gain(int index, double freq, uint32_t sr)
+ float freq_gain(int index, double freq, uint32_t sr);
+ void set_sample_rate(uint32_t sr)
{
- float ret = 1.f;
- if(*params[param_hp_active] > 0.f) {
- switch((int)*params[param_hp_mode]) {
- case MODE12DB:
- ret *= hpL[0].freq_gain(freq, sr);
- ret *= hpR[0].freq_gain(freq, sr);
- break;
- case MODE24DB:
- ret *= hpL[0].freq_gain(freq, sr) * hpL[0].freq_gain(freq, sr);
- ret *= hpR[0].freq_gain(freq, sr) * hpR[0].freq_gain(freq, sr);
- break;
- case MODE36DB:
- ret *= hpL[0].freq_gain(freq, sr) * hpL[0].freq_gain(freq, sr) * hpL[0].freq_gain(freq, sr);
- ret *= hpR[0].freq_gain(freq, sr) * hpR[0].freq_gain(freq, sr) * hpR[0].freq_gain(freq, sr);
- break;
- }
- }
- if(*params[param_lp_active] > 0.f) {
- switch((int)*params[param_lp_mode]) {
- case MODE12DB:
- ret *= lpL[0].freq_gain(freq, sr);
- ret *= lpR[0].freq_gain(freq, sr);
- break;
- case MODE24DB:
- ret *= lpL[0].freq_gain(freq, sr) * lpL[0].freq_gain(freq, sr);
- ret *= lpR[0].freq_gain(freq, sr) * lpR[0].freq_gain(freq, sr);
- break;
- case MODE36DB:
- ret *= lpL[0].freq_gain(freq, sr) * lpL[0].freq_gain(freq, sr) * lpL[0].freq_gain(freq, sr);
- ret *= lpR[0].freq_gain(freq, sr) * lpR[0].freq_gain(freq, sr) * lpR[0].freq_gain(freq, sr);
- break;
- }
- }
- 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;
- ret *= (*params[param_p4_active] > 0.f) ? pL[3].freq_gain(freq, sr) : 1;
- return ret;
+ srate = sr;
}
- 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<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:
@@@ -1256,50 -1128,6 +1128,50 @@@ public
int get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline);
};
+/// LFO by Markus
+class lfo_audio_module {
+private:
+ float phase, freq, offset, amount;
+ int mode;
+ uint32_t srate;
+ bool is_active;
+public:
+ lfo_audio_module();
+ void set_params(float f, int m, float o, uint32_t sr, float amount = 1.f);
+ float get_value();
+ void advance(uint32_t count);
+ void activate();
+ void deactivate();
+ float get_value_from_phase(float ph, float off);
+ virtual bool get_graph(float *data, int points, cairo_iface *context);
+ virtual bool get_dot(float &x, float &y, int &size, cairo_iface *context);
+};
+
+/// Pulsator by Markus Schmidt
+class pulsator_audio_module: public audio_module<pulsator_metadata>, public frequency_response_line_graph {
+private:
+ uint32_t clip_inL, clip_inR, clip_outL, clip_outR;
+ float meter_inL, meter_inR, meter_outL, meter_outR;
+ float offset_old;
+ int mode_old;
+ lfo_audio_module lfoL, lfoR;
+public:
+ float *ins[in_count];
+ float *outs[out_count];
+ float *params[param_count];
+ uint32_t srate;
+ bool is_active;
+ pulsator_audio_module();
+ void activate();
+ void deactivate();
+ void params_changed();
+ 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_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context);
+ bool get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context);
+};
+
/// Filterclavier --- MIDI controlled filter by Hans Baier
class filterclavier_audio_module:
public audio_module<filterclavier_metadata>,
diff --combined src/modules.cpp
index 0ac187f,fec7c53..309175e
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@@ -31,7 -31,7 +31,7 @@@
using namespace dsp;
using namespace calf_plugins;
- const char *calf_plugins::calf_copyright_info = "(C) 2001-2008 Krzysztof Foltman, license: LGPL";
+ const char *calf_plugins::calf_copyright_info = "(C) 2001-2009 Krzysztof Foltman, Thor Harald Johanssen, Markus Schmidt and others; license: LGPL";
////////////////////////////////////////////////////////////////////////////
@@@ -307,13 -307,13 +307,13 @@@ CALF_PORT_PROPS(multibandcompressor) =
{ 1000, 10, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq1", "Split 2/3" },
{ 6000, 10, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ | PF_PROP_GRAPH, NULL, "freq2", "Split 3/4" },
- { -0.17, -0.5, 0.5, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep0", "S0" },
- { -0.17, -0.5, 0.5, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep1", "S1" },
- { -0.17, -0.5, 0.5, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep2", "S2" },
+ { -0.17, -0.5, 0.5, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep0", "S1" },
+ { -0.17, -0.5, 0.5, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep1", "S2" },
+ { -0.17, -0.5, 0.5, 0, PF_FLOAT | PF_SCALE_LINEAR | PF_CTL_KNOB | PF_UNIT_COEF | PF_PROP_GRAPH, NULL, "sep2", "S3" },
- { 0.895025, 0.25, 4, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q0", "Q0" },
- { 0.895025, 0.25, 4, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q1", "Q1" },
- { 0.895025, 0.25, 4, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q2", "Q2" },
+ { 0.895025, 0.25, 4, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q0", "Q1" },
+ { 0.895025, 0.25, 4, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q1", "Q2" },
+ { 0.895025, 0.25, 4, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB | PF_PROP_GRAPH, NULL, "q2", "Q3" },
{ 0.0625, 0.000976563, 1, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "threshold0", "Threshold 1" },
@@@ -440,8 -440,14 +440,14 @@@ CALF_PLUGIN_INFO(equalizer5band) = { 0x
//////////////////////////////////////////////////////////////////////////////
+ #define EQ_BAND_PARAMS(band, frequency) \
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "p" #band "_active", "F" #band " Active" }, \
+ { 1, 0.015625, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p" #band "_level", "Level " #band }, \
+ { 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(equalizer8band) = {"In L", "In R", "Out L", "Out R"};
- const char *rolloff_mode_names[] = {"12dB", "24dB", "36dB"};
+ 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" },
@@@ -472,22 -478,10 +478,10 @@@
{ 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" },
- { 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" },
- { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "p4_active", "F4 Active" },
- { 1, 0.015625, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p4_level", "Level 4" },
- { 5000, 10, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "p4_freq", "Freq 4" },
- { 1, 0.1, 100, 1, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p4_q", "Q 4" },
+ EQ_BAND_PARAMS(1, 250)
+ EQ_BAND_PARAMS(2, 1000)
+ EQ_BAND_PARAMS(3, 2500)
+ EQ_BAND_PARAMS(4, 5000)
};
CALF_PLUGIN_INFO(equalizer8band) = { 0x8501, "Equalizer8Band", "Calf Equalizer 8 Band", "Markus Schmidt", calf_plugins::calf_copyright_info, "EqualizerPlugin" };
@@@ -525,71 -519,20 +519,47 @@@ CALF_PORT_PROPS(equalizer12band) =
{ 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" },
- { 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" },
- { 60, 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" },
- { 120, 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" },
- { 250, 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" },
- { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "p4_active", "F4 Active" },
- { 1, 0.015625, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p4_level", "Level 4" },
- { 500, 10, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "p4_freq", "Freq 4" },
- { 1, 0.1, 100, 1, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p4_q", "Q 4" },
- { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "p5_active", "F5 Active" },
- { 1, 0.015625, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p5_level", "Level 5" },
- { 1000, 10, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "p5_freq", "Freq 5" },
- { 1, 0.1, 100, 1, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p5_q", "Q 5" },
- { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "p6_active", "F6 Active" },
- { 1, 0.015625, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p6_level", "Level 6" },
- { 2500, 10, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "p6_freq", "Freq 6" },
- { 1, 0.1, 100, 1, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p6_q", "Q 6" },
- { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "p7_active", "F7 Active" },
- { 1, 0.015625, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p7_level", "Level 7" },
- { 4000, 10, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "p7_freq", "Freq 7" },
- { 1, 0.1, 100, 1, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p7_q", "Q 7" },
- { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "p8_active", "F8 Active" },
- { 1, 0.015625, 64, 0, PF_FLOAT | PF_SCALE_GAIN | PF_CTL_KNOB | PF_UNIT_DB, NULL, "p8_level", "Level 8" },
- { 6000, 10, 20000, 0, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_HZ, NULL, "p8_freq", "Freq 8" },
- { 1, 0.1, 100, 1, PF_FLOAT | PF_SCALE_LOG | PF_CTL_KNOB | PF_UNIT_COEF, NULL, "p8_q", "Q 8" },
+ EQ_BAND_PARAMS(1, 60)
+ EQ_BAND_PARAMS(2, 120)
+ EQ_BAND_PARAMS(3, 250)
+ EQ_BAND_PARAMS(4, 500)
+ EQ_BAND_PARAMS(5, 1000)
+ EQ_BAND_PARAMS(6, 2500)
+ EQ_BAND_PARAMS(7, 4000)
+ EQ_BAND_PARAMS(8, 6000)
};
CALF_PLUGIN_INFO(equalizer12band) = { 0x8501, "Equalizer12Band", "Calf Equalizer 12 Band", "Markus Schmidt", calf_plugins::calf_copyright_info, "EqualizerPlugin" };
////////////////////////////////////////////////////////////////////////////
+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" },
+ { 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" },
+ { 0.5, 0, 1, 0, PF_FLOAT | PF_SCALE_PERC, NULL, "offset", "Offset L/R" },
+ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "mono", "Mono-in" },
+};
+
+CALF_PLUGIN_INFO(pulsator) = { 0x8502, "Pulsator", "Calf Pulsator", "Markus Schmidt", calf_plugins::calf_copyright_info, "ModulationPlugin" };
+
+////////////////////////////////////////////////////////////////////////////
+
////////////////////////////////////////////////////////////////////////////
CALF_PORT_NAMES(monosynth) = {
diff --combined src/modules_dsp.cpp
index 94ce716,352ea90..1d827a6
--- a/src/modules_dsp.cpp
+++ b/src/modules_dsp.cpp
@@@ -32,87 -32,6 +32,6 @@@
using namespace dsp;
using namespace calf_plugins;
- /// convert amplitude value to normalized grid-ish value (0dB = 0.5, 30dB = 1.0, -30 dB = 0.0, -60dB = -0.5, -90dB = -1.0)
- static inline float dB_grid(float amp)
- {
- return log(amp) * (1.0 / log(256.0)) + 0.4;
- }
-
- template<class Fx>
- static bool get_graph(Fx &fx, int subindex, float *data, int points)
- {
- for (int i = 0; i < points; i++)
- {
- typedef std::complex<double> cfloat;
- double freq = 20.0 * pow (20000.0 / 20.0, i * 1.0 / points);
- data[i] = dB_grid(fx.freq_gain(subindex, freq, fx.srate));
- }
- return true;
- }
-
- /// convert normalized grid-ish value back to amplitude value
- static inline float dB_grid_inv(float pos)
- {
- return pow(256.0, pos - 0.4);
- }
-
- static void set_channel_color(cairo_iface *context, int channel)
- {
- if (channel & 1)
- context->set_source_rgba(0.35, 0.4, 0.2, 1);
- else
- context->set_source_rgba(0.35, 0.4, 0.2, 0.5);
- context->set_line_width(1.5);
- }
-
- static bool get_freq_gridline(int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context, bool use_frequencies = true)
- {
- if (subindex < 0 )
- return false;
- if (use_frequencies)
- {
- if (subindex < 28)
- {
- vertical = true;
- if (subindex == 9) legend = "100 Hz";
- if (subindex == 18) legend = "1 kHz";
- if (subindex == 27) legend = "10 kHz";
- float freq = 100;
- if (subindex < 9)
- freq = 10 * (subindex + 1);
- else if (subindex < 18)
- freq = 100 * (subindex - 9 + 1);
- else if (subindex < 27)
- freq = 1000 * (subindex - 18 + 1);
- else
- freq = 10000 * (subindex - 27 + 1);
- pos = log(freq / 20.0) / log(1000);
- if (!legend.empty())
- context->set_source_rgba(0, 0, 0, 0.2);
- else
- context->set_source_rgba(0, 0, 0, 0.1);
- return true;
- }
- subindex -= 28;
- }
- if (subindex >= 32)
- return false;
- float gain = 16.0 / (1 << subindex);
- pos = dB_grid(gain);
- if (pos < -1)
- return false;
- if (subindex != 4)
- context->set_source_rgba(0, 0, 0, subindex & 1 ? 0.1 : 0.2);
- if (!(subindex & 1))
- {
- std::stringstream ss;
- ss << (24 - 6 * subindex) << " dB";
- legend = ss.str();
- }
- vertical = false;
- return true;
- }
-
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
bool frequency_response_line_graph::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
@@@ -1811,556 -1730,114 +1730,114 @@@ int gain_reduction_audio_module::get_ch
/// of different chained filters.
///////////////////////////////////////////////////////////////////////////////////////////////
- equalizer12band_audio_module::equalizer12band_audio_module()
+ template<class BaseClass>
+ equalizerNband_audio_module<BaseClass>::equalizerNband_audio_module()
{
is_active = false;
srate = 0;
last_generation = 0;
- clip_inL = 0.f;
- clip_inR = 0.f;
- clip_outL = 0.f;
- clip_outR = 0.f;
- meter_inL = 0.f;
- meter_inR = 0.f;
- meter_outL = 0.f;
- meter_outR = 0.f;
+ clip_inL = clip_inR = clip_outL = clip_outR = 0.f;
+ meter_inL = meter_inR = meter_outL = meter_outR = 0.f;
}
- void equalizer12band_audio_module::activate()
+ template<class BaseClass>
+ void equalizerNband_audio_module<BaseClass>::activate()
{
is_active = true;
// set all filters
params_changed();
}
- void equalizer12band_audio_module::deactivate()
+
+ template<class BaseClass>
+ void equalizerNband_audio_module<BaseClass>::deactivate()
{
is_active = false;
}
- void equalizer12band_audio_module::params_changed()
+ static inline void copy_lphp(biquad_d2<float> filters[3][2])
{
- // set the params of all filters
- if(*params[param_hp_freq] != hp_freq_old) {
- hpL[0].set_hp_rbj(*params[param_hp_freq], 0.707, (float)srate, 1.0);
- hpL[1].copy_coeffs(hpL[0]);
- hpL[2].copy_coeffs(hpL[0]);
- hpR[0].copy_coeffs(hpL[0]);
- hpR[1].copy_coeffs(hpL[0]);
- hpR[2].copy_coeffs(hpL[0]);
- hp_freq_old = *params[param_hp_freq];
- }
- if(*params[param_lp_freq] != lp_freq_old) {
- lpL[0].set_lp_rbj(*params[param_lp_freq], 0.707, (float)srate, 1.0);
- lpL[1].copy_coeffs(lpL[0]);
- lpL[2].copy_coeffs(lpL[0]);
- lpR[0].copy_coeffs(lpL[0]);
- lpR[1].copy_coeffs(lpL[0]);
- lpR[2].copy_coeffs(lpL[0]);
- lp_freq_old = *params[param_lp_freq];
- }
- 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];
- }
- if(*params[param_p4_freq] != p_freq_old[3] or *params[param_p4_level] != p_level_old[3] or *params[param_p4_q] != p_q_old[3]) {
- pL[3].set_peakeq_rbj((float)*params[param_p4_freq], *params[param_p4_q], *params[param_p4_level], (float)srate);
- pR[3].copy_coeffs(pL[3]);
- p_freq_old[3] = *params[param_p4_freq];
- p_level_old[3] = *params[param_p4_level];
- p_q_old[3] = *params[param_p4_q];
- }
- if(*params[param_p5_freq] != p_freq_old[4] or *params[param_p5_level] != p_level_old[4] or *params[param_p5_q] != p_q_old[4]) {
- pL[4].set_peakeq_rbj((float)*params[param_p5_freq], *params[param_p5_q], *params[param_p5_level], (float)srate);
- pR[4].copy_coeffs(pL[4]);
- p_freq_old[4] = *params[param_p5_freq];
- p_level_old[4] = *params[param_p5_level];
- p_q_old[4] = *params[param_p5_q];
- }
- if(*params[param_p6_freq] != p_freq_old[5] or *params[param_p6_level] != p_level_old[5] or *params[param_p6_q] != p_q_old[5]) {
- pL[5].set_peakeq_rbj((float)*params[param_p6_freq], *params[param_p6_q], *params[param_p6_level], (float)srate);
- pR[5].copy_coeffs(pL[5]);
- p_freq_old[5] = *params[param_p6_freq];
- p_level_old[5] = *params[param_p6_level];
- p_q_old[5] = *params[param_p6_q];
- }
- if(*params[param_p7_freq] != p_freq_old[6] or *params[param_p7_level] != p_level_old[6] or *params[param_p7_q] != p_q_old[6]) {
- pL[6].set_peakeq_rbj((float)*params[param_p7_freq], *params[param_p7_q], *params[param_p7_level], (float)srate);
- pR[6].copy_coeffs(pL[6]);
- p_freq_old[6] = *params[param_p7_freq];
- p_level_old[6] = *params[param_p7_level];
- p_q_old[6] = *params[param_p7_q];
- }
- if(*params[param_p8_freq] != p_freq_old[7] or *params[param_p8_level] != p_level_old[7] or *params[param_p8_q] != p_q_old[7]) {
- pL[7].set_peakeq_rbj((float)*params[param_p8_freq], *params[param_p8_q], *params[param_p8_level], (float)srate);
- pR[7].copy_coeffs(pL[7]);
- p_freq_old[7] = *params[param_p8_freq];
- p_level_old[7] = *params[param_p8_level];
- p_q_old[7] = *params[param_p8_q];
- }
- }
-
- void equalizer12band_audio_module::set_sample_rate(uint32_t sr)
- {
- srate = sr;
+ for (int i = 0; i < 3; i++)
+ for (int j = 0; j < 2; j++)
+ if (i || j)
+ filters[i][j].copy_coeffs(filters[0][0]);
}
- uint32_t equalizer12band_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_inL = 0.f;
- clip_inR = 0.f;
- clip_outL = 0.f;
- clip_outR = 0.f;
- meter_inL = 0.f;
- meter_inR = 0.f;
- meter_outL = 0.f;
- meter_outR = 0.f;
- } else {
-
- clip_inL -= std::min(clip_inL, numsamples);
- clip_inR -= std::min(clip_inR, numsamples);
- clip_outL -= std::min(clip_outL, numsamples);
- clip_outR -= std::min(clip_outR, numsamples);
- meter_inL = 0.f;
- meter_inR = 0.f;
- meter_outL = 0.f;
- meter_outR = 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_hp_active] > 0.f) {
- switch((int)*params[param_hp_mode]) {
- case MODE12DB:
- procL = hpL[0].process(procL);
- procR = hpR[0].process(procR);
- break;
- case MODE24DB:
- procL = hpL[1].process(hpL[0].process(procL));
- procR = hpR[1].process(hpR[0].process(procR));
- break;
- case MODE36DB:
- procL = hpL[2].process(hpL[1].process(hpL[0].process(procL)));
- procR = hpR[2].process(hpR[1].process(hpR[0].process(procR)));
- break;
- }
- }
- if(*params[param_lp_active] > 0.f) {
- switch((int)*params[param_lp_mode]) {
- case MODE12DB:
- procL = lpL[0].process(procL);
- procR = lpR[0].process(procR);
- break;
- case MODE24DB:
- procL = lpL[1].process(lpL[0].process(procL));
- procR = lpR[1].process(lpR[0].process(procR));
- break;
- case MODE36DB:
- procL = lpL[2].process(lpL[1].process(lpL[0].process(procL)));
- procR = lpR[2].process(lpR[1].process(lpR[0].process(procR)));
- break;
- }
- }
- 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);
- }
- if(*params[param_p4_active] > 0.f) {
- procL = pL[3].process(procL);
- procR = pR[3].process(procR);
- }
- if(*params[param_p5_active] > 0.f) {
- procL = pL[4].process(procL);
- procR = pR[4].process(procR);
- }
- if(*params[param_p6_active] > 0.f) {
- procL = pL[5].process(procL);
- procR = pR[5].process(procR);
- }
- if(*params[param_p7_active] > 0.f) {
- procL = pL[6].process(procL);
- procR = pR[6].process(procR);
- }
- if(*params[param_p8_active] > 0.f) {
- procL = pL[7].process(procL);
- procR = pR[7].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
- if(inL > 1.f) {
- clip_inL = srate >> 3;
- }
- if(inR > 1.f) {
- clip_inR = srate >> 3;
- }
- if(outL > 1.f) {
- clip_outL = srate >> 3;
- }
- if(outR > 1.f) {
- clip_outR = srate >> 3;
- }
- // set up in / out meters
- if(inL > meter_inL) {
- meter_inL = inL;
- }
- if(inR > meter_inR) {
- meter_inR = inR;
- }
- if(outL > meter_outL) {
- meter_outL = outL;
- }
- if(outR > meter_outR) {
- meter_outR = outR;
- }
-
- // next sample
- ++offset;
- } // cycle trough samples
- // clean up
- for(int i = 0; i < 3; ++i) {
- hpL[i].sanitize();
- hpR[i].sanitize();
- lpL[i].sanitize();
- lpR[i].sanitize();
- }
- lsL.sanitize();
- hsR.sanitize();
- for(int i = 0; i < 8; ++i) {
- pL[i].sanitize();
- pR[i].sanitize();
- }
- }
- // draw meters
- if(params[param_clip_inL] != NULL) {
- *params[param_clip_inL] = clip_inL;
- }
- if(params[param_clip_inR] != NULL) {
- *params[param_clip_inR] = clip_inR;
- }
- if(params[param_clip_outL] != NULL) {
- *params[param_clip_outL] = clip_outL;
- }
- if(params[param_clip_outR] != NULL) {
- *params[param_clip_outR] = clip_outR;
- }
-
- if(params[param_meter_inL] != NULL) {
- *params[param_meter_inL] = meter_inL;
- }
- if(params[param_meter_inR] != NULL) {
- *params[param_meter_inR] = meter_inR;
- }
- if(params[param_meter_outL] != NULL) {
- *params[param_meter_outL] = meter_outL;
- }
- if(params[param_meter_outR] != NULL) {
- *params[param_meter_outR] = meter_outR;
- }
- // whatever has to be returned x)
- return outputs_mask;
- }
- bool equalizer12band_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 equalizer12band_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
+ template<class BaseClass>
+ void equalizerNband_audio_module<BaseClass>::params_changed()
{
- if (!is_active) {
- return false;
- } else {
- return get_freq_gridline(subindex, pos, vertical, legend, context);
+ // 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;
}
- }
-
- int equalizer12band_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_hp_freq] != hp_freq_old1
- or *params[param_hp_mode] != hp_mode_old1
- or *params[param_lp_freq] != lp_freq_old1
- or *params[param_lp_mode] != lp_mode_old1
-
- or *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]
-
- or *params[param_p4_freq] != p_freq_old1[3]
- or *params[param_p4_level] != p_level_old1[3]
- or *params[param_p4_q] != p_q_old1[3]
-
- or *params[param_p5_freq] != p_freq_old1[4]
- or *params[param_p5_level] != p_level_old1[4]
- or *params[param_p5_q] != p_q_old1[4]
-
- or *params[param_p6_freq] != p_freq_old1[5]
- or *params[param_p6_level] != p_level_old1[5]
- or *params[param_p6_q] != p_q_old1[5]
-
- or *params[param_p7_freq] != p_freq_old1[6]
- or *params[param_p7_level] != p_level_old1[6]
- or *params[param_p7_q] != p_q_old1[6]
-
- or *params[param_p8_freq] != p_freq_old1[7]
- or *params[param_p8_level] != p_level_old1[7]
- or *params[param_p8_q] != p_q_old1[7])
- {
-
- hp_freq_old1 = *params[param_hp_freq];
- hp_mode_old1 = *params[param_hp_mode];
- lp_freq_old1 = *params[param_lp_freq];
- lp_mode_old1 = *params[param_lp_mode];
-
- 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];
-
- p_freq_old1[3] = *params[param_p4_freq];
- p_level_old1[3] = *params[param_p4_level];
- p_q_old1[3] = *params[param_p4_q];
-
- p_freq_old1[4] = *params[param_p5_freq];
- p_level_old1[4] = *params[param_p5_level];
- p_q_old1[4] = *params[param_p5_q];
-
- p_freq_old1[5] = *params[param_p6_freq];
- p_level_old1[5] = *params[param_p6_level];
- p_q_old1[5] = *params[param_p6_q];
-
- p_freq_old1[6] = *params[param_p7_freq];
- p_level_old1[6] = *params[param_p7_level];
- p_q_old1[6] = *params[param_p7_q];
-
- p_freq_old1[7] = *params[param_p8_freq];
- p_level_old1[7] = *params[param_p8_level];
- p_q_old1[7] = *params[param_p8_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;
+ 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;
}
- return false;
- }
- /// Equalizer 8 Band by Markus Schmidt
- ///
- /// This module is based on Krzysztof's filters. It provides a couple
- /// of different chained filters.
- ///////////////////////////////////////////////////////////////////////////////////////////////
-
- equalizer8band_audio_module::equalizer8band_audio_module()
- {
- is_active = false;
- srate = 0;
- last_generation = 0;
- clip_inL = 0.f;
- clip_inR = 0.f;
- clip_outL = 0.f;
- clip_outR = 0.f;
- meter_inL = 0.f;
- meter_inR = 0.f;
- meter_outL = 0.f;
- meter_outR = 0.f;
- }
-
- void equalizer8band_audio_module::activate()
- {
- is_active = true;
- // set all filters
- params_changed();
- }
- void equalizer8band_audio_module::deactivate()
- {
- is_active = false;
- }
-
- void equalizer8band_audio_module::params_changed()
- {
- // set the params of all filters
- if(*params[param_hp_freq] != hp_freq_old) {
- hpL[0].set_hp_rbj(*params[param_hp_freq], 0.707, (float)srate, 1.0);
- hpL[1].copy_coeffs(hpL[0]);
- hpL[2].copy_coeffs(hpL[0]);
- hpR[0].copy_coeffs(hpL[0]);
- hpR[1].copy_coeffs(hpL[0]);
- hpR[2].copy_coeffs(hpL[0]);
- hp_freq_old = *params[param_hp_freq];
- }
- if(*params[param_lp_freq] != lp_freq_old) {
- lpL[0].set_lp_rbj(*params[param_lp_freq], 0.707, (float)srate, 1.0);
- lpL[1].copy_coeffs(lpL[0]);
- lpL[2].copy_coeffs(lpL[0]);
- lpR[0].copy_coeffs(lpL[0]);
- lpR[1].copy_coeffs(lpL[0]);
- lpR[2].copy_coeffs(lpL[0]);
- lp_freq_old = *params[param_lp_freq];
- }
- 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);
+ // 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];
+
+ if(lsfreq != ls_freq_old or lslevel != ls_level_old) {
+ lsL.set_lowshelf_rbj(lsfreq, 0.707, lslevel, (float)srate);
lsR.copy_coeffs(lsL);
- ls_level_old = *params[param_ls_level];
- ls_freq_old = *params[param_ls_freq];
+ ls_level_old = lslevel;
+ ls_freq_old = lsfreq;
}
- 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);
+ if(hsfreq != hs_freq_old or hslevel != hs_level_old) {
+ hsL.set_highshelf_rbj(hsfreq, 0.707, hslevel, (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];
+ hs_level_old = hslevel;
+ hs_freq_old = hsfreq;
}
- 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];
- }
- if(*params[param_p4_freq] != p_freq_old[3] or *params[param_p4_level] != p_level_old[3] or *params[param_p4_q] != p_q_old[3]) {
- pL[3].set_peakeq_rbj((float)*params[param_p4_freq], *params[param_p4_q], *params[param_p4_level], (float)srate);
- pR[3].copy_coeffs(pL[3]);
- p_freq_old[3] = *params[param_p4_freq];
- p_level_old[3] = *params[param_p4_level];
- p_q_old[3] = *params[param_p4_q];
+ for (int i = 0; i < AM::PeakBands; i++)
+ {
+ int offset = i * params_per_band;
+ float freq = *params[AM::param_p1_freq + offset];
+ float level = *params[AM::param_p1_level + offset];
+ float q = *params[AM::param_p1_q + offset];
+ if(freq != p_freq_old[i] or level != p_level_old[i] or q != p_q_old[i]) {
+ pL[i].set_peakeq_rbj(freq, q, level, (float)srate);
+ pR[i].copy_coeffs(pL[i]);
+ p_freq_old[i] = freq;
+ p_level_old[i] = level;
+ p_q_old[i] = q;
+ }
}
}
- void equalizer8band_audio_module::set_sample_rate(uint32_t sr)
+ static void process_hplp(float &procL, float &procR, dsp::biquad_d2<float> filter[3][2], CalfEqMode mode)
{
- srate = sr;
+ 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;
+ }
}
- uint32_t equalizer8band_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
+ #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)
{
- bool bypass = *params[param_bypass] > 0.5f;
+ bool bypass = *params[AM::param_bypass] > 0.f;
numsamples += offset;
if(bypass) {
// everything bypassed
@@@ -2370,14 -1847,8 +1847,8 @@@
++offset;
}
// displays, too
- clip_inL = 0.f;
- clip_inR = 0.f;
- clip_outL = 0.f;
- clip_outR = 0.f;
- meter_inL = 0.f;
- meter_inR = 0.f;
- meter_outL = 0.f;
- meter_outR = 0.f;
+ clip_inL = clip_inR = clip_outL = clip_outR = 0.f;
+ meter_inL = meter_inR = meter_outL = meter_outR = 0.f;
} else {
clip_inL -= std::min(clip_inL, numsamples);
@@@ -2388,6 -1859,8 +1859,8 @@@
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) {
@@@ -2397,72 -1870,37 +1870,37 @@@
float inL = ins[0][offset];
float inR = ins[1][offset];
// in level
- inR *= *params[param_level_in];
- inL *= *params[param_level_in];
+ inR *= *params[AM::param_level_in];
+ inL *= *params[AM::param_level_in];
float procL = inL;
float procR = inR;
// all filters in chain
- if(*params[param_hp_active] > 0.f) {
- switch((int)*params[param_hp_mode]) {
- case MODE12DB:
- procL = hpL[0].process(procL);
- procR = hpR[0].process(procR);
- break;
- case MODE24DB:
- procL = hpL[1].process(hpL[0].process(procL));
- procR = hpR[1].process(hpR[0].process(procR));
- break;
- case MODE36DB:
- procL = hpL[2].process(hpL[1].process(hpL[0].process(procL)));
- procR = hpR[2].process(hpR[1].process(hpR[0].process(procR)));
- break;
- }
+ if(*params[AM::param_hp_active] > 0.f) {
+ process_hplp(procL, procR, hp, hp_mode);
}
- if(*params[param_lp_active] > 0.f) {
- switch((int)*params[param_lp_mode]) {
- case MODE12DB:
- procL = lpL[0].process(procL);
- procR = lpR[0].process(procR);
- break;
- case MODE24DB:
- procL = lpL[1].process(lpL[0].process(procL));
- procR = lpR[1].process(lpR[0].process(procR));
- break;
- case MODE36DB:
- procL = lpL[2].process(lpL[1].process(lpL[0].process(procL)));
- procR = lpR[2].process(lpR[1].process(lpR[0].process(procR)));
- break;
- }
+ if(*params[AM::param_lp_active] > 0.f) {
+ process_hplp(procL, procR, lp, lp_mode);
}
- if(*params[param_ls_active] > 0.f) {
+ if(*params[AM::param_ls_active] > 0.f) {
procL = lsL.process(procL);
procR = lsR.process(procR);
}
- if(*params[param_hs_active] > 0.f) {
+ if(*params[AM::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);
- }
- if(*params[param_p4_active] > 0.f) {
- procL = pL[3].process(procL);
- procR = pR[3].process(procR);
+ for (int i = 0; i < AM::PeakBands; i++)
+ {
+ if(*params[AM::param_p1_active + i * params_per_band] > 0.f) {
+ procL = pL[i].process(procL);
+ procR = pR[i].process(procR);
+ }
}
- outL = procL * *params[param_level_out];
- outR = procR * *params[param_level_out];
+ outL = procL * *params[AM::param_level_out];
+ outR = procR * *params[AM::param_level_out];
// send to output
outs[0][offset] = outL;
@@@ -2500,59 -1938,47 +1938,47 @@@
} // cycle trough samples
// clean up
for(int i = 0; i < 3; ++i) {
- hpL[i].sanitize();
- hpR[i].sanitize();
- lpL[i].sanitize();
- lpR[i].sanitize();
+ hp[i][0].sanitize();
+ hp[i][1].sanitize();
+ lp[i][0].sanitize();
+ lp[i][1].sanitize();
}
lsL.sanitize();
hsR.sanitize();
- for(int i = 0; i < 4; ++i) {
+ for(int i = 0; i < AM::PeakBands; ++i) {
pL[i].sanitize();
pR[i].sanitize();
}
}
// draw meters
- if(params[param_clip_inL] != NULL) {
- *params[param_clip_inL] = clip_inL;
- }
- if(params[param_clip_inR] != NULL) {
- *params[param_clip_inR] = clip_inR;
- }
- if(params[param_clip_outL] != NULL) {
- *params[param_clip_outL] = clip_outL;
- }
- if(params[param_clip_outR] != NULL) {
- *params[param_clip_outR] = clip_outR;
- }
-
- if(params[param_meter_inL] != NULL) {
- *params[param_meter_inL] = meter_inL;
- }
- if(params[param_meter_inR] != NULL) {
- *params[param_meter_inR] = meter_inR;
- }
- if(params[param_meter_outL] != NULL) {
- *params[param_meter_outL] = meter_outL;
- }
- if(params[param_meter_outR] != NULL) {
- *params[param_meter_outR] = meter_outR;
- }
+ SET_IF_CONNECTED(clip_inL)
+ SET_IF_CONNECTED(clip_inR)
+ SET_IF_CONNECTED(clip_outL)
+ SET_IF_CONNECTED(clip_outR)
+ SET_IF_CONNECTED(meter_inL)
+ SET_IF_CONNECTED(meter_inR)
+ SET_IF_CONNECTED(meter_outL)
+ SET_IF_CONNECTED(meter_outR)
// whatever has to be returned x)
return outputs_mask;
}
- bool equalizer8band_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
+
+ #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)
{
if (!is_active)
return false;
- if (index == param_p1_freq && !subindex) {
+ if (index == AM::param_p1_freq && !subindex) {
context->set_line_width(1.5);
return ::get_graph(*this, subindex, data, points);
}
return false;
}
- bool equalizer8band_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
+ template<class BaseClass>
+ bool equalizerNband_audio_module<BaseClass>::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
{
if (!is_active) {
return false;
@@@ -2561,63 -1987,22 +1987,22 @@@
}
}
- int equalizer8band_audio_module::get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline)
+ template<class BaseClass>
+ int equalizerNband_audio_module<BaseClass>::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_hp_freq] != hp_freq_old1
- or *params[param_hp_mode] != hp_mode_old1
- or *params[param_lp_freq] != lp_freq_old1
- or *params[param_lp_mode] != lp_mode_old1
-
- or *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]
-
- or *params[param_p4_freq] != p_freq_old1[3]
- or *params[param_p4_level] != p_level_old1[3]
- or *params[param_p4_q] != p_q_old1[3])
+ bool changed = false;
+ for (int i = 0; i < graph_param_count && !changed; i++)
{
-
- hp_freq_old1 = *params[param_hp_freq];
- hp_mode_old1 = *params[param_hp_mode];
- lp_freq_old1 = *params[param_lp_freq];
- lp_mode_old1 = *params[param_lp_mode];
-
- 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];
-
- p_freq_old1[3] = *params[param_p4_freq];
- p_level_old1[3] = *params[param_p4_level];
- p_q_old1[3] = *params[param_p4_q];
+ if (*params[AM::first_graph_param + i] != old_params_for_graph[i])
+ changed = true;
+ }
+ if (changed)
+ {
+ for (int i = 0; i < graph_param_count; i++)
+ old_params_for_graph[i] = *params[AM::first_graph_param + i];
last_generation++;
subindex_graph = 0;
@@@ -2635,6 -2020,38 +2020,38 @@@
return false;
}
+ static inline float adjusted_lphp_gain(float **params, int param_active, int param_mode, biquad_d2<float> filter, float freq, float srate)
+ {
+ if(*params[param_active] > 0.f) {
+ float gain = filter.freq_gain(freq, srate);
+ switch((int)*params[param_mode]) {
+ case MODE12DB:
+ return gain;
+ case MODE24DB:
+ return gain * gain;
+ case MODE36DB:
+ return gain * gain * gain;
+ }
+ }
+ return 1;
+ }
+
+ template<class BaseClass>
+ float equalizerNband_audio_module<BaseClass>::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);
+ 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++)
+ ret *= (*params[AM::param_p1_active + i * params_per_band] > 0.f) ? pL[i].freq_gain(freq, (float)sr) : 1;
+ 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
@@@ -2893,331 -2310,3 +2310,331 @@@ int equalizer5band_audio_module::get_ch
}
return false;
}
+
+/// LFO module by Markus
+/// This module provides simple LFO's (sine=0, triangle=1, square=2, saw_up=3, saw_down=4)
+/// get_value() returns a value between -1 and 1
+////////////////////////////////////////////////////////////////////////////////
+lfo_audio_module::lfo_audio_module()
+{
+ is_active = false;
+ phase = 0.f;
+}
+
+void lfo_audio_module::activate()
+{
+ is_active = true;
+ phase = 0.f;
+}
+
+void lfo_audio_module::deactivate()
+{
+ is_active = false;
+}
+
+float lfo_audio_module::get_value()
+{
+ return get_value_from_phase(phase, offset) * amount;
+}
+
+float lfo_audio_module::get_value_from_phase(float ph, float off)
+{
+ float val = 0.f;
+ float phs = ph + off;
+ if (phs >= 1.0)
+ phs = fmod(phs, 1.f);
+ switch (mode) {
+ default:
+ case 0:
+ // sine
+ val = sin((phs * 360.f) * M_PI / 180);
+ break;
+ case 1:
+ // triangle
+ if(phs > 0.75)
+ val = (phs - 0.75) * 4 - 1;
+ else if(phs > 0.5)
+ val = (phs - 0.5) * 4 * -1;
+ else if(phs > 0.25)
+ val = 1 - (phs - 0.25) * 4;
+ else
+ val = phs * 4;
+ break;
+ case 2:
+ // square
+ val = (phs < 0.5) ? -1 : +1;
+ break;
+ case 3:
+ // saw up
+ val = phs * 2.f - 1;
+ break;
+ case 4:
+ // saw down
+ val = 1 - phs * 2.f;
+ break;
+ }
+ return val;
+}
+
+void lfo_audio_module::advance(uint32_t count)
+{
+ //this function walks from 0.f to 1.f and starts all over again
+ phase += count * freq * (1.0 / srate);
+ if (phase >= 1.0)
+ phase = fmod(phase, 1.f);
+}
+
+void lfo_audio_module::set_params(float f, int m, float o, uint32_t sr, float a)
+{
+ // freq: a value in Hz
+ // mode: sine=0, triangle=1, square=2, saw_up=3, saw_down=4
+ // offset: value between 0.f and 1.f to offset the lfo in time
+ freq = f;
+ mode = m;
+ offset = o;
+ srate = sr;
+ amount = a;
+}
+
+bool lfo_audio_module::get_graph(float *data, int points, cairo_iface *context)
+{
+ if (!is_active)
+ return false;
+ for (int i = 0; i < points; i++) {
+ float ph = (float)i / (float)points;
+ data[i] = get_value_from_phase(ph, offset) * amount;
+ }
+ return true;
+}
+
+bool lfo_audio_module::get_dot(float &x, float &y, int &size, cairo_iface *context)
+{
+ if (!is_active)
+ return false;
+ float phs = phase + offset;
+ if (phs >= 1.0)
+ phs = fmod(phs, 1.f);
+ x = phase;
+ y = get_value_from_phase(phase, offset) * amount;
+}
+
+/// Pulsator by Markus Schmidt
+///
+/// This module provides a couple
+/// of different LFO's for modulating the level of a signal.
+///////////////////////////////////////////////////////////////////////////////////////////////
+
+pulsator_audio_module::pulsator_audio_module()
+{
+ is_active = false;
+ srate = 0;
+// last_generation = 0;
+ clip_inL = 0.f;
+ clip_inR = 0.f;
+ clip_outL = 0.f;
+ clip_outR = 0.f;
+ meter_inL = 0.f;
+ meter_inR = 0.f;
+ meter_outL = 0.f;
+ meter_outR = 0.f;
+}
+
+void pulsator_audio_module::activate()
+{
+ is_active = true;
+ lfoL.activate();
+ lfoR.activate();
+ params_changed();
+}
+void pulsator_audio_module::deactivate()
+{
+ is_active = false;
+ lfoL.deactivate();
+ lfoR.deactivate();
+}
+
+void pulsator_audio_module::params_changed()
+{
+ lfoL.set_params(*params[param_freq], *params[param_mode], 0.f, srate, *params[param_amount]);
+ lfoR.set_params(*params[param_freq], *params[param_mode], *params[param_offset], srate, *params[param_amount]);
+}
+
+void pulsator_audio_module::set_sample_rate(uint32_t sr)
+{
+ srate = sr;
+}
+
+uint32_t pulsator_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask)
+{
+ bool bypass = *params[param_bypass] > 0.5f;
+ uint32_t samples = numsamples + offset;
+ if(bypass) {
+ // everything bypassed
+ while(offset < samples) {
+ outs[0][offset] = ins[0][offset];
+ outs[1][offset] = ins[1][offset];
+ ++offset;
+ }
+ // displays, too
+ clip_inL = 0.f;
+ clip_inR = 0.f;
+ clip_outL = 0.f;
+ clip_outR = 0.f;
+ meter_inL = 0.f;
+ meter_inR = 0.f;
+ meter_outL = 0.f;
+ meter_outR = 0.f;
+
+ // LFO's should go on
+ lfoL.advance(numsamples);
+ lfoR.advance(numsamples);
+
+ } else {
+
+ clip_inL -= std::min(clip_inL, numsamples);
+ clip_inR -= std::min(clip_inR, numsamples);
+ clip_outL -= std::min(clip_outL, numsamples);
+ clip_outR -= std::min(clip_outR, numsamples);
+ meter_inL = 0.f;
+ meter_inR = 0.f;
+ meter_outL = 0.f;
+ meter_outR = 0.f;
+
+ // process
+ while(offset < samples) {
+ // 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];
+
+ if(*params[param_mono] > 0.5) {
+ inL = (inL + inR) * 0.5;
+ inR = inL;
+ }
+ float procL = inL;
+ float procR = inR;
+
+ procL *= (lfoL.get_value() * 0.5 + *params[param_amount] / 2);
+ procR *= (lfoR.get_value() * 0.5 + *params[param_amount] / 2);
+
+ outL = procL + inL * (1 - *params[param_amount]);
+ outR = procR + inR * (1 - *params[param_amount]);
+
+ outL *= *params[param_level_out];
+ outR *= *params[param_level_out];
+
+ // send to output
+ outs[0][offset] = outL;
+ outs[1][offset] = outR;
+
+ // clip LED's
+ if(inL > 1.f) {
+ clip_inL = srate >> 3;
+ }
+ if(inR > 1.f) {
+ clip_inR = srate >> 3;
+ }
+ if(outL > 1.f) {
+ clip_outL = srate >> 3;
+ }
+ if(outR > 1.f) {
+ clip_outR = srate >> 3;
+ }
+ // set up in / out meters
+ if(inL > meter_inL) {
+ meter_inL = inL;
+ }
+ if(inR > meter_inR) {
+ meter_inR = inR;
+ }
+ if(outL > meter_outL) {
+ meter_outL = outL;
+ }
+ if(outR > meter_outR) {
+ meter_outR = outR;
+ }
+
+ // next sample
+ ++offset;
+
+ // advance lfo's
+ lfoL.advance(1);
+ lfoR.advance(1);
+ } // cycle trough samples
+ }
+ // draw meters
+ if(params[param_clip_inL] != NULL) {
+ *params[param_clip_inL] = clip_inL;
+ }
+ if(params[param_clip_inR] != NULL) {
+ *params[param_clip_inR] = clip_inR;
+ }
+ if(params[param_clip_outL] != NULL) {
+ *params[param_clip_outL] = clip_outL;
+ }
+ if(params[param_clip_outR] != NULL) {
+ *params[param_clip_outR] = clip_outR;
+ }
+
+ if(params[param_meter_inL] != NULL) {
+ *params[param_meter_inL] = meter_inL;
+ }
+ if(params[param_meter_inR] != NULL) {
+ *params[param_meter_inR] = meter_inR;
+ }
+ if(params[param_meter_outL] != NULL) {
+ *params[param_meter_outL] = meter_outL;
+ }
+ if(params[param_meter_outR] != NULL) {
+ *params[param_meter_outR] = meter_outR;
+ }
+ // whatever has to be returned x)
+ return outputs_mask;
+}
+bool pulsator_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context)
+{
+ if (!is_active) {
+ return false;
+ } else if(index == param_freq) {
+ if(subindex == 0) {
+ context->set_source_rgba(0.35, 0.4, 0.2, 1);
+ return lfoL.get_graph(data, points, context);
+ }
+ if(subindex == 1) {
+ context->set_source_rgba(0.35, 0.4, 0.2, 0.5);
+ return lfoR.get_graph(data, points, context);
+ }
+ }
+ return false;
+}
+bool pulsator_audio_module::get_dot(int index, int subindex, float &x, float &y, int &size, cairo_iface *context)
+{
+ if (!is_active) {
+ return false;
+ } else if(index == param_freq) {
+ if(subindex == 0) {
+ context->set_source_rgba(0.35, 0.4, 0.2, 1);
+ return lfoL.get_dot(x, y, size, context);
+ }
+ if(subindex == 1) {
+ context->set_source_rgba(0.35, 0.4, 0.2, 0.5);
+ return lfoR.get_dot(x, y, size, context);
+ }
+ return false;
+ }
+ return false;
+}
+bool pulsator_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context)
+{
+ if (index == param_freq && !subindex)
+ {
+ pos = 0;
+ vertical = false;
+ return true;
+ }
+ return false;
+}
--
calf audio plugins packaging
More information about the pkg-multimedia-commits
mailing list