adsr~ Reference

ADSR envelope generator

adsr~

Description

The adsr~ object is an Attack-Decay-Sustain-Release signal controllable by signals. In some situations, a combination of the function and line~ objects may be a useful alternative.

Examples

Use adsr~ to manage the polyphony and muting for a sampler or synthesizer patch internal to a poly~ object

Discussion

Any non-zero value in the trigger inlet will trigger an envelope with that amplitude. Like an adsr~ triggered by an input float, a zero value represents "note-off" and will begin the release stage. unlike the event-trigger model, a signal-triggered adsr~ must receive a zero before it will retrigger.

The adsr~ object uses the Max time format syntax; envelope times can be specified in either fixed or tempo-relative formats.

Arguments

attack [float]

Optional

The initial attack time

decay [float]

Optional

The initial decay time

sustain [float]

Optional

The initial sustain level

release [float]

Optional

The initial release time

Attributes

attack [Time Value]

Sets the attack of the ADSR-envelope in milliseconds.

decay [Time Value]

Sets the decay of the ADSR-envelope in milliseconds.

legato [int]

Given as input, the word legato, followed by a 0 or a non-zero number, disables or enables legato mode. If legato mode is enabled, the envelope will not drop to zero in the event of a retrigger while the envelope is active - instead, the envelope ramps to the new amplitude over the attack period.

maxsustain [float]

Given as input, the word maxsustain, followed by a float, sets the maximum amount of time that the envelope will remain in the sustain stage. A negative number sets no maximum; the envelope will remain forever in the sustain stage until a note-off is received. To create a simple three-stage sustainless envelope (an ADR), you can use the message maxsustain 0.0.

release [Time Value]

Sets the release of the ADSR-envelope in milliseconds.

retrigger [float]

Given as input, the word retrigger, followed by a float, sets the amount of time taken to ramp down to zero in the event of a retrigger while the envelope is active (the default is 5 milliseconds). This ramping prevents clicking.

sustain [float]

Sets the sustain of the ADSR-envelope, as a factor of the amplitude. For example, a value of 0.5 means the sustain level will be half of the amplitude height.

triggermode [int]

The triggermode attributes determines whether the envelope waits for a zero to complete the release phase or plays to the end once triggered. Possible values:

0 = 'ADSR' ( Normal ADSR triggering )
In ADSR mode, the envelope starts when a non-zero signal or float is received and begins the release phase when a zero is reeived.

1 = 'Play to End' ( Play to End )
In Play to End mode, the envelope starts and plays the attack, decay and release segments, ignoring further input until the envelope completes.

Common Box Attributes

annotation [symbol]

Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.

background [int] (default: 0)

Adds or removes the object from the patcher's background layer. background 1 adds the object to the background layer, background 0 removes it. Objects in the background layer are shown behind all objects in the default foreground layer.

color [4 floats]

Sets the color for the object box outline.

fontface [int]

Sets the type style used by the object. The options are:

plain
bold
italic
bold italic Possible values:

0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'

fontname [symbol]

Sets the object's font.

fontsize [float]

Sets the object's font size (in points). Possible values:

'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'

hidden [int] (default: 0)

Toggles whether an object is hidden when the patcher is locked.

hint [symbol]

Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.

ignoreclick [int] (default: 0)

Toggles whether an object ignores mouse clicks in a locked patcher.

jspainterfile [symbol]

JS Painter File

patching_rect [4 floats] (default: 0. 0. 100. 0.)

Sets the position and size of the object in the patcher window.

position [2 floats]

g/s(set)

Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.

presentation [int] (default: 0)

Sets whether an object belongs to the patcher's presentation.

presentation_rect [4 floats] (default: 0. 0. 0. 0.)

Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.

rect [4 floats]

g/s(set)

Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).

size [2 floats]

g/s(set)

Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.

textcolor [4 floats]

Sets the color for the object's text in RGBA format.

textjustification [int]

Sets the justification for the object's text. Possible values:

0 = 'left'
1 = 'center'
2 = 'right'

varname [symbol]

Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.

Messages

int

Arguments

trigger/ADSR-parameters [int]
Converted to float

float

Arguments

trigger/ADSR-parameters [float]
In left inlet: A non-zero number triggers an envelope with the given amplitude. The envelope will sustain until a zero is input to trigger the release stage, or until another non-zero int retriggers the envelope.

In second inlet: sets the attack time in milliseconds.

In third inlet: sets the decay time in milliseconds.

In fourth inlet: sets the envelope's sustain level, as a factor of the amplitude. For example, a value of 2 means the sustain level will be twice the value of the amplitude height.

In fifth inlet: sets the envelope's release time, in milliseconds.

list

Arguments

attack [float]
decay [float]
sustain [float]
release [float]
A list of four numbers will set the attack, decay, sustain and release values.

anything

Arguments

attack [float]
decay [float]
sustain [float]
release [float]
In left inlet: Performs the same function as list.

Any other inlet: A list may be used to specify time in one of the Max time formats.

signal

In left inlet: A non-zero value triggers an envelope with that value as its amplitude. After the envelope starts, a zero signal value will begin the release phase of the envelope. If triggermode is enabled the envelope is completed fully even if the signal is zero.

In second inlet: sets the attack time in milliseconds.

In third inlet: sets the decay time in milliseconds.

In fourth inlet: sets the envelope's sustain level, as a factor of the amplitude. For example, a value of 0.5 means the sustain level will be half of the amplitude.

In right inlet: sets the release time in milliseconds.

Output

message

The right outlet sends mute messages suitable for managing internal poly~ instance muting with the thispoly~ object.

message

The fourth outlet responds to query messages for the various attributes (i.e. getattack).

signal

Left outlet: the envelope.

Middle outlet: signals the beginning of an envelope by sending 1 when in the attack, decay, or sustain stages and 0 otherwise (release, retrigger, or inactive). You can use this outlet in conjunction with the sah~ object to synchronize pitch (or other information) with the beginning of an envelope with sample accuracy.

See Also

Name Description
function Breakpoint function editor
line~ Linear signal ramp generator
techno~ Signal-driven step sequencer
transport Control a clock
zigzag~ Linked list function editor