open-audiovisual
Search GitHub

oav-p5 reference · Sound and instruments

OAVp5.sound.error#

variableoav-p5
OAVp5.sound.error

The message of the last thing that went wrong while loading sound, or null when nothing has.

It is the error the browser reported when @openav/sound or Tone.js could not be loaded. A card beside the 🎹 already tells the person at the keyboard what to do (try another network, or point the tone option at another copy of Tone.js); read this value to log it or to show your own message. To know whether sound is failing right now, use OAVp5.sound.state, not this.

Type
String | null

Set when the state becomes 'error'. It stays until the page is reloaded: a later try that works does not clear it.

Examples

jsOpenProcessing ↗
function setup() {
  createCanvas(400, 300);
  startSound('strings');
  textAlign(CENTER, CENTER);
}

function draw() {
  background(OAVp5.sound.error ? color(120, 30, 30) : 20);
  fill(255);
  text(OAVp5.sound.error ? OAVp5.sound.error : 'no error', width / 2, height / 2);
}
Stays on "no error" when sound loads; if Tone.js cannot be reached the background turns red and the message is printed.

Related

  • OAVp5.sound.state Where sound is: 'off', 'waiting' (for a click), 'loading', 'on' or 'error'.
  • startSound() Makes the keys you play heard through an instrument you name, and returns a promise that says whether sound is on.
  • soundIsOn Whether notes are being heard right now: true once startSound() has finished, false before and after.

p5/oav-p5.js, line 1347

↑ Back to top · All names