# Clock

> Bar, beat, eighth, sixteenth and triplet pulses plus the phase within the beat on six lanes, locked to the transport or at its own tempo.

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

Clock turns the shared transport into pulses you can cable: one lane for each bar, beat, eighth, sixteenth and eighth-note triplet, plus a sixth lane with the position inside the current beat. Use it to restart LFOs on the bar, count beats, or step anything that takes a trigger.

## What it does

The six output lanes are `[bar, beat, eighth, sixteenth, triplet, phase]`. Each of the first five is 1 for exactly one block when its boundary falls inside that block, and 0 otherwise. A bar is four clock beats. The `phase` lane is the position within the clock beat, 0 to 1, at the start of the block.

With Source on Transport, the clock reads the transport's beat, so it pulses only while the transport rolls and lands on the same blocks on every replay and offline render. With Source on Free, it counts its own Tempo instead. Multiply sets how many clock beats fit in one transport beat (or one Tempo beat in Free mode).

Control runs once per audio block, so a pulse can arrive up to one block after its exact time: about 2.7 ms at 128 frames and 48 kHz. Sequencers that need sample-exact notes, such as [Step sequencer](https://docs.tune.toys/nodes/midi.step/), read the transport directly rather than this clock.

### Inputs

`run` gates the clock: unconnected, it runs while the transport rolls; cabled, it runs while the lane is at least 0.5. A rising edge on `reset` restarts the bar at that block, so every lane pulses there and the phase starts again from 0. Pick a single lane of another node's bundle with [Select lanes](https://docs.tune.toys/nodes/ctl.select/) to cable it into either input.

## When to use it

Use Clock when something should happen in time with the music but is not a note: reset a [Control LFO](https://docs.tune.toys/nodes/ctl.lfo/) on every bar, advance a [Counter](https://docs.tune.toys/nodes/ctl.counter/) on each beat, or retrigger an envelope on the sixteenths. To play notes, use a sequencer instead.

## Ports

<!-- ports:start -->

| Port      | Direction | Signal  | Lanes |
| --------- | --------- | ------- | ----- |
| `run`     | Input     | Control | 1     |
| `reset`   | Input     | Control | 1     |
| `control` | Output    | Control | 6     |

<!-- ports:end -->

## Parameters

<!-- parameters:start -->

| Parameter  | Label    | Range     | Default | Unit | Scale  | Notes                                                                                                                              |
| ---------- | -------- | --------- | ------- | ---- | ------ | ---------------------------------------------------------------------------------------------------------------------------------- |
| `source`   | Source   | 0 to 1    | 0       |      | linear | Transport follows the shared transport's beat and runs while it rolls; Free counts at its own Tempo. Choices: 0 Transport, 1 Free. |
| `bpm`      | Tempo    | 20 to 300 | 120     |      | linear | Beats per minute in Free mode. Shown when `source` is 1.                                                                           |
| `swing`    | Swing    | 0 to 0.75 | 0       |      | linear | Delay of every second eighth and sixteenth pulse, as a fraction of its spacing: about 0.33 is a triplet feel.                      |
| `multiply` | Multiply | 0 to 4    | 2       |      | linear | Clock beats per transport beat: ×2 doubles every pulse rate, ×½ halves it. Choices: 0 ×¼, 1 ×½, 2 ×1, 3 ×2, 4 ×4.                  |

<!-- parameters:end -->

### Source (`source`)

Transport or Free. Transport follows the shared transport's beat and tempo; Free counts its own Tempo from where it is, and its `reset` input restarts it from zero.

### Tempo (`bpm`)

Beats per minute in Free mode, 20 to 300. Hidden while Source is Transport, which uses the transport's tempo.

### Swing (`swing`)

Delays every second eighth and every second sixteenth by a fraction of its spacing, 0 to 0.75. About 0.33 gives a triplet feel and 0.5 a dotted one. Bars, beats and triplets are never swung.

### Multiply (`multiply`)

Clock beats per transport beat: ×¼, ×½, ×1, ×2 or ×4. At ×2 every lane runs twice as fast and a bar lasts two transport beats.

## Tips

- Cable the bar lane (lane 1, through Select lanes) into a Control LFO's `reset` so the LFO starts every bar at its Phase.
- The `phase` lane is a beat-long ramp: scale it to sweep something once per beat.
- In Free mode with nothing cabled to `run`, the clock still waits for the transport to roll; cable a constant 1 into `run` to keep it running.

## See also

[Counter](https://docs.tune.toys/nodes/ctl.counter/), [Select lanes](https://docs.tune.toys/nodes/ctl.select/), [Control LFO](https://docs.tune.toys/nodes/ctl.lfo/), [Step sequencer](https://docs.tune.toys/nodes/midi.step/), [Control lanes](https://docs.tune.toys/concepts/control-lanes/).
