open-audiovisual
Search GitHub

oav-p5 reference · The OAVp5 object (advanced)

OAVp5.clock.info#

objectoav-p5
OAVp5.clock.info

A snapshot of the external clock: state (none, running, stopped or lost), bpm, whether the drums follow it, where it came from, and counts.

state is 'none' until a clock message has come, 'running' while the clock is going, 'stopped' after a MIDI stop (the position holds and clocks may still arrive), and 'lost' when no clock message has arrived for 0.6 seconds. bpm is the tempo fitted over the last 24 ticks, rounded to two decimals, or null before two ticks. running is true while the transport runs, which a stream of clocks with no start message counts as too (implicit is true then).

following is true when the drums read this clock: it is running, has a tempo and clock=off is not set. source says where the messages came from: 'hardware', 'screen', 'phone', 'virtual-out' (a program playing into OAV Virtual MIDI) or 'link'. clocks, dupes, starts, stops and continues count what arrived; a start sent three times with one timestamp counts once and adds to dupes.

Type
Object

A new object each time you read it: { state, bpm, running, following, source, implicit, clocks, dupes, starts, stops, continues }. Before any clock message it is { state: 'none', bpm: null, running: false, following: false, source: null, clocks: 0 }.

Examples

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

function draw() {
  background(20);
  fill(255);
  const i = OAVp5.clock.info;
  text('state: ' + i.state + (i.running ? ' (running)' : ''), 20, 30);
  text('bpm: ' + i.bpm + ',  following: ' + i.following, 20, 60);
  text('source: ' + i.source + ',  clocks heard: ' + i.clocks, 20, 90);
}
Prints the clock's snapshot while the sketch sends itself a made-up clock: the state goes from "none" to "running" within a moment.

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.
  • OAVp5.clock.bpm The tempo of the external MIDI clock in beats a minute, or null while there is none.
  • OAVp5.clock.phase Where the external clock is right now: { pos, bar, beat, bpm, running }, or null while there is no tempo.
  • clock Whether an external MIDI clock (from a DAW, Strudel or a drum machine) moves drumPhase, drumBpm and the drum machine: follow or off.

p5/oav-p5.js, line 743

↑ Back to top · All names