diff --git a/plugins/ladspa_effect/calf/calf/metadata.h b/plugins/ladspa_effect/calf/calf/metadata.h index a92bb64f1..da99c7407 100644 --- a/plugins/ladspa_effect/calf/calf/metadata.h +++ b/plugins/ladspa_effect/calf/calf/metadata.h @@ -253,7 +253,7 @@ struct pulsator_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 }; + param_mode, param_freq, param_amount, param_offset, param_mono, param_reset, param_count }; PLUGIN_NAME_ID_LABEL("pulsator", "pulsator", "Pulsator") }; diff --git a/plugins/ladspa_effect/calf/calf/modules.h b/plugins/ladspa_effect/calf/calf/modules.h index d33fe9545..ee8906772 100644 --- a/plugins/ladspa_effect/calf/calf/modules.h +++ b/plugins/ladspa_effect/calf/calf/modules.h @@ -1103,6 +1103,7 @@ public: 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 set_phase(float ph); void activate(); void deactivate(); float get_value_from_phase(float ph, float off); @@ -1117,6 +1118,7 @@ private: float meter_inL, meter_inR, meter_outL, meter_outR; float offset_old; int mode_old; + bool clear_reset; lfo_audio_module lfoL, lfoR; public: float *ins[in_count]; @@ -1129,6 +1131,13 @@ public: void deactivate(); void params_changed(); void set_sample_rate(uint32_t sr); + void params_reset() + { + if (clear_reset) { + *params[param_reset] = 0.f; + clear_reset = false; + } + } 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); diff --git a/plugins/ladspa_effect/calf/src/modules.cpp b/plugins/ladspa_effect/calf/src/modules.cpp index d03999187..1c6a939ff 100644 --- a/plugins/ladspa_effect/calf/src/modules.cpp +++ b/plugins/ladspa_effect/calf/src/modules.cpp @@ -509,6 +509,7 @@ CALF_PORT_PROPS(pulsator) = { { 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" }, + { 0, 0, 1, 2, PF_BOOL | PF_CTL_BUTTON , NULL, "reset", "Reset" }, }; CALF_PLUGIN_INFO(pulsator) = { 0x8514, "Pulsator", "Calf Pulsator", "Markus Schmidt", calf_plugins::calf_copyright_info, "ModulationPlugin" }; diff --git a/plugins/ladspa_effect/calf/src/modules_dsp.cpp b/plugins/ladspa_effect/calf/src/modules_dsp.cpp index 3dbb6b0db..d30672ca3 100644 --- a/plugins/ladspa_effect/calf/src/modules_dsp.cpp +++ b/plugins/ladspa_effect/calf/src/modules_dsp.cpp @@ -2151,6 +2151,14 @@ void lfo_audio_module::advance(uint32_t count) phase = fmod(phase, 1.f); } +void lfo_audio_module::set_phase(float ph) +{ + //set the phase from outsinde + phase = fabs(ph); + 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 @@ -2225,6 +2233,12 @@ 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]); + clear_reset = false; + if (*params[param_reset] >= 0.5) { + clear_reset = true; + lfoL.set_phase(0.f); + lfoR.set_phase(0.f); + } } void pulsator_audio_module::set_sample_rate(uint32_t sr)