OAVp5.drums.now#
objectoav-p5OAVp5.drums.now
A snapshot of what the machine hears right now: the bar, the step, both phases and which words of the line are lit.
It is what the card uses to light the word that sounds. Read it when you want the line and its lit words in one go, for example to draw the line on the canvas with the sounding word marked. Before the machine has loaded it answers with zeros and an empty text.
- Type
Object- Range
{ bar, step, phase, beatPhase, tokens, mode, text }
A new object on every read. phase and beatPhase are drumPhase and beatPhase. tokens is a list of { start, end }: the places in text of the words that sound now. mode is 'string' for a line of rhythm and 'grid' for a preset or a grid you drew. text is the line.
Examples
function setup() {
createCanvas(400, 300);
startDrums('bd*4, [~ sd]*2, hh*8', 80);
textFont('monospace');
textSize(18);
noStroke();
}
function draw() {
background(20);
const n = OAVp5.drums.now;
fill(255, 211, 107);
for (const t of n.tokens) {
rect(20 + textWidth(n.text.slice(0, t.start)), 150, textWidth(n.text.slice(t.start, t.end)), 3); // underline the sounding words
}
fill(255);
text(n.text, 20, 140);
}Related
OAVp5.drums.srcThe line of rhythm that plays now, such as'bd*4, [~ sd]*2, hh*8'; an empty string until the machine has loaded.drumPhaseHow far through the current bar the drum machine is, smoothly from 0 up to just below 1, as it is heard.beatPhaseHow far through the current beat the drum machine is, smoothly from 0 up to just below 1, four times per bar.drumStepWhich of the 16 steps of the bar the drum machine just played, from 0 to 15.drumBarWhich bar the drum machine is in, counted from 1 when it started.