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

setclock Reference

Create and control an alternative clock

setclock

Description

Allows the creation of alternatives to the standard millisecond clock. This includes several modes of timing that change timing activities. Each setclock is associated with a name (its first argument), and this name may be passed as the argument to a "clock" message to numerous objects that use timing in Max, such as metro, line, and pipe.

Examples

setclock becomes the clock for metro... setclock modifies the time for clocker

Arguments

name [symbol]

Obligatory. The first argument is the name of the setclock object, by which timing objects such as clocker, line, metro, pipe, and tempo can refer to the setclock. Those timing objects -- once they have received the message clock followed by the name of a setclock object -- use that setclock as their timing source instead of Max's regular millisecond clock. The setclock object need not be in the same patcher as the timing objects that refer to it. More than one setclock object may exist with the same name; setclock objects with the same name share the same clock time information. (Note: Different setclock objects that share the same name argument can have different mode arguments typed in, but they will in fact operate with the mode of whichever setclock was first loaded with that name. Thus, setclock objects with the same name but different modes may behave unpredictably, since the order in which they are loaded by Max is often unknown.)

The second (optional) argument describes the mode of clock operation this setclock object will have. The possible modes for the second argument are:

mode [symbol]

The word pass specifies passive mode. In this mode, the setclock object's current clock time is set by a number received in the left inlet, and associated timing objects will follow that clock time just as if it were a regularly progressing millisecond clock. If no second argument is present, the mode is pass by default.

The word add specifies additive mode. A number received in the left inlet is added to the current clock time to determine the new clock time.

The word mul specifies multiplicative mode. The number received in the left inlet is used as a factor by which all associated timing objects will modify their time settings. For example, a factor of 2.0 will cause all timing objects that are using the setclock as their clock source to double their time values (that is, to halve their speed). An alternative (and perhaps more truthful) way to conceptualize the behavior of mul mode is to think of the incoming float as a divisor by which setclock divides the speed at which its own clock time progresses. Thus, when it receives the number 2.0 it divides its own clock speed by 2.0, causing the objects which are following that clock to progress twice as slowly.

The word interp specifies interpolate mode. The number received in the left inlet is gradually added to the current time of setclock, over a time period determined by the amount of time elapsed since the previous number was received. During that time period, setclock linearly interpolates to set its clock to the intermediate values.

multiplier [float]

If the second argument is mul, an optional third argument specifies a multiplier for the time of all associated timing objects. If no third argument is present, the multiplier is 1.0 by default.

Attributes

Common Box Attributes

Messages

bang

In left inlet: Sends out the current time value, according to the setclock object's own clock. Timing objects such as clocker, line, metro, pipe, and tempo can use setclock as their clock source instead of Max's regular millisecond clock.

int

Arguments

timing [int]
In left inlet: The meaning of the number depends on the second typed-in argument, which identifies the setclock object's mode of operation. If the mode is pass [ive] (the default mode), the number sets an absolute clock time which timing objects may use by comparing it to their initial time value. If the mode is add [itive], the number is added to the setclock object's current clock time. If the mode is interp [olate], setclock will change its clock time incrementally by that amount, over a time period determined by the time elapsed since the previous number was received. (However, negative numbers cause an immediate decrease in the clock time.) If the mode is ext [ernal], the number is simply ignored. If the mode is mul [tiplicative], the number is used as a multiplier for associated timing objects. For instance the number 0.5 halves the rate of increase (speed) of the associated timing objects.

In right inlet: Sets the time interval, in milliseconds, at which the setclock will report its clock information to associated timing objects. The default is 5 milliseconds.

float

Arguments

timing [float]
Performs the same function as int.

  (inlet1)

Arguments

interval [int]
In right inlet: Sets the time update interval.

clock

Arguments

clock name [symbol]
The word clock, followed by a word, specifies the name of the name of the setclock object, by which timing objects such as clocker, line, metro, pipe, and tempo can refer to the setclock.

(mouse)

Double-clicking with the mouse will print status messages in the Max Console.

reset

Arguments

interval [float]
The word reset followed by a number of milliseconds sets the timing interval at which the object will report its clock information to associated timing objects. The information is reported whenever the next report is due according to the set interval.

set

Arguments

interval [float]
The word set followed by a number of milliseconds sets the timing interval at which the object will report its clock information to associated timing objects. The information is reported to those associated objects immediately.

Output

int

When bang is received in the left inlet, setclock sends its current time reading out the outlet.

See Also

Name Description
Timing and Sequencing Events Timing and Sequencing Events
clocker
metro
timer