open-audiovisual
Search GitHub

oav-p5 reference · Timeline, cues and score

OAVp5.drums.cue()#

functionoav-p5
OAVp5.drums.cue(bar, name, [every])

The same as cue(bar, name, every), but it returns the cue it made (or the one that was already there), and null when bar is not valid.

Use it when you want to hold on to the cue, for example to find out which step it fires at. For a plain plan, cue() is shorter. The list of every cue is OAVp5.drums.cues.

Parameters

NameTypeDescription
barNumberThe bar, counted from 1; 4.5 is halfway through bar 4. See cue().
nameAnyWhat to call the cue.
everyNumberRepeat every this many bars; 0 or left out: once. optional

Returns

Object | null The cue: { bar, name, every, at, period, key } with at and period counted in steps. null if bar is below 1 or not a number. A repeat of an earlier call gives back the cue that exists.

Examples

jsOpenProcessing ↗
let c = null;

function setup() {
  createCanvas(400, 300);
  startDrums('four on floor', 120);
  c = OAVp5.drums.cue(3.5, 'half', 4);
  textAlign(CENTER, CENTER);
}

function draw() {
  background(20);
  fill(255);
  text(c ? 'cue "' + c.name + '" at step ' + c.at + ', every ' + c.period + ' steps' : 'no cue', width / 2, height / 2);
}
Bar 3.5 is step 40 of the count, and "every 4 bars" is 64 steps.

Related

  • cue() Plans something for a bar: at bar bar the function cueFired(name, bar) is called and cueName becomes name; with every, again every that many bars.
  • OAVp5.drums.cues The list of every cue declared so far, in the order they were declared.
  • cueFired() An event you define: it is called when the bar of a cue declared with cue() has come, with the cue's name and the bar.

p5/oav-p5.js, line 1468

↑ Back to top · All names