open-audiovisual
Search GitHub

oav-p5 reference · The OAVp5 object (advanced)

OAVp5.sound.shell#

variableoav-p5
OAVp5.sound.shell

Also: OAVp5.sound.engine OAVp5.sound.module

The loaded parts of @openav/sound: the Sound shell, its Tone.js engine and the module itself. All three are null until sound has loaded.

OAVp5.sound.shell is the Sound instance of @openav/sound, OAVp5.sound.engine is the Tone.js engine it plays through (noteOn, noteOff, sustain, releaseAll, setInstrument) and OAVp5.sound.module is the whole module, for example OAVp5.sound.module.listInstruments(), which lists every instrument id. They are advanced handles: the sketch-level names (startSound(), soundIsOn) cover everything a sketch normally needs.

Type
Object | null

Set once, when startSound() has loaded @openav/sound (the engine and the shell at the same moment, the module a little before). null before that, and after a failed load.

Before it has a value

Call startSound() first and wait until OAVp5.sound.state is no longer 'loading', or check for null before you use them.

Examples

jsOpenProcessing ↗
let ids = [];

function setup() {
  createCanvas(400, 300);
  startSound('synth/pluck');
}

function draw() {
  background(20);
  fill(255);
  textSize(12);
  if (!ids.length && OAVp5.sound.module) ids = OAVp5.sound.module.listInstruments().map((d) => d.id);
  text(ids.length ? ids.join(', ') : 'loading…', 20, 20, width - 40, height - 40);
}
Lists every instrument id that startSound() accepts, as soon as the module has loaded.

Related

  • OAVp5.sound The object behind the sound names: the state, the instrument, the error, the loading progress and the loaded parts of @openav/sound.
  • startSound() Makes the keys you play heard through an instrument you name, and returns a promise that says whether sound is on.
  • OAVp5.sound.state Where sound is: 'off', 'waiting' (for a click), 'loading', 'on' or 'error'.

p5/oav-p5.js, line 1347

↑ Back to top · All names