A newer version of Max is available. Click here to access the latest version of this document.

sah~

Sample and hold

Description

sah~ accepts two signals. The left signal is the "input" and the right signal is the "control". When the control makes a transition from being at or below the trigger value to being above the trigger value, the input is sampled. The sampled value is output until another control transition occurs, at which point the input is sampled again. The default threshold value is 0, but can be specified via a float in the left inlet or as an argument to sah~.

Arguments

Name Type Opt Description
initial-trigger-value int or float opt Sets the initial trigger value. The default is 0.

Messages

float trigger-value [float]
In left inlet: Sets the trigger value.
signal In left inlet: A signal to be sampled. When the control signal (in the right inlet) goes from being at or below the current trigger value to being above the trigger value, the signal in the left inlet is sampled and its value is sent out as a constant signal value.

In right inlet: The control signal. In order to cause a change in the output of sah~, the control signal must go from being at or below the trigger value to above the trigger value. When this transition occurs, the signal in the left inlet is sampled and becomes the new output signal value.

Information for box attributes common to all objects

Output

signal: When the control signal received in the right inlet goes from being at or below the trigger value to being above the trigger value, the output signal changes to the current value of the signal received in the left inlet. This signal value is sent out until the next time the trigger value is exceeded by the control signal.

Examples

Hold the signal value constant until the next trigger

See Also

Name Description
phasor~ Sawtooth wave generator
train~ Pulse train generator