open-audiovisual
Search GitHub

oav-p5 reference · Drum machine and rhythm

OAVp5.drums.pattern#

variableoav-p5
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.

After startDrums('breakbeat') it is 'breakbeat', after startDrums({ kick: 'x...x...x...x...' }) it is 'custom', and after startDrums('bd*4, hh*8') it is that line. A click on a cell of a preset makes it 'custom'. To get the line of rhythm in every case, read OAVp5.drums.src: a preset also has one.

Type
String

'four on floor' until you choose another. It follows what plays, including clicks on the grid.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
  startDrums('breakbeat', 110);
  textAlign(CENTER, CENTER);
  textSize(24);
}

function draw() {
  background(20);
  fill(255);
  text(OAVp5.drums.pattern, width / 2, height / 2);
}
Shows "breakbeat"; click a cell of the grid and it turns into "custom".

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.
  • 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.
  • rhythmChanged() An event you define: it is called with the new line of rhythm every time the rhythm changes.

p5/oav-p5.js, line 1466

↑ Back to top · All names