<?xml version="1.0" encoding="utf-8" standalone="yes"?>

<?xml-stylesheet href="./_c74_ref.xsl" type="text/xsl"?>

<!--This is an automatically generated file. DO NOT EDIT THIS FILE DIRECTLY. Rather, use the _ref.xml files found in the 'edits' folder.-->
<c74object name="counter" module="max" category="Control">
	<digest>
		Keep count based on bang messages
	</digest>
	<description>
		Outputs the current count of bang message constrained to a specified range. Can be set to count up, down, or up-then-down.
	</description>
	<!--METADATA-->
	<metadatalist>
		<metadata name="author">
			Cycling '74
		</metadata>
		<metadata name="tag">
			Max
		</metadata>
		<metadata name="tag">
			Control
		</metadata>
	</metadatalist>
	<!--INLETS-->
	<inletlist>
		<inlet id="0" type="INLET_TYPE">
			<digest>
				int, bang are Counted, set Sets Counter Value
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
		<inlet id="1" type="INLET_TYPE">
			<digest>
				Set Direction: 0 = Up, 1 = Down, 2 = UpDown
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
		<inlet id="2" type="INLET_TYPE">
			<digest>
				Resets Counter to Number on Next Clock
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
		<inlet id="3" type="INLET_TYPE">
			<digest>
				Resets Counter to Number Immediately
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
		<inlet id="4" type="INLET_TYPE">
			<digest>
				Sets Count Maximum
			</digest>
			<description>
				TEXT_HERE
			</description>
		</inlet>
	</inletlist>
	<!--OUTLETS-->
	<outletlist>
		<outlet id="0" type="OUTLET_TYPE">
			<digest>
				Current Count
			</digest>
			<description>
				TEXT_HERE
			</description>
		</outlet>
		<outlet id="1" type="OUTLET_TYPE">
			<digest>
				Underflow (Counter Hit Minimum) Flag
			</digest>
			<description>
				TEXT_HERE
			</description>
		</outlet>
		<outlet id="2" type="OUTLET_TYPE">
			<digest>
				Carry (Counter Hit Maximum) Flag
			</digest>
			<description>
				TEXT_HERE
			</description>
		</outlet>
		<outlet id="3" type="OUTLET_TYPE">
			<digest>
				Carry Count
			</digest>
			<description>
				TEXT_HERE
			</description>
		</outlet>
	</outletlist>
	<!--ARGUMENTS-->
	<objarglist>
		<objarg name="options" optional="1" type="int">
			<digest>
				Function depends on number of arguments
			</digest>
			<description>
				If there is only one argument, it sets an initial maximum count value for <o>counter</o>. 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).
			</description>
		</objarg>
	</objarglist>
	<!--MESSAGES-->
	<methodlist>
		<method name="bang">
			<arglist />
			<digest>
				Function depends on inlet
			</digest>
			<description>
				In left inlet: Sends out the current count of the <m>bang</m> messages received in the left inlet.
				<br />
				<br />
				In left-middle inlet: Changes the direction of the count.
				<br />
				<br />
				In middle inlet: Resets the count to its specified minimum value, which will be sent out the next time a <m>bang</m> is received in the left inlet.
				<br />
				<br />
				In right-middle inlet: Resets the count to its specified minimum value, and sends out that value immediately.
				<br />
				<br />
				In right inlet: Resets the count to its specified maximum value, which is sent out immediately.
			</description>
		</method>
		<method name="int">
			<arglist>
				<arg name="input" optional="0" type="int" />
			</arglist>
			<digest>
				Function depends on inlet
			</digest>
			<description>
				In left inlet: Same effect as <m>bang</m>.				<br />
				<br />
				In left-middle inlet: Sets the direction of the count. <m>0</m> causes <o>counter</o> to count up, <m>1</m> causes it to count down, and <m>2</m> causes it to count up and down.
				<br />
				<br />
				In middle inlet: The number sets the counter to a new value, to be sent out the next time a <m>bang</m> 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.
				<br />
				<br />
				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.
				<br />
				<br />
				In right inlet: Resets the maximum value sent out by <o>counter</o>. 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 <o>counter</o> objects retains the correct maximum value it received through this inlet. Unlike a <m>bang</m> message, an int in this inlet does not cause the <o>counter</o> object to output anything.
			</description>
		</method>
		<method name="float">
			<arglist>
				<arg name="input" optional="0" type="float" />
			</arglist>
			<digest>
				Function depends on inlet
			</digest>
			<description>
				In all other inlets: Converted to <m>int</m>.
			</description>
		</method>
		<method name="dec">
			<arglist />
			<digest>
				Decrement the counter value
			</digest>
			<description>
				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.
			</description>
		</method>
		<method name="down">
			<arglist />
			<digest>
				Set direction to down (decreasing)
			</digest>
			<description>
				In left inlet: Sets the <o>counter</o> to count in a downward direction.
			</description>
		</method>
		<method name="carrybang">
			<arglist />
			<digest>
				Change carry output to a bang message
			</digest>
			<description>
				In left inlet: Causes <o>counter</o> to send a <m>bang</m> out the right-middle outlet when the count is going upward and reaches its maximum limit, and causes <o>counter</o> to send a <m>bang</m> out the left-middle outlet when the count is going downward and reaches its minimum limit. (By default, counter sends out the number <m>1</m> in those situations, instead of <m>bang</m>.) The state of the <m>carrybang</m> message is saved along with the patcher it is used in.
			</description>
		</method>
		<method name="carryint">
			<arglist />
			<digest>
				Change carry output to an int message
			</digest>
			<description>
				In left inlet: Undoes the effect of a previously received <m>carrybang</m> message. Resets the counter to send the numbers <m>1</m> and <m>0</m> out the left-middle and right-middle outlets (instead of <m>bang</m>) to signal when the counter reaches and leaves its minimum and maximum values. The state of the <m>carryint</m> message is saved along with the patcher it is used in.
			</description>
		</method>
		<method name="goto">
			<arglist>
				<arg name="input" optional="0" type="int" />
			</arglist>
			<digest>
				Set the counter value with no output
			</digest>
			<description>
				In left inlet: Same effect as <m>set</m>.
			</description>
		</method>
		<method name="flags">
			<arglist>
				<arg name="carry-mode" optional="0" type="int" />
				<arg name="minimum-mode" optional="0" type="int" />
			</arglist>
			<digest>
				Set operational modes
			</digest>
			<description>
				The <m>flags</m> message followed by two numbers will set the Underflow/Carry Mode and set the Minimum-Mode resetting capability. If the first number is 0, <o>counter</o> will output a 1 when it hits the maximum or else output a 0. If the first number is 1, <o>counter</o> will output a <m>bang</m> 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.
			</description>
		</method>
		<method name="inc">
			<arglist />
			<digest>
				Increment the counter value
			</digest>
			<description>
				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.
			</description>
		</method>
		<method name="jam">
			<arglist>
				<arg name="input" optional="0" type="int" />
			</arglist>
			<digest>
				Set the counter value and cause output
			</digest>
			<description>
				In left inlet: The word <m>jam</m>, 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.
			</description>
		</method>
		<method name="next">
			<arglist />
			<digest>
				Output next count value
			</digest>
			<description>
				In left inlet: Same as <m>bang</m>.
			</description>
		</method>
		<method name="max">
			<arglist>
				<arg name="maximum" optional="0" type="int" />
			</arglist>
			<digest>
				Set the maximum value
			</digest>
			<description>
				In left inlet: The word <m>max</m> followed by a number, resets the maximum value of <o>counter</o> 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 <o>counter</o> object.
			</description>
		</method>
		<method name="min">
			<arglist>
				<arg name="minimum" optional="0" type="int" />
			</arglist>
			<digest>
				Set the minimum value and cause output
			</digest>
			<description>
				In left inlet: The word <m>min</m> followed by a number, resets the minimum value of <o>counter</o> to that number, and causes the <o>counter</o> 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.
			</description>
		</method>
		<method name="set">
			<arglist>
				<arg name="input" optional="0" type="int" />
			</arglist>
			<digest>
				Set the counter value with no output
			</digest>
			<description>
				In left inlet: The word <m>set</m>, followed by a number, sets the counter to that number, which will be sent out the next time a <m>bang</m> is received in the left inlet.
			</description>
		</method>
		<method name="setmin">
			<arglist>
				<arg name="minimum" optional="0" type="int" />
			</arglist>
			<digest>
				Set the minimum value with no output
			</digest>
			<description>
				In left inlet: The word <m>setmin</m>, followed by a number, sets the <o>counter</o> object's minimum count without affecting its current count value or causing any output.
			</description>
		</method>
		<method name="state">
			<arglist />
			<digest>
				Print current state to the Max Console
			</digest>
			<description>
				The message <m>state</m> will cause the <o>counter</o> object to report its current state to the Max Console.
			</description>
		</method>
		<method name="up">
			<arglist />
			<digest>
				Set direction to up (increasing)
			</digest>
			<description>
				In left inlet: Sets the <o>counter</o> to count in an upward direction.
			</description>
		</method>
		<method name="updown">
			<arglist />
			<digest>
				Set direction to up/down (alternating)
			</digest>
			<description>
				In left inlet: Sets the <o>counter</o> 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.
			</description>
		</method>
	</methodlist>
	<!--ATTRIBUTES-->
	<attributelist>
		<attribute name="carryflag" get="1" set="1" type="int" size="1">
			<digest>
				Carry output flag
			</digest>
			<description>
				Sets the type of data output from the third outlet (numbers or bangs).
			</description>
			<attributelist>
				<attribute name="basic" get="1" set="1" type="int" size="1" value="1" />
				<attribute name="enumvals" get="1" set="1" type="atom" size="2">
					<enumlist>
						<enum name="Numeric">
							<digest>
								TEXT_HERE
							</digest>
							<description>
								TEXT_HERE
							</description>
						</enum>
						<enum name="Bang">
							<digest>
								TEXT_HERE
							</digest>
							<description>
								TEXT_HERE
							</description>
						</enum>
					</enumlist>
				</attribute>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Carry Flag Output" />
				<attribute name="style" get="1" set="1" type="symbol" size="1" value="enumindex" />
			</attributelist>
		</attribute>
		<attribute name="compatmode" get="1" set="1" type="int" size="1">
			<digest>
				Compatibility mode
			</digest>
			<description>
				Provides compatibility when importing patches created with versions 3.x and earlier of Max. When &quot;Ancient&quot; 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 <m>min</m> message were sent to the <o>counter</o> object).
			</description>
			<attributelist>
				<attribute name="enumvals" get="1" set="1" type="atom" size="2">
					<enumlist>
						<enum name="Current">
							<digest>
								TEXT_HERE
							</digest>
							<description>
								TEXT_HERE
							</description>
						</enum>
						<enum name="Ancient">
							<digest>
								TEXT_HERE
							</digest>
							<description>
								TEXT_HERE
							</description>
						</enum>
					</enumlist>
				</attribute>
				<attribute name="label" get="1" set="1" type="symbol" size="1" value="Compatibility Mode" />
				<attribute name="style" get="1" set="1" type="symbol" size="1" value="enumindex" />
			</attributelist>
		</attribute>
	</attributelist>
	<!--EXAMPLE-->
	<examplelist>
		<example img="counter.png" caption="Keep track of how many events have occurred, or create a continuous loop" />
	</examplelist>
	<!--SEEALSO-->
	<seealsolist>
		<seealso name="tempo" />
		<seealso name="basicchapter11" module="max" type="tutorial" />
	</seealsolist>
	<misc name="Output">
		<entry name="int">
			<description>
				Out left outlet: When <m>bang</m>, <m>next</m>, <m>inc</m>, <m>dec</m>, or a number is received in the left inlet, the current count is sent out, within the minimum and maximum limits specified. If the direction of the count is both up and down, the count is folded back in the other direction when it reaches the specified limits. If the count is in only one direction, up or down, the count is wrapped around to the opposite extreme when it reaches its limit.
				<br />
				<br />
				When the direction is up, or up and down, <o>counter</o>, begins counting from the specified minimum value. When the direction is down, <o>counter</o> begins from the maximum value.
				<br />
				<br />
				Out left-middle outlet: When the count is moving downward and reaches the minimum limit, the number <m>1</m> is sent out. When the count leaves the minimum limit, <m>0</m> is sent out.
				<br />
				<br />
				Out right-middle outlet: When the count is moving upward and reaches the maximum limit, the number <m>1</m> is sent out. When the count leaves the maximum limit, <m>0</m> is sent out.
				<br />
				<br />
				Out right outlet: An additional count is kept of the number of times <o>counter</o> reaches its maximum limit. Each time the maximum is reached, that count is sent out.
			</description>
		</entry>
		<entry name="bang">
			<description>
				Out left-middle outlet: If a <m>carrybang</m> message has been received in the left inlet, then when the count is moving downward and reaches the minimum limit, a <m>bang</m> is sent out (instead of the number <m>1</m> which is sent out by default). When the count leaves the minimum limit, nothing is sent out.
				<br />
				<br />
				Out right-middle outlet: If a <m>carrybang</m> message has been received in the left inlet, then when the count is moving upward and reaches the maximum limit, a <m>bang</m> is sent out (instead of the number <m>1</m> which is sent out by default). When the count leaves the maximum limit, nothing is sent out.
			</description>
		</entry>
	</misc>
</c74object>
