OAVp5.sound.instrument#
variableoav-p5OAVp5.sound.instrument
The id of the instrument you hear right now, or null before sound has loaded.
After a first startSound('piano') the piano's samples (about 2 MB) download first, and the electric piano plays meanwhile, so the first key is never silent: instrument says 'epiano' until the piano is ready and 'piano' after. When you switch to the piano from another instrument, that one keeps sounding and instrument names it until the samples are in. How far the loading is, and which instrument it is on, is in OAVp5.sound.status.
- Type
String | null
Changes when the instrument changes, which for a sampled instrument is when its samples are in.
Examples
function setup() {
createCanvas(400, 300);
startSound('piano');
textAlign(CENTER, CENTER);
}
function draw() {
background(20);
fill(255);
text(OAVp5.sound.instrument || 'nothing loaded yet', width / 2, height / 2);
}Related
startSound()Makes the keys you play heard through an instrument you name, and returns a promise that says whether sound is on.OAVp5.sound.statusHow the instrument is loading:{ id, state, progress, error }, withprogressfrom 0 to 1.OAVp5.sound.stateWhere sound is:'off','waiting'(for a click),'loading','on'or'error'.