Linear AD Envelope Generator

    Apr 25 2013 | 4:20 pm
    Hi guys, I'm trying to hack together a simple 2 step Envelope Generator (AD) from the 7-step envelope generator example patch. I'm trying to make it react exactly like the ADSR~ object with Sustain and Release set to 0.
    Unfortunately I can't seem to make the envelope retrigger without first sending a zero value. Also I can't seem to make it retrigger until the envelope has finished.
    Is there a way to do this simply? Possibly more simply than the 7-stage envelope generator method, I feel it's maybe overkill for a 2 step envelope.
    Anyway, here's what I have so far.

    • Apr 25 2013 | 5:43 pm
      without gen~: you can use e.g. function with line~  or curve~...
    • Apr 25 2013 | 9:21 pm
      Thanks for your reply. I know several ways I can do it in MSP and this is a good one, but the point was to achieve it in gen so I can make a sample accurate envelope generator.
    • Apr 27 2013 | 10:48 am
      like this?
    • Apr 27 2013 | 3:29 pm
      Aha, thanks, I guess I can use a pulse train to get it out of the max and into MSP too. Now I guess my only problem is how to get the envelope to reset to zero quickly if it is retriggered while it's still ramping. Any ideas? I'm gonna have a rummage.
    • May 20 2013 | 7:07 am
      Here's a way of doing it. This is not as flexible as the seven stage envelope in terms of number of stages, but (I think) it has the same retriggering behavior as adsr~. I've also added the legato mode, which I find more useful for monosynths.
      Also, you can prematurely short-circuit the attack (i.e. if you release the envelope before it's reached the decay phase, it will decay from there)
      I highly recommend checking out some of the threads on envelopes on kvraudio. I've found them greatly helpful.
      FWIW, envelopes can be surprisingly hard to write, especially with features such as those found in adsr~. I'm working on an analog style ADSR now that has a retriggering model similar to the Moog mini. (where rapid retriggering of notes would cause an increase in volume)
      For no-frill two-stage envelopes you can look at models that are much simpler: a pulse-wave generator (I'd look at sig~ 1 into +=~ into
    • Jun 29 2016 | 5:54 am
      @Peter's Gen~ patch:
      Is it possible to change the attack/decay time WHILE the ramp is in progress? Help appreciated!
    • Jun 29 2016 | 6:03 am
      Sure! I'd encourage you to check out the Bp.AHD and Bp.AD2 in BEAP for some examples. (Especially the latter one)
    • Jun 30 2016 | 9:26 am
      Thanks a lot, that helped clear a lot of doubts. Boy was I wrong about making Envelope Generators :3 :3 :3 :3 :3
    • Jul 13 2016 | 8:10 am
      Here is a gen~ implementation of an ADSR envelope, first published in May 2014, with full documentation. It uses the same envelope-phase calculation method as the 7-stage envelope, and is openly expansible to any number of stages
    • Jul 13 2016 | 1:01 pm
      Ernest, have you considered adding a Delay stage (for a DADSR)? Might be handy for LFOs, and a fun one to figure out.
    • Jul 13 2016 | 4:44 pm
      It really isn't very difficult to add a delay stage in gen~. One simply puts a delay object on the gate-on input, with time set in sample periods.
    • Jul 13 2016 | 5:31 pm
      I think it's slightly different, since the attack of the envelope is delayed but the release is not. Also, the wait period might interact with the release in a monophonic setting. For controlling the amplitude of a pitch LFO, a hard reset to 0 would probably be fine, but this might not be ideal for an amplitude LFO's envelope. My guess is that you could probably just model it as an additional stage in the envelope which has 0 amplitude.
    • Jul 13 2016 | 7:15 pm
      My design does both of those things already. Delaying the gate-on signal would not affect the gate-off signal, and it already has a pre-attack phase that only happens on gate-off events while the envelope is on, to prevent clicks.
    • Jul 13 2016 | 7:59 pm
      if i may ask: why is it a problem that you are required to send 0 before the list?
      anyhow, if you dont need to modulate the envelope in realtime, you could use a buffer~ with the pregenerated envelope inside.
    • Jul 13 2016 | 9:08 pm
      @Ernest, I'm doing analog-style envelopes triggered at signal rate so gate-on and gate-off are usually in the same stream and then a separate stream containing triggers is used to indicate new envelopes. I took a look at it and the delay triggering at signal rate ended up being pretty easy to add to existing envelopes; the key is not using a delay to begin with.
      For anyone curious, here's an example of a signal rate triggered DADSR. It uses an asymmetrical rampsmooth~ (with arguments of 88200 1) in combination with a threshold so that it takes extra time to trigger the start (2 seconds), but the release is triggered immediately. This also allows it to be cancelled without being triggered.