Digital Sound & Music: Concepts, Applications, & Science, Chapter 6, last updated 6/25/2013
the value at inlet 1 ($f1) is greater than 0 (as is the case for 1 to 127), and if so it outputs the
value 1. Otherwise, (if the inlet value is less than or equal to 0) it outputs 0. Since there are no
negative velocity values, we’ve just lumped them into the release outcome to cover our bases.
Now our input value results in a 1 or a 0 relating to a start or release envelope trigger.
As is often the case, it just so happens that MAX has a built in adsr~ object that generates
a standard ADSR envelope. We opted to create our own custom ADSR subpatcher. However,
its purpose and inlets/outlets are essentially identical, and it’s meant to be easily interchangeable
with the adsr~ object. You can find out more about our custom ADSR subpatcher and the
reason for its existence in the MAX Demo “ADSR Envelopes” back in section 220.127.116.11.1. For the
moment, we’ll refer to it as the standard adsr~ object.
Now, it just so happens that the adsr~ object’s first inlet triggers the envelope start when
it sees any non-zero number, and it triggers the release when it receives a 0. Our input is thus
already primed to be plugged straight into this object. It may also seem that our conditioning is
now somewhat moot, since any typical velocity value, being a positive number, triggers the
envelope start of the adsr~ object just as well as the number 1. It is however still important to
consider that perhaps the user may (for creative reasons) connect a different type of control value
to the envelope trigger input, other than note velocity. The conditioning if…then object thereby
ensures a more widely successful operation with potentially unexpected input formats.
The adsr~ object also takes four other values as input. These are, as you might imagine,
the attack time, decay time, sustain value, and release time. For simple controls, we’ve provided
the user with four sliders to manipulate these parameters. In between the sliders and the adsr~
inlets, we need to condition the slider values to relate to usable ADSR values. The subpatcher
adjustEnvelope does just that, and its contents can be seen in Figure 6.53. The four slider values
(default 0 to 127) are converted to time values of appropriate scale, and in the case of sustain a
factor ranging from 0.0 to 1.0. The expSlider subpatchers as seen in earlier MAX demos give
the sliders an exponential curve, allowing for greater precision at lower values.