OAVp5.clock.bpm#
variableoav-p5OAVp5.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
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);
}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.infoA snapshot of the external clock:state(none,running,stoppedorlost),bpm, whether the drums follow it, where it came from, and counts.OAVp5.clock.phaseWhere the external clock is right now:{ pos, bar, beat, bpm, running }, ornullwhile there is no tempo.drumBpmThe tempo of the drum machine in beats per minute.