cueName#
variableoav-p5cueNameAlso: 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
cueNamekeeps it: oav-p5 leaves the name alone and a card says to readOAVp5.drums.lastCueinstead.
Examples
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);
}Related
cue()Plans something for a bar: at barbarthe functioncueFired(name, bar)is called andcueNamebecomesname; withevery, again every that many bars.cueFired()An event you define: it is called when the bar of a cue declared withcue()has come, with the cue's name and the bar.drumBarWhich 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.