well i guess i find it myself but its seems weird
let song = [];
function setup() {
song[0] = loadSound('sample1.mp3');
song[1] = loadSound('sample1.mp3');
createCanvas(720, 200);
background(255, 0, 0);
}
function mousePressed() {
for (let index = 0; index < song.length; index++) {
song[index].playMode('untilDone');
song[index].play();
song[index].onended(stop)
console.log(index)
function stop()
{
if(index+1<song.length){
setTimeout(() => { song[index+1].play(); }, 1000/4);
;
}
}
}
}