round~

Round an input signal value

Description

The round~ objects rounds its left signal input to the integer multiple of its right signal input. You can set the object's 'nearest' attribute to determine whether or not it rounds to the absolute nearest integer multiple, or the nearest integer multiple between the value and zero (for positive numbers this will round down). By default this is on.

Arguments

Name Type Opt Description
int or float int or float opt Sets the value to which the input signal will be rounded. The default value is 0. (no modification).

Messages

 int rounding-multiple-specifier [int] In right inlet: an int or float will cause the input to be rounded to the nearest multiple of the specified number. If a signal is attached to the inlet, int and float messages are ignored. float rounding-multiple-specifier [float] In right inlet: an int or float will cause the input to be rounded to the nearest multiple of the specified number. If a signal is attached to the inlet, int and float messages are ignored. signal In left inlet: A signal whose values will be rounded. In right inlet: A signal whose value is used for rounding. Signal values received in the left inlet will be rounded to either the absolute nearest integer multiple or the nearest integer multiple between the value received in this inlet or 0 (see the nearest message for more information).

Attributes

Name Type g/s Description
nearest int When set to 1 (the default), the round~ object will round to the nearest multiple of the specified signal value.

Note: This attribute does not set the rounding step (which is set using round~ object's right inlet), It specifies that rounding to the nearest signal value will occur. Here are some examples:

With the rounding interval set to 3 and the nearest attribute set to 1:
an input signal value of 5.8 will return 6
an input signal value of 3.7 will return 3
an input signal value of -1 will return 0
an input signal value of -2.7 will return -3

With the rounding interval set to 3 and the nearest attribute set to 0:
an input signal value of 5.8 will return 3
an input signal value of 3.7 will return 3
an input signal value of -1 will return 0
an input signal value of -2.7 will return 0

Output

signal: The rounded input signal.

Examples

round~ takes floating-point signals and rounds them to a specific increment