open-audiovisual
Search GitHub

oav-p5 reference · Loading options

tone#

optionoav-p5
?oav_tone=an ES module URL

Where Tone.js, the sound engine behind startSound(), is loaded from: an ES module address. Empty means jsDelivr.

Sound (startSound(), the sound option, the 🔊 button) uses Tone.js 15, which oav-p5 loads the first time sound is wanted. By default it comes from jsDelivr. Point tone at your own copy when the page is behind a school firewall or an ad blocker that stops the CDN, or when you serve everything yourself. If it cannot be loaded, a card says which host was unreachable and what to try.

Type
String (URL)
Values
an ES module URL
default
'' (jsDelivr)

The address of Tone.js version 15 as an ES module. Left empty, it is https://cdn.jsdelivr.net/npm/tone@15.0.4/+esm, and OAVp5.options.tone reads ''.

Notes

  • Set it before oav-p5 loads. window.OAV_P5 = { tone: … }; above the loader line wins, then ?oav_tone=… on the page address, then ?tone=… on the script's own URL. Values in window.OAV_P5 are turned into text, so write 'off', not false. On OpenProcessing the page address takes ?sketch_oav_tone=… (the project's README says OpenProcessing forwards it to the sketch).

Examples

jsOpenProcessing ↗
window.OAV_P5 = { tone: 'https://cdn.jsdelivr.net/npm/tone@15.0.4/+esm' };

function setup() {
  createCanvas(400, 300);
}

function draw() {
  background(20);
  fill(255);
  text('Tone.js from: ' + OAVp5.options.tone, 20, 30);   // the address here is the built-in one
}
Prints where Tone.js would come from. The address here is the built-in one, so nothing changes. Swap in your own copy to host it yourself.

Related

  • sound Whether notes are heard: click (only after startSound() or 🔊), off (never), or an instrument id that starts at the first click.
  • 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 130

↑ Back to top · All names