open-audiovisual
Search GitHub

oav-p5 reference · Timeline, cues and score

cueName#

variableoav-p5
cueName

Also: OAVp5.drums.lastCue

The name of the last cue that fired, or an empty string before the first one.

Read it in draw() instead of waiting for cueFired(): look = SCENES[cueName];. It is the name of the last cue only, so it is the right thing for "which scene am I in", and cueFired() is the right thing for "something just began". Cues are declared with cue().

Type
String
Range
'' or a cue name

Changes when a cue fires, and keeps the name until the next one. It is '' at the start.

Notes

  • A sketch that declares its own variable called cueName keeps it: oav-p5 leaves the name alone and a card says to read OAVp5.drums.lastCue instead.

Examples

jsOpenProcessing ↗
const SCENES = { calm: '#3b5bdb', bloom: '#e64980', storm: '#495057' };

function setup() {
  createCanvas(400, 300);
  startDrums('breakbeat', 150);
  cue(1, 'calm', 6);
  cue(3, 'bloom', 6);
  cue(5, 'storm', 6);
  textAlign(CENTER, CENTER);
  textSize(32);
}

function draw() {
  background(SCENES[cueName] || '#111');   // nothing yet: dark
  fill(255);
  text(cueName, width / 2, height / 2);
}
The background and the word follow the last cue: blue "calm", pink "bloom", grey "storm", every six bars.

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.
  • 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.
  • drumBar Which bar the drum machine is in, counted from 1 when it started.
  • 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 317

↑ Back to top · All names