p5((sketch) => {
let system;
sketch.setup = function () {
sketch.createCanvas(width, 600);
};
sketch.draw = function () {
sketch.background("#FFFFFF");
let from = sketch.color(218, 165, 0);
let to = sketch.color(72, 61, 139);
sketch.stroke(0);
const totalLength = sound.length;
for (var j = totalLength; j >= 0; j -= 3) {
sketch.rectMode(sketch.CENTER);
let ampl = sketch.map(sound[j], 0, maxAmplitude, 0, sketch.height / 2);
let interA = sketch.lerpColor(from, to, j / totalLength);
sketch.fill(interA);
sketch.rect(
sketch.map(j, 0, totalLength, 50, sketch.width - 50),
sketch.height / 2,
10,
ampl,
5,
5
);
}
};
})