The ParameterListener Object

The ParameterListener Object

The ParameterListener object listens for changes to the value of a named Parameter. When a change occurs, a user-specified function will be called. The object also provides methods for getting and setting the value of the observed Parameter.

ParameterListener Constructor

var pl = new ParameterListener(parameter_name, function);

The parameter_name argument is string specifying a Parameter in the patcher hierarchy of the js object running the script. Parameter names are global to a patcher hierarchy, so there's no need to know the Patcher or Maxobj for the Parameter.

The function argument specifes the function you want to execute. The function should have a single argument, which is a ParameterListenerData object.


function valuechanged(data) {
  post("parameter value changed: " + + "\n")
  post("new value: " + data.value + "\n")

l = new ParameterListener("myParameter", valuechanged)

For convenience, the ParameterListener object is a property of the ParameterListenerData argument to the function. To access the ParameterListener from within its function:


ParameterListener Properties

name [string]

The Parameter to observe.

silent [int]

Never execute the callback function in response to calling setvalue from this ParameterListener.

ParameterListener Methods


Report the value of the Parameter. List values are reported in a JS Array object.


Set the value of the Parameter.


Set the value of the Parameter, without executing the callback function (also see the silent property).


The ParameterListenerData object is the argument to your ParameterListener's function

ParameterListenerData Properties

listener [ParameterListener]


The ParameterListener which called the function.

name [string]


The name of the Parameter which changed.

value [value or Array]


The current value of the Parameter. List values are represented by a JS Array object.

See Also

Name Description
JavaScript Usage JavaScript Usage