diff --git a/Source/Control/adenv.cpp b/Source/Control/adenv.cpp index 4e9568b7..f062ece7 100644 --- a/Source/Control/adenv.cpp +++ b/Source/Control/adenv.cpp @@ -75,7 +75,7 @@ float AdEnv::Process() current_segment_ = ADENV_SEG_ATTACK; phase_ = 0; curve_x_ = 0.0f; - retrig_val_ = output_; + retrig_val_ = hard_trigger_ ? 0.0 : output_; } time_samps = (uint32_t)(segment_time_[current_segment_] * sample_rate_); diff --git a/Source/Control/adenv.h b/Source/Control/adenv.h index fb115ae6..9020c110 100644 --- a/Source/Control/adenv.h +++ b/Source/Control/adenv.h @@ -60,8 +60,19 @@ class AdEnv */ float Process(); - /** Starts or retriggers the envelope.*/ - inline void Trigger() { trigger_ = 1; } + /** Starts or retriggers the envelope. Default is a non-hard retrigger.*/ + inline void Trigger() + { + trigger_ = true; + hard_trigger_ = false; + } + /** Starts or retriggers the envelope. If hard is true the envelope re-starts + from 0, if hard is false it starts from the current envelope value. */ + inline void Trigger(bool hard) + { + trigger_ = true; + hard_trigger_ = hard; + } /** Sets the length of time (in seconds) for a specific segment. */ inline void SetTime(uint8_t seg, float time) { segment_time_[seg] = time; } /** Sets the amount of curve applied. A positve value will create a log @@ -92,7 +103,7 @@ class AdEnv float sample_rate_, min_, max_, output_, curve_scalar_; float c_inc_, curve_x_, retrig_val_; uint32_t phase_; - uint8_t trigger_; + uint8_t trigger_, hard_trigger_; }; } // namespace daisysp