<iframe src="https://editor.p5js.org/sofimoutafi/full/-zBcUMmb-"></iframe>
var sound;
let easing = 0.80;
let x = 10;
let y = 10;
function preload() {
sound = loadSound('Ham.mp3');
sound.loop();
}
function setup() {
createCanvas(windowWidth, windowHeight);
sound.play();
amp = new p5.Amplitude();
}
function draw() {
let vol = amp.getLevel();
let targetX = mouseX;
let dx = targetX - x;
x += dx * easing;
let targetY = mouseY;
let dy = targetY - y;
y += dy * easing;
if (sound.isPlaying() == true) { background(255, 0, 0);
}
else {
background(0, 0, 255);
}
sound.rate(map(mouseX, 0, width, 0.2, 5));
sound.setVolume(map(mouseY, 0, height, 0, 1));
ellipse(x, y, vol*500, vol*500);
fill(mouseX,67,mouseY);
console.log(vol)
}
function mousePressed() {
let fs = fullscreen();
fullscreen(!fs);
}
function windowResized() {
resizeCanvas(windowWidth, windowHeight);
}