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

count~

Signal sample counter

Description

count~ will output a signal increasing by 1 each sample when it receives a bang or a number in its inlet (count~ can be used to do sample playback using index~).

Arguments

Name Type Opt Description
minimum-count maximum-count on/off-flag and autoreset-state (ints) list opt The first argument sets initial minimum value for the counter. The default value is 0. The second argument sets the initial maximum value for the counter, the default value is 0, which means there is no maximum value. The third argument specifies whether the count~ object is off (0) or on (1) initially. The fourth argument sets the autoreset state of the object (see the autoreset message above).

Messages

bang If the audio is on, the output signal begins counting from its current minimum value, increasing by one each sample. If the signal is already currently counting, it resets to the minimum value and continues upward.
int minimum-count [int]
In left inlet: Sets a new current minimum value, and the output signal begins counting upward from this value.
  (inlet1) maximum-count [int]
In right inlet: Sets the count limit, which is never actually reached. When the count reaches this value, it starts over at the minimum value. A value of 0 (the default) eliminates the maximum, and the count continues increasing without resetting.
float minimum and maximum-count [float]
In any inlet: Converted to int.
list minimum-count maximum-count on/off-flag and autoreset-state (ints) [list]
In left inlet: A list consisting of four numbers can be used to specify the behavior of the count~ object. The first and second numbers specify the minimum and maximum values for the count, the third number specifies whether the count~ object is off (0) or on (1) initially, and the fourth number sets the autoreset flag (see the autoreset message).
min minimum-count [int]
In left inlet: The word min, followed by a number, sets the count minimum on next loop without immediately affecting output.
set minimum-count [list]
In left inlet: The word set, followed by a number, sets the count minimum on the next loop without immediately affecting output.
signal A non-zero signal value will cause the count~ object's output signal to begin counting. A zero signal value will stop it.
stop In left inlet: Causes count~ to output a signal with its current minimum value.

Attributes

Name Type g/s Description
autoreset int When enabled, resets the object's counter to its minimum value when audio is turned on.

Information for box attributes common to all objects

Output

signal: When the audio is first turned on, count~ always sends out its current minimum value. When a bang or int is received, the count begins increasing from the current minimum value.

Examples

Send out a running count of the passing samples beginning at a given point

See Also

Name Description
index~ Sample playback without interpolation
mstosamps~ Convert milliseconds to samples
sampstoms~ Convert time from samples to milliseconds
+=~ Signal accumulator
MSP Tutorial 13: Recording and Playback MSP Tutorial 13: Recording and Playback