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

pong~

Variable range signal folding

Description

pong~ either folds or wraps its input within the range of a low value and a high value. The optional arguments are <mode> <lo val> <hi val>. mode 0 is fold, mode 1 is wrap. The default mode is fold. The default range is zero to one. If <hi val> is greater than <lo val>, their behavior is swapped. All inlets accept both signals and floats. The mode message may be used to switch between fold and wrap mode. It is useful for performing modulo arithmetic, as well as foldover or wraparound distortion.

Arguments

Name Type Opt Description
folding-mode-flag (0 or 1) int opt An optional argument is used to set the mode of the pong~ A 0 sets signal folding (the default), and a 1 sets signal wrapping (see the mode message).
low/high-values float opt When used with the optional mode argument, the low and high range values for the pong~ objects can be specified by two additional float arguments. If only one argument is given following the mode argument (e.g., pong~ 0 .1), it specifies the low range value of the pong~ object above which folding occurs, and the high range value is set to 1.0 (the default). If two arguments are present, the first argument specifies the low range value and the second argument specifies the high range value.

Messages

float input [float]
In left inlet: All incoming signal or float values which exceed the high or low value ranges specified by arguments to the pong~ object are either folded back into this range (i.e., values greater than one are reduced by one plus the amount that they exceed one, and negative values are handled similarly) or wrapped (i.e., values greater than one are reduced by two, and negative values are increased by two), according to the mode of the pong~ object (see the mode message).

In center or right inlet: The pong~ objects accepts low and high range values for the range outside of which folding occurs. If the pong~ object has either one or no arguments, pong~ will have two inlets. The right inlet is used to set the high range value above which signal folding occurs, the low range value is assumed to be zero.

If the pong~ object has two arguments, the object has three inlets. The center inlet specifies the low value range below which folding occurs, and the right inlet specifies the high range limit. The default object has no arguments, and the right inlet specifies the upper value.

If the current low range value is greater than the high range value, their behavior is swapped.
mode folding-mode-flag (0 or 1) [int]
The word mode, followed by a zero or one, sets the folding mode of the pong~ object.

pong 0 sets the pong~ object to signal folding. Values greater than one are reduced by one plus the amount that they exceed one, and negative values are handled similarly. This is the default mode of the object.

pong 1 sets the pong~ object to signal wrapping. Values greater than one are reduced by two, and negative values are increased by two.
signal In left inlet: All incoming signal or float values which exceed the high or low value ranges specified by arguments to the pong~ object are either folded back into this range (i.e., values greater than one are reduced by one plus the amount that they exceed one, and negative values are handled similarly) or wrapped (i.e., values greater than one are reduced by two, and negative values are increased by two), according to the mode of the pong~ object (see the mode message).

In center or right inlet: The pong~ objects accepts low and high range values for the range outside of which folding occurs. If the pong~ object has either one or no arguments, pong~ will have two inlets. The right inlet is used to set the high range value above which signal folding occurs, the low range value is assumed to be zero.

If the pong~ object has two arguments, the object has three inlets. The center inlet specifies the low value range below which folding occurs, and the right inlet specifies the high range limit. The default object has no arguments, and the right inlet specifies the upper value.

If the current low range value is greater than the high range value, their behavior is swapped.

Information for box attributes common to all objects

Output

signal: The folded signal or float value.

Examples

pong~ distorts a signal by folding it or wrapping it around an upper and lower threshold level

See Also

Name Description
phasewrap~ Wrap a signal between π and -π