All I want to do is push an array of numbers into another array and then reference those numbers to make a calculation. Something is wrong. The splice just removes the last array from the bunch. This is an example of what I want it to do that I did after I posted. Unfortunately this method is not working in my main program. I don’t understand what the problem is. Passing an array into another array should be fine to do, as it’s an object. Not sure why this second example works by putting the array inside an object, and then I have to use something like sampleBuffer[0].band[x]. Maybe I need to make a 2d array. I’ve never had such an annoying problem in p5.
var sampleBuffer=[];
var bandsEnergy=[];
function setup() {
}
function draw() {
for(let i=0; i<3; i++) {
bandsEnergy[i] = random(10);
}
var b = { band: bandsEnergy };
sampleBuffer.push(b);
if(sampleBuffer.length==32) {
//console.log(sampleBuffer);
sampleBuffer.splice(0,1);
}
console.log(sampleBuffer);
// console.log(sampleBuffer[0].band.length);
}