Copying buffers with js freezes the max gui
Jul 10 2017 | 9:13 pm
I have built a looper where I can record my overdubs in one buffer and after this overdub recording that buffer gets cut in portions as big as my main buffer. The audio in my patch continues, but the whole gui freezes for multiple seconds. Is there a way to do this more efficient?
My maximum recording time is 30s and my maximum amount of overdubs is 20. This comes to 600s in total. I understand this is a lot. But still even with 2 seconds of audio and maybe 3 overdubs, my gui freezes at least a second.
I am quite new to js.
and this is the code:
var overbuf = new Buffer("overdub")
var destinationbuf = new Buffer("dubresult")
outlets = 1;
function list(nrofdubs, amount, delay)
{
var dubzL = new Array(amount);
var dubzR = new Array(amount);
for(i=0;i<amount;i++){ //add dubs
dubzL[i] = 0;
dubzR[i] = 0;
for(j=0;j<nrofdubs;j++){
dubzL[i] += overbuf.peek(1,j*amount+(i-delay),1);
dubzR[i] += overbuf.peek(2,j*amount+(i-delay),1);
}
}
destinationbuf.poke(1,0,dubzL);
destinationbuf.poke(2,0,dubzR);
outlet(0,"bang");
}