If you are hoping for an array of 32 inner arrays, where the inner arrays each contain three random numbers, and where the inner arrays differ from each other, this will do it:
let sampleBuffer=[];
let bandsEnergy=[];
function setup() {
}
function draw() {
for(let i=0; i<3; i++) {
bandsEnergy[i] = random(10);
}
sampleBuffer.push(bandsEnergy.slice(0, 3));
if(sampleBuffer.length==32) {
noLoop();
console.log(sampleBuffer);
}
}
After testing this, you can remove the call to the noLoop
function.
But perhaps we are mistaken regarding what you are trying to do. If so, please clarify it for us
EDIT (August 5, 2021):
Perhaps the following example can help:
let sampleBuffer=[];
let bandsEnergy=[];
function setup() {
createCanvas(400, 500);
for (let i=0; i<20; i++) {
for (let j=0; j<3; j++) {
bandsEnergy[j] = random(10);
}
sampleBuffer.push(bandsEnergy.slice(0, 3));
}
frameRate(10);
}
function draw() {
background(255);
for (let j=0; j<3; j++) {
bandsEnergy[j] = random(10);
}
for (let i=0; i<sampleBuffer.length; i++) {
text(sampleBuffer[i], 10, i * 20 + 20);
}
sampleBuffer.push(bandsEnergy.slice(0, 3));
sampleBuffer.splice(0,1);
}
Image capture:
Please let us know how it works out.