Envelope Control
Description
An envelope is the modification of a controller over time. It can be created statically as a controller itself (Lisp), or applied dynamically at any time (Max).
Syntax and Default Values
An envelope can be applied using the following Lisp, mlys (Max) or mlys.lua syntax:
(make-controller 'envelope dimension
(list (list t0 value value ... )
(list t1 value value ... )
(list t2 value value ... )
... ) )
// Max message:
{applyenvelope MyCtrl t1 value value ... t2 value value ...}
//example: suppose MyCtrl is a dynamic controller (dim=1) with current value -1:
{applyenvelope MyCtrl 0.5 2 1 0}
//MyCtrl will go from -1 to 2 in 0.5 sec, then from 2 to 0 in 1 sec.
For each time point, there is as many values as the controller's dimension.
NB: t0 is the moment the envelope is applied and t1, t2 etc. are relative to t0. The current value of the controller is taken into account to reach (t1, value).
local V = { t1 value value ... t2 value value ... }
apply_envelope(MyCtrl, V)
-- example: suppose MyCtrl is a dynamic controller (dim=1) with current value -1:
local V = {0.5 2 1 0}
apply_envelope(MyCtrl, V)
-- MyCtrl will go from -1 to 2 in 0.5 sec, then from 2 to 0 in 1 sec.
NB: t0 is the moment the envelope is applied and t1, t2 etc. are relative to t0. The current value of the controller is taken into account to reach (t1, value).
Parameters
An envelope takes the following arguments:
- controller: for Lua and Max message only (for Lisp, the controller is the envelope.)
- dimension: number of values controlled by the envelope (Lisp only)
- t0, t1, t2...: the time points of the breakpoints. In Max, t0 is the moment the envelope is applied, and subsequent t1 etc. are relative to t0.
- value: the value(s) output by the controller at the given time.
The number of values for each time time is equal to the controller's dimension.
Discussion
An envelope follows a predetermined course from value to value in a given amount of time. Values which fall between those which are specified in the list are interpolated. Thus if we specify that at time zero, the value output by the controller will be one, and at time one, the value will be zero, the value at time .5 will be .5 and the value at time .4 will be .6, etc. Note that time1, time2, time3, etc. are in absolute synthesis time and not relative time. If, for example, one wants to set a breakpoint every second for five seconds, the times are 0 1 2 3 4 5, and not 1 1 1 1 1.
Here is an example showing a typical ADSR envelope over 2 seconds of time (its graph is shown at the top of this page):
(make-controller 'envelope 1
'( (0 0.0)
(0.2 1.0)
(0.4 0.7)
(1.2 0.7)
(2 0) ) )