open-audiovisual
Search GitHub

oav-p5 reference · Drum machine and rhythm

OAVp5.drums.src#

variableoav-p5
OAVp5.drums.src

The line of rhythm that plays now, such as 'bd*4, [~ sd]*2, hh*8'; an empty string until the machine has loaded.

Show it on the canvas so a recording has it (text(OAVp5.drums.src, 20, 30)), or keep it to come back to the rhythm later with startDrums(src). rhythmChanged() tells you when it changes, and OAVp5.drums.copyText is the same line wrapped in a startDrums("…") call.

Type
String

Read fresh each time. A preset or a grid you drew shows as the line it is written as, and it changes with every click on a cell and every typed edit.

Before it has a value

It is '' until startDrums() has loaded the machine and the rhythm module, a fraction of a second.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
  startDrums('half time', 100);
  textAlign(CENTER, CENTER);
}

function draw() {
  background(20);
  fill(255);
  text(OAVp5.drums.src || 'loading…', width / 2, height / 2);
}
The preset "half time" written as the line of rhythm it is; click cells on the grid and the line is rewritten.

Related

  • OAVp5.drums.pattern What the drum machine plays, as a name: the preset's name, 'custom' for a grid, or the line of rhythm itself.
  • OAVp5.drums.copyText The text the Copy button on the card puts on the clipboard: the rhythm that plays now as a ready startDrums("…", bpm) call.
  • OAVp5.drums.edit() Plays a line of rhythm as if it was typed on the card, and returns whether it worked and, if not, what is wrong with it.
  • rhythmChanged() An event you define: it is called with the new line of rhythm every time the rhythm changes.
  • 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.

p5/oav-p5.js, line 1486

↑ Back to top · All names