OAVp5.drums.machine#
variableoav-p5OAVp5.drums.machine
The drum machine from @openav/drums that the grid on the page belongs to, or null before it has loaded.
It is what mountDrums() of @openav/drums returns, with seq (the sequencer), engine (the kit), play(on), setPattern(p), setBpm(bpm), phase(), now(), info() and the rhythm functions. OAVp5.drums.machine.play(false) stops the sound and the counting but leaves the grid up: OAVp5.drums.state then says 'stopped'. It is an advanced handle; the names on this page cover what a sketch normally needs.
- Type
Object | null
Set once, when startDrums() has loaded the machine. null before that and after a failed load.
Before it has a value
It is null until startDrums() (or 🥁) has loaded the machine. Check for null before you use it.
Examples
function setup() {
createCanvas(400, 300);
startDrums('four on floor', 120);
textAlign(CENTER, CENTER);
}
function mousePressed() {
const m = OAVp5.drums.machine;
if (m) m.play(!m.seq.playing); // pause and resume, the grid stays
}
function draw() {
background(OAVp5.drums.state === 'stopped' ? 80 : 20);
fill(255);
text('click to pause or resume (' + OAVp5.drums.state + ')', width / 2, height / 2);
}Related
OAVp5.drumsThe object behind the drum names: the state of the machine, its counters, the line of rhythm, its history and the loaded machine.OAVp5.drums.stateWhere the drum machine is:'off','loading','on','stopped'or'error'.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.