fluctuate

Created by Panaiotis
© 2001 by Panaiotis. All rights reserved.

General

A variation of the random object. fluctuate takes a focus point, a minimum offset from the focus, and a maximum offset from the focus. The result is the range that fluctuate will use to generate random values. The calculated extremes are inclusive. Changing the focus simultaneously changes the upper and lower limits of the randomly generated numbers. If min and max are both positive or both negative, the output will not include the focus.

Input

  bang in leftmost inlet: trigger random output.
  # in leftmost inlet: min and max represent fixed values from the focus.
  % in left inlet: min and max represent a percentage deviation from the focus. (Useful for fluctuations of time).
min deviation = focus + (focus * min/100).
max deviation = focus + (focus * max/100).
  int in leftmost inlet: set the focus.
  in1 set the lower limit of the random numbers. Negative values set the lower limit below the focus. Positive numbers set the lower limit above the focus. Actual lower limit depends on the mode (% or #).
  in2 set the upper limit of the random numbers. Negative values set the upper limit below the focus. Positive numbers set the upper limit above the focus. Actual upper limit depends on the mode (% or #).

Arguments

  optional The first argument may be a Symbol (% or #). The remaining arguments are integers: focus, min, max.

Output

  int out left outlet a random number between (focus + min) and (focus + max), inclusive. If the generated number = previously generated number, no output. If min=max, (focus + min) is output at the next bang and no further output is made until min != max.
  bang out right outlet if no change between previous output and new value.

 

Examples

fluctuate sets the rate of metro, which will fluctuate between 250ms and 750ms. Each output of metro will generate a new rate value. Change the focus (the general rate) and metro will still fluctuate with a range 1/2 focus to 1 1/2 focus.

now fluctuate has a range between 25ms and 75ms. The % deviation remains the same

See also

random, autocount