OAVp5.clock.info#
objectoav-p5OAVp5.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
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);
}Related
OAVp5.clockWhat 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.bpmThe tempo of the external MIDI clock in beats a minute, ornullwhile there is none.OAVp5.clock.phaseWhere the external clock is right now:{ pos, bar, beat, bpm, running }, ornullwhile there is no tempo.clockWhether an external MIDI clock (from a DAW, Strudel or a drum machine) movesdrumPhase,drumBpmand the drum machine:followoroff.