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

urn Reference

Generate random numbers without duplicates

urn

Examples

Arguments

size [number]

Optional

Sets the range of possible output values. Output values are 0 indexed. Changing this value will clear the internal array of used numbers.

seed [number]

Optional

Sets a seed state for the random values, so that randomized results will be predictable each time the code is run.

Inlets

trigger [bang]

A bang or number in the left inlet causes urn to output a number between 0 and one less than the value of the size attribute. Each number in the range can only be output once until the object is cleared.

size [number]

Sets the range of possible output values. Output values are 0 indexed. Changing this value will clear the internal array of used numbers.

Outlets

out [number]

The number chosen. This value will be between 0 and one less than the maximum value as determined by the size attribute.

bangout [bang]

Send a bang when every number in the range has been chosen.

Dynamic Attributes

These attributes can be modified in the code during execution using the set object

autoclear [bool] (default: false)

When enabled the urn object will automatically clear itself once all numbers in the range have been used.

clear [bang]

Clear the list of already chosen numbers. Note that this does not reset the object to the original seed state.

norepeat [bool] (default: false)

When enabled, the first number generated at the start of a new series (after the clear message) will never match the final number of the previous series.

seed [number]

Sets a seed state for the random values, so that randomized results will be predictable each time the code is run.

size [number]

Sets the range of possible output values. Output values are 0 indexed. Changing this value will clear the internal array of used numbers.

trigger [bang]

A bang or number in the left inlet causes urn to output a number between 0 and one less than the value of the size attribute. Each number in the range can only be output once until the object is cleared.

See Also

Name Description
drunk Output random numbers within a step range.
noise White noise generator
random Generate random numbers
urn Generate random numbers without duplicates