The program Im making uses the p5 library. The sound works in the repl site but doesn’t work in the actual website.
Heres the code:
let timeElapsed = 0;
let c1,c2;
let noiseScale=0.0045;
var moon
let w, h, x, y, lag;
let trx, trry, tlx, tly, brx, bry, blx, bly;
var background;
function preload()
{
moon = loadImage("moon.svg");
background = loadSound("Lofi.mp3");
}
function setup()
{
createCanvas(windowWidth,windowHeight)
frameRate(100);
w = width/2;
h = height/2;
x = width/2;
y = height/2;
lag = 10;
noCursor();
background.play();
}
function draw()
{
timeElapsed++;
//237, 187, 85(c1)
//207, 143, 203(c2)
c1 = color(138, 65, 121);
c2 = color(227, 127, 144);
for(let y=0; y<height; y++){
n = map(y,0,height,0,1);
let newc = lerpColor(c1,c2,n);
stroke(newc);
line(0,y,width, y);
}
image(moon,width-170,60,250,200);
for (let x=0; x < width; x++) {
let noiseVal = noise((mouseX+x)*noiseScale,
10*noiseScale);
stroke(245);
line(x, 300+noiseVal*650, x, height);
}
noStroke();
fill(255);
rect (0, height-65, width, 65);
x += (mouseX-x)/lag
y += (mouseY-y)/lag
circle(x, y, 30);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}