PDA

View Full Version : how to know when envelope is done?



mykle
04-02-2016, 11:29 PM
Hello,

A quick question about the envelope object: is there a way to fire a callback when the envelope is completely closed? Working on a polyphonic kbd system, where I want to work with a pool of voices, so I want to free up a voice for reuse when it's done playing. What's the best way of knowing that? I don't see a method for it on the object itself. I guess I could set a timer when I call noteOff(), but there must already be some timer in play ...

-m-

blackketter
04-03-2016, 08:42 PM
I submitted a patch: https://github.com/PaulStoffregen/Audio/pull/175 to provide access to the envelope state in the Audio library. It's not a callback, but you can poll in your loop() on where the envelope is in its state.

Call envelope.getState() and check to see if it returns one of STATE_IDLE, STATE_DELAY, STATE_ATTACK, STATE_HOLD, STATE_DECAY, STATE_SUSTAIN, STATE_RELEASE...

dslocum
03-22-2020, 03:36 PM
I submitted a patch: https://github.com/PaulStoffregen/Audio/pull/175 to provide access to the envelope state in the Audio library. It's not a callback, but you can poll in your loop() on where the envelope is in its state.

Call envelope.getState() and check to see if it returns one of STATE_IDLE, STATE_DELAY, STATE_ATTACK, STATE_HOLD, STATE_DECAY, STATE_SUSTAIN, STATE_RELEASE...

I'm still learning this SW environment....

How can I get a version with this new envelope.getState() method please?