Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Source/Control/adenv.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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_);
Expand Down
17 changes: 14 additions & 3 deletions Source/Control/adenv.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down