The AdEnv has the Trigger() method that starts the envelope (A = attack). Then the rest of the process() is handled by the set time(s).
That means you must know beforehand how long the note is. There is no TriggerOff() so the envelope enters Release ®.
I’d like an ADSR that I can control like how I control a note on a keyboard. Keypress = Trigger(), then I lift my finder and send a TriggerOff() so the note enters the Release phase.
Does this makes sense or have I misunderstood something?
I looked before at the Adsr class, but didn’t read it carefully enough. The Adsr.Process() method has a boolean argument that is the gate!
float Adsr::Process (bool gate)
Processes one sample through the filter and returns one sample.
Parameters
gate - trigger the envelope, hold it to sustain
So I have been using the ADSR on a guitar effect to smoothly ramp a pitch change and it works pretty well, but sometimes if I strum a chord before the ADSR completes, it triggers the change quickly and sounds a little glitchy. I am using the gate argument as it’s used in the ADSR example patch, but I am not sure I fully understand how it works. Were you able to get it working to your satisfaction @StaffanMelin? If so, any tips or guidance?
I got it to work as I wanted, but I don’t know if it will be of use for you as I used it to control oscillators. But I’ll give you a description anyway, maybe it might help!
OK, so I run a bunch of oscillators. Two of them use the Adsr class. That means I don’t Trigger() their envelopes when I start a new note like I do with the ones that use the AdEnv class.
@bretvh
This is the classic polysynth conundrum - how do you decide if it’s a new note played or someone extending an existing note. One technique I do sometimes is to leave the ADSR running in its decay mode but also trigger another ADSR from the start of the attack mode. Give it a try - it may solve your glitching … or maybe not