open-audiovisual
Search GitHub

oav-p5 reference · Loading options

clock#

optionoav-p5
?oav_clock=follow | off

Whether an external MIDI clock (from a DAW, Strudel or a drum machine) moves drumPhase, drumBpm and the drum machine: follow or off.

With follow, an external MIDI clock (24 ticks a beat, plus start, stop and song position) is followed: drumPhase, beatPhase, drumBar, drumStep and drumBpm read it, and a drum machine that is up takes its tempo and its downbeat from it, starting and stopping with it. OAVp5.clock tells you what it hears. With nothing sending a clock, nothing changes.

off ignores every clock message: OAVp5.clock.info.state stays 'none'. Use it when something on the page or the machine sends a clock you do not want the sketch to follow.

Type
String
Values
follow | off
default
follow

Anything except off means follow.

Notes

  • Set it before oav-p5 loads. window.OAV_P5 = { clock: … }; above the loader line wins, then ?oav_clock=… on the page address, then ?clock=… on the script's own URL. Values in window.OAV_P5 are turned into text, so write 'off', not false. On OpenProcessing the page address takes ?sketch_oav_clock=… (the project's README says OpenProcessing forwards it to the sketch).

Examples

jsOpenProcessing ↗
window.OAV_P5 = { clock: 'off' };

function setup() {
  createCanvas(400, 300);
  OAVp5.input([0xFA]);                          // MIDI start
  setInterval(() => OAVp5.input([0xF8]), 20);   // clock ticks: 24 a beat, here 50 a second
}

function draw() {
  background(20);
  fill(255);
  text('clock option: ' + OAVp5.options.clock, 20, 30);
  text('external clock: ' + OAVp5.clock.info.state, 20, 60);   // none: the clock is ignored
}
The sketch sends itself a made-up MIDI clock, and with clock: 'off' it is ignored: the state stays "none". Delete the first line and it reads "running".

Related

  • OAVp5.clock What oav-p5 hears of an external MIDI clock: its state, tempo and where it is in the bar. Nothing until another program or device starts sending one.
  • drumPhase How far through the current bar the drum machine is, smoothly from 0 up to just below 1, as it is heard.
  • beatPhase How far through the current beat the drum machine is, smoothly from 0 up to just below 1, four times per bar.
  • startDrums() Starts a drum machine: a 16-step grid on the page that plays a preset, your own grid or one line of rhythm, and counts the bars for your sketch.
  • link Joins a room: oav-p5 pages with the same room hear what each other's programs play, over the relay. A room name, or empty for none.

p5/oav-p5.js, line 155

↑ Back to top · All names