open-audiovisual
Search GitHub

oav-p5 reference · The OAVp5 object (advanced)

OAVp5.clock.bpm#

variableoav-p5
OAVp5.clock.bpm

The tempo of the external MIDI clock in beats a minute, or null while there is none.

The raw number, not rounded. Use it for anything that should run at the clock's tempo: OAVp5.clock.bpm / 60 is beats a second. If the drum machine follows the clock, drumBpm shows it rounded to a tenth.

Type
Number | null

Fitted over the last 24 clock ticks, so it settles within a moment and does not jump with one late tick. null before two ticks have arrived or when clock=off.

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);
  textSize(48);
  textAlign(CENTER, CENTER);
  const bpm = OAVp5.clock.bpm;
  text(bpm ? nf(bpm, 1, 1) + ' BPM' : 'no clock', width / 2, height / 2);
}
Prints the tempo of the made-up clock the sketch sends itself: about 125 BPM once a few ticks have arrived.

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.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.
  • OAVp5.clock.phase Where the external clock is right now: { pos, bar, beat, bpm, running }, or null while there is no tempo.
  • drumBpm The tempo of the drum machine in beats per minute.

p5/oav-p5.js, line 744

↑ Back to top · All names