Cron

Fire a trigger on an interval, a cron expression or musical beats, with the time as JSON.

  • Time
  • Since 0.2.0
  • time
  • clock
  • schedule
  • interval
  • cron
  • beat
  • trigger
  • data

Open in TuneToys

Cron as the Patch draws it, at default values: inlets on the left, outlets on the right.

Cron is the data domain's clock. It sends a trigger every few seconds, at the times a cron expression names, or on musical beats, and it sends the time with each tick as JSON.

What it does#

Each tick sends true on tick and an object on time: { iso, epochMs, beat, bar, count }, where count starts at 1. Ticks are stamped with the audio block they belong to, so they line up with the sound rather than with a UI timer.

Cron only ticks while the transport rolls. Pressing Play starts it; stopping, seeking or changing tempo re-arms it. A cabled enable input pauses it while false.

Cron runs in the browser's data runtime. The Player and exports report the data domain unavailable at load, so it does not tick there.

When to use it#

Use it to drive anything that should happen again and again: pick a new Random value, refresh a Web request, play a JSON melody every bar, or log the time to the Console.

Ports#

PortDirectionSignalLanes
enableInputData (boolean)1
tickOutputData (trigger)1
timeOutputData (json)1

Parameters#

ParameterLabelRangeDefaultUnitScaleNotes
modeMode0 to 20linearInterval fires every few seconds, Cron follows the expression in the host time zone, Beat follows the transport. Choices: 0 Interval, 1 Cron, 2 Beat.
intervalInterval0.05 to 36001slogSeconds between ticks in Interval mode.
divisionDivision0 to 52linearNote value between ticks in Beat mode. Choices: 0 Whole, 1 Half, 2 Quarter, 3 Eighth, 4 Sixteenth, 5 Bar.
limitLimit0 to 1000000linearStop after this many ticks; 0 runs until stopped.
  • expression: cron.

Mode (mode)#

Interval ticks every Interval seconds, counted from when the transport starts; ticks are targeted at exact frames, so they never drift. Cron follows the node's cron expression in the host's time zone. Beat ticks on the transport's beats at the chosen Division.

Interval (interval)#

Seconds between ticks in Interval mode, from 0.05 to 3600. The first tick arrives one interval after Play.

Division (division)#

The note value between ticks in Beat mode: whole, half, quarter, eighth or sixteenth notes, or one bar of the current time signature.

Limit (limit)#

Stop after this many ticks. 0 runs until the transport stops.

Cron expression#

The node's expression field takes five fields (minute hour day month weekday) or six with seconds first, such as */5 * * * * * for every five seconds. The inspector previews the next five runs. It is used only in Cron mode.

Tips#

  • Nothing happens until you press Play: Cron follows the transport.
  • Use Beat mode for anything musical. It follows tempo changes, while Interval keeps clock time.
  • Wire tick to triggers and time to Console log to see when each tick happened.

See also#

Random, Console log, Data to MIDI, Data cables, Takes.

Help patches

Each help patch is an ordinary Toy that teaches one idea. The diagram shows the Patch; the preview shows its Frame. Open it in TuneToys to play and edit it.

1. A lamp every second

beginner Teaches: mode, interval

Cron ticks once a second and Random picks a new colour for a lamp each time.

Patch: Cron tick output connected to Random trigger input.
Connections as text
  • Cron tick output connected to Random trigger input
  • Interval mode: one tick every Interval seconds, counted from when the transport starts.
  • Each tick asks Random for a new colour; the lamp shows the Random output.
Frame preview: A lamp every secondFrame “A lamp every second” with 3 elements: text heading, text hint, led Lamp.A LAMP EVERY SECONDPress Play: Cron only ticks while the transport rolls. The lamp changes colour …led
Frame preview (static). Controls show their default values.

Open in TuneToys

2. On the beat

intermediate Teaches: division, limit

Beat mode ticks on every quarter note and stops after sixteen ticks; the time JSON goes to the Console.

Patch: Cron time output connected to Console log value input.
Connections as text
  • Cron time output connected to Console log value input
  • Beat mode follows the transport tempo; Division picks the note value.
  • Limit 16 stops after sixteen ticks; 0 runs until the transport stops.
  • The time output carries iso, epochMs, beat, bar and count.
Frame preview: On the beatFrame “On the beat” with 2 elements: text heading, text hint.ON THE BEATPress Play and open the Console panel: one line per quarter note, sixteen in al…
Frame preview (static). Controls show their default values.

Open in TuneToys

  • Random Make a random number, integer, boolean, string, colour or choice on each trigger; seeded when a seed is wired.
  • Console log Write each incoming value to the Console panel with a level and label, rate-limited.
  • Data to MIDI Play a JSON list of notes in beats as MIDI on each trigger, scheduled on the transport.

Edit this page on GitHub

esc

↑ ↓ move↩ open⌘↩ new tabesc close