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

change

Filter out repetitions of a number

Description

change will output a given number only if it is different from the stored number and will reset the stored number to that differing input number. Different modes of operation also allow change to react to values only if they are greater-than or less-than the stored value.

Arguments

Name Type Opt Description
initial-comparison-value int or float opt Initial value for comparison to incoming numbers. If there is no argument, the initial value is 0.
mode symbol opt A second argument may be + or -, causing change to behave as if it had received a mode + or mode - message. Subsequent mode messages can change this behavior.

Messages

int input [int]
The number is sent out the outlet only if it is different from the currently stored value. Replaces the stored value.
float input [float]
The number is sent out the outlet only if it is different from the currently stored value. Replaces the stored value.
mode behavioral-flag (+ or -) [symbol]
The word mode, followed by a +, causes change to send a 1 out its left outlet if the received number is greater than the previously received number. In this mode, change does nothing with any other input. The word mode, followed by a -, causes change to send out a -1 if the received number is less than the previously received number. In this mode, change does nothing with any other input. The word mode by itself returns change to its default mode of sending out received values that differ from the previously received input.
set comparison-number [list]
The word set, followed by a number, replaces the stored value without triggering output.

Information for box attributes common to all objects

Output

int: Out left outlet: The number received in the inlet is sent out only if it is different from the stored value.

Out middle outlet: If the stored value is 0 and the input is not 0, 1 is sent out; otherwise nothing is sent out.

Out right outlet: If the stored value is not 0 and the input is 0, 1 is sent out; otherwise nothing is sent out.

Examples

Filter out undesirable repetitions

See Also

Name Description
peak If a number is greater than previous numbers, output it
togedge Report zero/non-zero transitions
trough If a number is less than previous numbers, output it
Max Basic Tutorial 15: Abstractions Max Basic Tutorial 15: Abstractions