drumBpm#
variableoav-p5drumBpmAlso: OAVp5.drums.bpm
The tempo of the drum machine in beats per minute.
A beat is a quarter note, four steps, so one step lasts 60 / drumBpm / 4 seconds and one bar 240 / drumBpm: at 120 a bar takes 2 seconds. To change the tempo call startDrums(bpm): startDrums(drumBpm + 5) speeds up by five. Writing to drumBpm yourself changes nothing.
startDrums() keeps the tempo between 30 and 300; the slider on the grid goes from 60 to 180.
- Type
Number- Range
30..300
112 until you set another one. It follows startDrums() and the tempo slider on the grid.
Notes
- A sketch that declares its own variable called
drumBpmkeeps it: oav-p5 leaves the name alone and a card says to readOAVp5.drums.bpminstead.
Examples
function setup() {
createCanvas(400, 300);
startDrums('four on floor', 100);
textAlign(CENTER, CENTER);
textSize(32);
}
function keyPressed() {
if (keyCode === UP_ARROW) startDrums(drumBpm + 5);
if (keyCode === DOWN_ARROW) startDrums(drumBpm - 5);
}
function draw() {
background(20);
fill(255);
text(round(drumBpm) + ' bpm', width / 2, height / 2);
}Related
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.drumPhaseHow far through the current bar the drum machine is, smoothly from 0 up to just below 1, as it is heard.beatPhaseHow far through the current beat the drum machine is, smoothly from 0 up to just below 1, four times per bar.drumBarWhich bar the drum machine is in, counted from 1 when it started.