OAVp5.sound#
objectoav-p5OAVp5.sound
The object behind the sound names: the state, the instrument, the error, the loading progress and the loaded parts of @openav/sound.
OAVp5.sound (also reachable as midi.sound) is what startSound(), stopSound() and soundIsOn are built on. Read state to know where sound is, instrument for what you hear, status for the loading progress and error for a failure. start(id) and stop() are the same as the two global functions. shell, engine and module hand you the loaded @openav/sound parts for the rare case that you need them.
Notes
- For a sketch the global names are enough. This object is for tools, the console and debugging:
OAVp5.sound.stateis the first thing to look at when nothing is heard.
Examples
function setup() {
createCanvas(400, 300);
startSound('harp');
}
function draw() {
background(20);
fill(255);
const s = OAVp5.sound;
text('state: ' + s.state, 20, 30);
text('instrument: ' + s.instrument, 20, 60);
text('error: ' + s.error, 20, 90);
}Related
startSound()Makes the keys you play heard through an instrument you name, and returns a promise that says whether sound is on.stopSound()Turns sound off and lets every ringing note go; the instrument stays loaded, sostartSound()brings it back at once.soundIsOnWhether notes are being heard right now: true oncestartSound()has finished, false before and after.OAVp5.sound.stateWhere sound is:'off','waiting'(for a click),'loading','on'or'error'.OAVp5.sound.statusHow the instrument is loading:{ id, state, progress, error }, withprogressfrom 0 to 1.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.recordThe object behind the recording names: the state, the time, the last file, the formats this browser can write and the screenshot function.