Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add hard retrigger to adenv #202

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
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