Using a for with big numbers make the browser freeze or even crash. Is there a way to run these loops and not freezing the page?
Using Promisses, async functions maybe? How should i do that?
Exemple:
for(i=0; i<1000000000; i++){}
Im developing a MIDI player in a website, i need the precision that comes from the for
or the forEach
instead of adding one millesecond using setInterval
.
var renderTrack = (track, play) => {
track.notes.forEach(note=>{
if(play){
notesArr.push(setTimeout(()=>{
pianoPress(note.name + note.octave, note.velocity);
}))
}
})
}
MIDI.tracks.forEach(track=>{
renderTrack(track, true);
});