Forum Rule: Always post complete source code & details to reproduce any issue!
Results 1 to 3 of 3

Thread: how to know when envelope is done?

  1. #1

    how to know when envelope is done?

    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-

  2. #2
    Senior Member
    Join Date
    May 2015
    Location
    San Francisco
    Posts
    225
    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...
    Last edited by blackketter; 04-03-2016 at 07:45 PM.

  3. #3
    Member
    Join Date
    Jan 2015
    Location
    Toms River, NJ USA
    Posts
    37
    Quote Originally Posted by blackketter View Post
    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?

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •