I am having an issue getting my canvas to load when I am using the preload function with a sound. The code is producing a output that just says “Loading…” I think this is an issue with my index.html, but I’ve been trying to fix it on my own with no luck.
let sound;
function preload(){
play=loadSound("ADHD project1sound2")
}
function setup() {
let cnv = createCanvas(100, 100);
cnv.mousePressed(canvasPressed);
background(220);
text('tap here to play', 10, 20);
play=loadSound("ADHD project1sound2")
sound.play()
}
function canvasPressed(){
sound.play();
}
<!DOCTYPE html>
<html lang="en">
<head src="path/to/p5.sound.js">
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/p5.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/p5.js/1.1.9/addons/p5.sound.min.js"></script>
<link rel="stylesheet" type="text/css" href="style.css">
<meta charset="utf-8" />
</head>
<body>
<script src="sketch.js"></script>
</body>
</html>