diff --git a/plugins/ladspa_effect/calf/calf/metadata.h b/plugins/ladspa_effect/calf/calf/metadata.h index a99259067..a92bb64f1 100644 --- a/plugins/ladspa_effect/calf/calf/metadata.h +++ b/plugins/ladspa_effect/calf/calf/metadata.h @@ -192,14 +192,18 @@ struct deesser_metadata: public plugin_metadata struct equalizer5band_metadata: public plugin_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 @@ -243,6 +247,16 @@ struct equalizer12band_metadata: public plugin_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 --git a/plugins/ladspa_effect/calf/calf/modules.h b/plugins/ladspa_effect/calf/calf/modules.h index 6c9008a41..d33fe9545 100644 --- a/plugins/ladspa_effect/calf/calf/modules.h +++ b/plugins/ladspa_effect/calf/calf/modules.h @@ -1039,7 +1039,7 @@ public: }; /// Equalizer N Band by Markus Schmidt (based on Krzysztof's filters) -template +template class equalizerNband_audio_module: public audio_module, public frequency_response_line_graph { public: typedef audio_module 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 hp[3][2], lp[3][2]; biquad_d2 lsL, lsR, hsL, hsR; biquad_d2 pL[PeakBands], pR[PeakBands]; + + inline void process_hplp(float &left, float &right); public: typedef std::complex 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,49 +1087,52 @@ public: int get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline); }; -typedef equalizerNband_audio_module equalizer8band_audio_module; -typedef equalizerNband_audio_module equalizer12band_audio_module; +typedef equalizerNband_audio_module equalizer5band_audio_module; +typedef equalizerNband_audio_module equalizer8band_audio_module; +typedef equalizerNband_audio_module equalizer12band_audio_module; -/// Equalizer 5 Band by Markus Schmidt (based on Krzysztof's filters) -class equalizer5band_audio_module: public audio_module, public frequency_response_line_graph { +/// LFO by Markus +class lfo_audio_module { 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 lsL, lsR, hsL, hsR; - biquad_d2 pL[3], pR[3]; + 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, 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: - typedef std::complex 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(); + pulsator_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_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); - int get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline); }; /// Filterclavier --- MIDI controlled filter by Hans Baier diff --git a/plugins/ladspa_effect/calf/src/giface.cpp b/plugins/ladspa_effect/calf/src/giface.cpp index a9737cc68..bd71b2720 100644 --- a/plugins/ladspa_effect/calf/src/giface.cpp +++ b/plugins/ladspa_effect/calf/src/giface.cpp @@ -21,7 +21,6 @@ #include #include #include -#include #include using namespace std; using namespace calf_utils; @@ -203,6 +202,7 @@ void calf_plugins::plugin_ctl_iface::clear_preset() { const char *calf_plugins::load_gui_xml(const std::string &plugin_id) { +#if 0 try { return strdup(calf_utils::load_file((std::string(PKGLIBDIR) + "/gui-" + plugin_id + ".xml").c_str()).c_str()); } @@ -210,6 +210,7 @@ const char *calf_plugins::load_gui_xml(const std::string &plugin_id) { return NULL; } +#endif } bool calf_plugins::check_for_message_context_ports(parameter_properties *parameters, int count) diff --git a/plugins/ladspa_effect/calf/src/modules.cpp b/plugins/ladspa_effect/calf/src/modules.cpp index 7b5f2edbd..acf6a15a2 100644 --- a/plugins/ladspa_effect/calf/src/modules.cpp +++ b/plugins/ladspa_effect/calf/src/modules.cpp @@ -306,13 +306,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" }, @@ -401,43 +401,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" }, +#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" }, - - { 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 EQ_BAND_PARAMS(band, frequency) \ { 0, 0, 1, 0, PF_BOOL | PF_CTL_TOGGLE, NULL, "p" #band "_active", "F" #band " Active" }, \ @@ -445,38 +440,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) @@ -490,34 +479,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) @@ -532,6 +497,24 @@ CALF_PLUGIN_INFO(equalizer12band) = { 0x8501, "Equalizer12Band", "Calf Equalizer //////////////////////////////////////////////////////////////////////////// +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) = { + 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" }, + { 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 --git a/plugins/ladspa_effect/calf/src/modules_dsp.cpp b/plugins/ladspa_effect/calf/src/modules_dsp.cpp index 48ea8d51c..3dbb6b0db 100644 --- a/plugins/ladspa_effect/calf/src/modules_dsp.cpp +++ b/plugins/ladspa_effect/calf/src/modules_dsp.cpp @@ -1729,8 +1729,8 @@ int gain_reduction_audio_module::get_changed_offsets(int generation, int &subind /// of different chained filters. /////////////////////////////////////////////////////////////////////////////////////////////// -template -equalizerNband_audio_module::equalizerNband_audio_module() +template +equalizerNband_audio_module::equalizerNband_audio_module() { is_active = false; srate = 0; @@ -1739,16 +1739,16 @@ equalizerNband_audio_module::equalizerNband_audio_module() meter_inL = meter_inR = meter_outL = meter_outR = 0.f; } -template -void equalizerNband_audio_module::activate() +template +void equalizerNband_audio_module::activate() { is_active = true; // set all filters params_changed(); } -template -void equalizerNband_audio_module::deactivate() +template +void equalizerNband_audio_module::deactivate() { is_active = false; } @@ -1761,26 +1761,31 @@ static inline void copy_lphp(biquad_d2 filters[3][2]) filters[i][j].copy_coeffs(filters[0][0]); } - -template -void equalizerNband_audio_module::params_changed() +template +void equalizerNband_audio_module::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]; @@ -1813,28 +1818,53 @@ void equalizerNband_audio_module::params_changed() } } -static void process_hplp(float &procL, float &procR, dsp::biquad_d2 filter[3][2], CalfEqMode mode) +template +inline void equalizerNband_audio_module::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 -uint32_t equalizerNband_audio_module::process(uint32_t offset, uint32_t numsamples, uint32_t inputs_mask, uint32_t outputs_mask) +template +uint32_t equalizerNband_audio_module::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; @@ -1858,8 +1888,6 @@ uint32_t equalizerNband_audio_module::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) { @@ -1876,12 +1904,7 @@ uint32_t equalizerNband_audio_module::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); @@ -1964,8 +1987,8 @@ uint32_t equalizerNband_audio_module::process(uint32_t offset, uint32 #undef SET_IF_CONNECTED -template -bool equalizerNband_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context) +template +bool equalizerNband_audio_module::get_graph(int index, int subindex, float *data, int points, cairo_iface *context) { if (!is_active) return false; @@ -1976,8 +1999,8 @@ bool equalizerNband_audio_module::get_graph(int index, int subindex, return false; } -template -bool equalizerNband_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context) +template +bool equalizerNband_audio_module::get_gridline(int index, int subindex, float &pos, bool &vertical, std::string &legend, cairo_iface *context) { if (!is_active) { return false; @@ -1986,8 +2009,8 @@ bool equalizerNband_audio_module::get_gridline(int index, int subinde } } -template -int equalizerNband_audio_module::get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline) +template +int equalizerNband_audio_module::get_changed_offsets(int index, int generation, int &subindex_graph, int &subindex_dot, int &subindex_gridline) { if (!is_active) { return false; @@ -2035,12 +2058,15 @@ static inline float adjusted_lphp_gain(float **params, int param_active, int par return 1; } -template -float equalizerNband_audio_module::freq_gain(int index, double freq, uint32_t sr) +template +float equalizerNband_audio_module::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++) @@ -2048,105 +2074,202 @@ float equalizerNband_audio_module::freq_gain(int index, double freq, return ret; } -template class equalizerNband_audio_module; -template class equalizerNband_audio_module; +template class equalizerNband_audio_module; +template class equalizerNband_audio_module; +template class equalizerNband_audio_module; -/// Equalizer 5 Band by Markus Schmidt +/// 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; + return true; +} + +/// Pulsator by Markus Schmidt /// -/// This module is based on Krzysztof's filters. It provides a couple -/// of different chained filters. +/// This module provides a couple +/// of different LFO's for modulating the level of a signal. /////////////////////////////////////////////////////////////////////////////////////////////// -equalizer5band_audio_module::equalizer5band_audio_module() +pulsator_audio_module::pulsator_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; +// 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 equalizer5band_audio_module::activate() +void pulsator_audio_module::activate() { is_active = true; - // set all filters + lfoL.activate(); + lfoR.activate(); params_changed(); } -void equalizer5band_audio_module::deactivate() +void pulsator_audio_module::deactivate() { is_active = false; + lfoL.deactivate(); + lfoR.deactivate(); } -void equalizer5band_audio_module::params_changed() +void pulsator_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]; - } + 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 equalizer5band_audio_module::set_sample_rate(uint32_t sr) +void pulsator_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) +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; - numsamples += offset; + uint32_t samples = numsamples + offset; if(bypass) { // everything bypassed - while(offset < numsamples) { + while(offset < samples) { 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; + 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_in -= std::min(clip_in, numsamples); - clip_out -= std::min(clip_out, numsamples); - meter_in = 0.f; - meter_out = 0.f; + 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) { + while(offset < samples) { // cycle through samples float outL = 0.f; float outR = 0.f; @@ -2156,156 +2279,130 @@ uint32_t equalizer5band_audio_module::process(uint32_t offset, uint32_t numsampl 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; - // 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); - } + procL *= (lfoL.get_value() * 0.5 + *params[param_amount] / 2); + procR *= (lfoR.get_value() * 0.5 + *params[param_amount] / 2); - outL = procL * *params[param_level_out]; - outR = procR * *params[param_level_out]; + 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 - 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(inL > 1.f) { + clip_inL = srate >> 3; } - if(maxOut > 1.f) { - clip_out = 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(maxIn > meter_in) { - meter_in = maxIn; + if(inL > meter_inL) { + meter_inL = inL; } - if(maxOut > meter_out) { - meter_out = maxOut; + 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 - // 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_inL] != NULL) { + *params[param_clip_inL] = clip_inL; } - if(params[param_clip_out] != NULL) { - *params[param_clip_out] = clip_out; + 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_in] != NULL) { - *params[param_meter_in] = meter_in; + if(params[param_meter_inL] != NULL) { + *params[param_meter_inL] = meter_inL; } - if(params[param_meter_out] != NULL) { - *params[param_meter_out] = meter_out; + 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 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) +bool pulsator_audio_module::get_graph(int index, int subindex, float *data, int points, 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 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); } - else { - subindex_graph = 0; - subindex_dot = subindex_gridline = generation ? INT_MAX : 0; + if(subindex == 1) { + context->set_source_rgba(0.35, 0.4, 0.2, 0.5); + return lfoR.get_graph(data, points, context); } - if (generation == last_calculated_generation) - subindex_graph = INT_MAX; - return last_generation; + } + 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; }