mirror of
https://github.com/sjlongland/atinysynth.git
synced 2025-11-02 11:51:42 +10:00
adsr: Add state helper functions
Add helper functions that report back whether the ADSR generator is in a given state. Namely, if it is "waiting" for a trigger, or it is idle.
This commit is contained in:
parent
aeefd70fe3
commit
7039dd1307
16
adsr.h
16
adsr.h
@ -135,6 +135,22 @@ static inline uint8_t adsr_is_done(struct adsr_env_gen_t* const adsr) {
|
||||
return (adsr->state == ADSR_STATE_DONE);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Test to see if the ADSR is awaiting a trigger.
|
||||
*/
|
||||
static inline uint8_t adsr_is_waiting(struct adsr_env_gen_t* const adsr) {
|
||||
return ((adsr->next_event == UINT32_MAX)
|
||||
&& ((adsr->state == ADSR_STATE_DELAY_EXPIRE)
|
||||
|| (adsr->state == ADSR_STATE_SUSTAIN_EXPIRE)));
|
||||
}
|
||||
|
||||
/*!
|
||||
* Test to see if the ADSR is idle.
|
||||
*/
|
||||
static inline uint8_t adsr_is_idle(struct adsr_env_gen_t* const adsr) {
|
||||
return (adsr->state == ADSR_STATE_IDLE);
|
||||
}
|
||||
|
||||
/*!
|
||||
* Tell the ADSR to move onto the next state.
|
||||
*/
|
||||
|
||||
Loading…
Reference in New Issue
Block a user