When experimenting with the example sketch provided at the following link, I noticed that I needed to click the run button in order for it to function properly:
However, when I copied the code and ran it locally on my localhost, there was no indication of a run button event to kickstart the sketch. What type of event should I use to initiate the sketch?
I believe this crucial information should be included in the sketch description to help users get started quickly. After attempting to find a solution using developer tools, I realized it would be more efficient to seek assistance directly.
let mic;
function setup() {
createCanvas(710, 200);
// Create an Audio input
mic = new p5.AudioIn();
// Start the Audio Input.
// By default, it does not .connect() (to the computer speakers)
mic.start();
}
function draw() {
background(200);
// Obtain the overall volume (ranging from 0 to 1.0)
let vol = mic.getLevel();
fill(127);
stroke(0);
// Display an ellipse with height based on volume
let h = map(vol, 0, 1, height, 0);
ellipse(width / 2, h - 25, 50, 50);
}