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);

    • Jul 11 2017 | 11:22 am
      Using java script to copy buffers is no option for real time looping. Try a better concept for looping, overdubbing etc
    • Jul 12 2017 | 6:22 am
      Will do. Working in gen~ now. There is nothing wrong with the audio, I used a trick for this. It is just that the gui is freezing, is there a way that this is not happening? Or why is this happening?
      Thanks again ;)
    • Jul 12 2017 | 7:11 am
      Problem is certainly that copying between buffers runs in high priority thread, and thus may interrupt whatever GUI elements. But I can't give You an advice, what would be better with so sparse infos on what exactly happens with recording, cutting, resizing, copying etc. When it comes to buffer manipulation, there are quite a few options, it all depends on Looper design. Mr Eric Lyon created the best tool ever for copying, mixing and many other buffer manipulations as part of putpourri library. The specific object is el.buffet. There where some attempts to create buffer coping in gen, but never worked properly.
    • Jul 12 2017 | 7:42 am
      Hmm, I am aware of el.buffet, it doesn't work on Windows unfortunately. Since I had so many struggles with overdubbing, using poke, ipoke, etc, I went the direction of copying buffers. Not ideal indeed. Do you think a simple phaser synced, non variable speed overdub can be easily achieved in gen~ ? All my earlier attempts with gen resulted in audio clicks and drop outs. But if Poke is reliable in gen, I want to give it a shot anyway.
      There is is no need for infinite overdubs. 20 times with a max of 20s is big enough.
      A point that we have to take in account is that when not in recording or overdubbing mode, I am able to stretch the buffer with stretch~. could this cause some problems with poke later on? I am not having any issues with my js copy variation at the moment, since it writes the interpolated samples within the object, so no weird ipoke is needed I presume.
      it is good to be in touch with you again.
    • Jul 12 2017 | 8:49 am
      I never had any problems with overdubs in max, whatever objects were used, groove/record combo or index/poke, pokef, xsample objects etc, etc Copying buffers was needed only if undo is desired, deleting the previous overdub, in case of a mistake or similar. But Record / Playback heads need to be set latency compensated... But now to the looper, what is the structure of the loop ? You record free and then want to have separate buffers of same length to place overdub generations in them ? Or what exactly ? There is a simple way of copying buffers by message set "buffer xy", set back to original buffername, crop etc