counter
Keep count based on bang messages
Description
Outputs the current count of bang message constrained to a specified range. Can be set to count up, down, or up-then-down.
Arguments
options[int]
optional
If there is only one argument, it sets an initial maximum count value for counter. If there are two arguments, the first number sets an initial minimum value, and the second number sets an initial maximum value. If there are three arguments, the first number specifies the direction of the count, the second number is the minimum, and the third number is the maximum. If there are no arguments, the direction is up, the minimum is 0, and the maximum is 2,147,483,647 (the largest possible 32-bit signed integer).
Attributes
carryflag[int]
Sets the type of data output from the third outlet (numbers or bangs).
Possible values:
0 = 'Numeric'
1 = 'Bang'
compatmode[int]
Provides compatibility when importing patches created with versions 3.x and earlier of Max. When "Ancient" is selected, sending an int to inlets 3 and 4 will change the min count instead of just resetting it temporarily (which causes the fourth inlet to behave exactly as thought the counter object).
Possible values:
0 = 'Current'
1 = 'Ancient'
Common Box Attributes
annotation[symbol]
Sets the text that will be displayed in the Clue window when the user moves the mouse over the object.
background[int]: 0
Adds or removes the object from the patcher's background layer.
adds the object to the background layer, removes it. Objects in the background layer are shown behind all objects in the default foreground layer.
color[4 floats]
Sets the color for the object box outline.
fontface[int]
Sets the type style used by the object. The options are:
plain
bold
italic
bold italic
Possible values:
0 = 'regular'
1 = 'bold'
2 = 'italic'
3 = 'bold italic'
fontname[symbol]
Sets the object's font.
fontsize[float]
Sets the object's font size (in points).
Possible values:
'8'
'9'
'10'
'11'
'12'
'13'
'14'
'16'
'18'
'20'
'24'
'30'
'36'
'48'
'64'
'72'
hint[symbol]
Sets the text that will be displayed in as a pop-up hint when the user moves the mouse over the object in a locked patcher.
ignoreclick[int]: 0
Toggles whether an object ignores mouse clicks in a locked patcher.
jspainterfile[symbol]
You can override the default appearance of a user interface object by assigning a JavaScript file with code for painting the object. The file must be in the search path.
patching_rect[4 floats]: 0. 0. 100. 0.
Sets the position and size of the object in the patcher window.
position[2 floats]
write-only
Sets the object's x and y position in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its size unchanged.
presentation[int]: 0
Sets whether an object belongs to the patcher's presentation.
presentation_rect[4 floats]: 0. 0. 0. 0.
Sets the x and y position and width and height of the object in the patcher's presentation, leaving its patching position unchanged.
rect[4 floats]
write-only
Sets the x and y position and width and height of the object in both patching and presentation modes (if the object belongs to its patcher's presentation).
size[2 floats]
write-only
Sets the object's width and height in both patching and presentation modes (if the object belongs to its patcher's presentation), leaving its position unchanged.
textcolor[4 floats]
Sets the color for the object's text in RGBA format.
textjustification[int]
Sets the justification for the object's text.
Possible values:
0 = 'left'
1 = 'center'
2 = 'right'
varname[symbol]
Sets the patcher's scripting name, which can be used to address the object by name in pattr, scripting messages to thispatcher, and the js object.
Messages
bang
In left inlet: Sends out the current count of the
In left-middle inlet: Changes the direction of the count.
In middle inlet: Resets the count to its specified minimum value, which will be sent out the next time a is received in the left inlet.
In right-middle inlet: Resets the count to its specified minimum value, and sends out that value immediately.
In right inlet: Resets the count to its specified maximum value, which is sent out immediately.
int
In left inlet: Same effect as
In left-middle inlet: Sets the direction of the count. causes counter to count up, causes it to count down, and causes it to count up and down.
In middle inlet: The number sets the counter to a new value, to be sent out the next time a is received in the left inlet. If the number is less than the current minimum value, the minimum will be reset to that number. If the number is greater than the current maximum value, the counter will be set to that number, but the maximum value actually remains the same and the minimum is set equal to the maximum.
In middle-right inlet: The number sets the counter to a new value and sends it out immediately. If the number is less than the current minimum value, the minimum will be reset to that number. If the number is greater than the current maximum value, the number is sent out, but the maximum value actually remains the same and the minimum is set equal to the maximum.
In right inlet: Resets the maximum value sent out by counter. If the number is less than the current minimum, the maximum is equal to the minimum. If the minimum is subsequently changed to a value below the maximum value you input, the counter objects retains the correct maximum value it received through this inlet. Unlike a message, an int in this inlet does not cause the counter object to output anything.
- input
[int]
float
In all other inlets: Converted to
.- input
[float]
carrybang
In left inlet: Causes counter to send a out the right-middle outlet when the count is going upward and reaches its maximum limit, and causes counter to send a out the left-middle outlet when the count is going downward and reaches its minimum limit. (By default, counter sends out the number in those situations, instead of .) The state of the message is saved along with the patcher it is used in.
carryint
In left inlet: Undoes the effect of a previously received
message. Resets the counter to send the numbers and out the left-middle and right-middle outlets (instead of ) to signal when the counter reaches and leaves its minimum and maximum values. The state of the message is saved along with the patcher it is used in.
dec
In left inlet: Decrements the counter (downward) and sends out the new value, regardless of the direction in which the object has been set to count ordinarily.
down
In left inlet: Sets the counter to count in a downward direction.
flags
The counter will output a 1 when it hits the maximum or else output a 0. If the first number is 1, counter will output a when it hits the maximum. If the second number is 0, an integer in inlets 3 and 4 will override the minimum count temporarily. If the second number is 1, an integer in inlets 3 and 4 will change the minimum count permanently.
message followed by two numbers will set the Underflow/Carry Mode and set the Minimum-Mode resetting capability. If the first number is 0,- carry-mode
[int]
- minimum-mode
[int]
goto
In left inlet: Same effect as
.- input
[int]
inc
In left inlet: Increments the counter (upward) and sends out the new value, regardless of the direction in which the object has been set to count ordinarily.
jam
In left inlet: The word
, followed by a number, sets the counter to that number and sends the number out immediately. If the number is outside the minimum and maximum count range, this message is ignored.- input
[int]
max
In left inlet: The word counter to that number. If the number is less than the current minimum value, the maximum is considered to be equal to the minimum, although the actual maximum value you set is stored inside the counter object.
followed by a number, resets the maximum value of- maximum
[int]
min
In left inlet: The word counter to that number, and causes the counter object to set itself to that number and output immediately. If the number is greater than the current maximum value, the minimum is set equal to the maximum.
followed by a number, resets the minimum value of- minimum
[int]
next
In left inlet: Same as
.
set
In left inlet: The word
, followed by a number, sets the counter to that number, which will be sent out the next time a is received in the left inlet.- input
[int]
setmin
In left inlet: The word counter object's minimum count without affecting its current count value or causing any output.
, followed by a number, sets the- minimum
[int]
state
The message counter object to report its current state to the Max Console.
will cause the
up
In left inlet: Sets the counter to count in an upward direction.
updown
In left inlet: Sets the counter object's direction so that it counts upward until it reaches the specified maximum, then counts down until it reaches the specified minimum, then up, then down, and so on.
Output
bang
Out left-middle outlet: If a
Out right-middle outlet: If a message has been received in the left inlet, then when the count is moving upward and reaches the maximum limit, a is sent out (instead of the number which is sent out by default). When the count leaves the maximum limit, nothing is sent out. This only works in mode 0 (count up) or mode 2 (count up and down).
int
Out left outlet: When
When the direction is up, or up and down, counter begins counting from the specified minimum value. When the direction is down, counter begins from the maximum value.
Out left-middle outlet: When the count is moving downward and reaches the minimum limit, the number is sent out. When the count leaves the minimum limit, is sent out. This only works in mode 1 (count down) or mode 2 (count up and down).
Out right-middle outlet: When the count is moving upward and reaches the maximum limit, the number is sent out. When the count leaves the maximum limit, is sent out. This only works in mode 0 (count up) or mode 2 (count up and down).
Out right outlet: An additional count is kept of the number of times counter reaches its maximum limit. Each time the maximum is reached, that count is sent out.
See Also
Name | Description |
---|---|
tempo | Output numbers at a metronomic tempo |