open-audiovisual
Search GitHub

oav-p5 reference · Drum machine and rhythm

stopDrums()#

functionoav-p5
stopDrums()

Also: OAVp5.drums.stop

Stops the drum machine and hides its card.

The machine stops playing, the grid disappears and drumsAreOn becomes false. The numbers keep the last value they had: drumStep, drumBar and cueName stay where they were, and drumPhase and beatPhase hold still. startDrums() afterwards begins again from bar 1.

It also works while the machine is still loading: the pending startDrums() then resolves to false. The × on the card does the same thing.

Returns

Promise<Boolean> A promise that is already resolved to false, the new state of the machine.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
  startDrums('four on floor', 120);
  textAlign(CENTER, CENTER);
}

function mousePressed() {
  stopDrums();
}

function draw() {
  background(drumsAreOn ? 40 : 100);
  fill(255);
  text(drumsAreOn ? 'click to stop the drums' : 'stopped at step ' + drumStep, width / 2, height / 2);
}
Click the canvas: the grid disappears, the background turns light and the text shows the step it stopped on.

To be confirmed

After stopDrums() and a second startDrums() on the same page the machine plays and counts again, but drumsAreOn and OAVp5.drums.state stayed false and 'off' when this was tried (Chromium, oav-p5 0.8.0). Whether that is intended is not confirmed.

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.
  • drumsAreOn Whether the drum machine is playing right now.
  • stopSound() Turns sound off and lets every ringing note go; the instrument stays loaded, so startSound() brings it back at once.

p5/oav-p5.js, line 1761

↑ Back to top · All names