# Random

> A seeded random control lane: steps, glides or walks to a new value on each trigger, or free-running at a rate or tempo division.

Source: https://docs.tune.toys/nodes/ctl.random/

Random is a control lane that changes to a new random value now and then. It either follows a trigger you cable in, or runs on its own clock.

## What it does

Each time a new value is due, Random decides with Probability whether to change at all, then picks the value. In Step mode the lane jumps to a new value between 0 and 1; in Smooth mode it glides there over Slew; in Walk mode it moves from where it is by at most Walk either way and stays inside 0 to 1. Min and Max then map that 0 to 1 value onto the range the output uses, and may be swapped to invert it.

When a cable reaches Trigger, each rising edge is a new value. When nothing does, Random runs at Rate, or at one value per Beats when Beats is above 0, locked to the shared transport.

### Seeded

The sequence is seeded from the node's path, so the same Toy produces the same values on every host, every play and every replay. Two Random nodes in one Toy differ because their paths differ. Changing Probability does not shift the sequence that follows.

## When to use it

Use it for sample-and-hold style stepped values, a drifting pitch, humanised timing or levels, and generative patches. For random shapes inside a cycle, see the Random step and Random smooth shapes of [Control LFO](https://docs.tune.toys/nodes/ctl.lfo/); to freeze any lane on a clock use [Sample and hold](https://docs.tune.toys/nodes/ctl.hold/).

## Ports

<!-- ports:start -->

| Port      | Direction | Signal  | Lanes |
| --------- | --------- | ------- | ----- |
| `trigger` | Input     | Control | 1     |
| `control` | Output    | Control | 1     |

<!-- ports:end -->

## Parameters

<!-- parameters:start -->

| Parameter     | Label       | Range      | Default | Unit  | Scale  | Notes                                                                                                                                |
| ------------- | ----------- | ---------- | ------- | ----- | ------ | ------------------------------------------------------------------------------------------------------------------------------------ |
| `mode`        | Mode        | 0 to 2     | 0       |       | linear | Step jumps to a new value, Smooth glides to it, Walk moves a bounded step from the current value. Choices: 0 Step, 1 Smooth, 2 Walk. |
| `rate_hz`     | Rate        | 0.01 to 40 | 2       | Hz    | log    | New values per second when nothing is cabled to Trigger and Beats is 0.                                                              |
| `beats`       | Beats       | 0 to 64    | 0       | beats | linear | Beats per new value, synced to the shared transport, when nothing is cabled to Trigger. 0 uses Rate instead.                         |
| `probability` | Probability | 0 to 1     | 1       |       | linear | Chance that a trigger changes the value.                                                                                             |
| `walk`        | Walk        | 0 to 1     | 0.2     |       | linear | Largest step either way in Walk mode.                                                                                                |
| `slew_ms`     | Slew        | 0 to 10000 | 100     | ms    | linear | Glide time in Smooth mode.                                                                                                           |
| `min`         | Min         | 0 to 1     | 0       |       | linear | Output when the internal value is 0.                                                                                                 |
| `max`         | Max         | 0 to 1     | 1       |       | linear | Output when the internal value is 1.                                                                                                 |

<!-- parameters:end -->

### Mode (`mode`)

Step, Smooth or Walk. A discrete choice.

### Rate (`rate_hz`) and Beats (`beats`)

How often a new value is due when Trigger is not cabled. Beats above 0 follows the transport and Rate is ignored. Control runs once per audio block, so at most one new value arrives per block.

### Probability (`probability`)

The chance a trigger changes the value, 0 to 1.

### Walk (`walk`)

The largest step either way in Walk mode.

### Slew (`slew_ms`)

The glide time in Smooth mode.

### Min (`min`) and Max (`max`)

The output range the 0 to 1 value is mapped onto.

## Tips

- Cable a [Control LFO](https://docs.tune.toys/nodes/ctl.lfo/) square wave into Trigger to line new values up with a clock.
- Set Min and Max narrower for a gentle drift around a centre.
- Probability 0.5 on a steady clock gives uneven, human-sounding changes.

## See also

[Sample and hold](https://docs.tune.toys/nodes/ctl.hold/), [Control LFO](https://docs.tune.toys/nodes/ctl.lfo/), [Counter](https://docs.tune.toys/nodes/ctl.counter/), [Scale](https://docs.tune.toys/nodes/ctl.scale/), [Cables](https://docs.tune.toys/concepts/cables/).
