javascript-piano icon indicating copy to clipboard operation
javascript-piano copied to clipboard

Loop replay takes a while to start

Open normanr opened this issue 5 years ago • 0 comments

If the loop is 10s long, then it only starts playing 10s after recordStop. This is because window.setInterval doesn't run the function immediately, but rather only after interval.

So I would recommend changing recordStop to have:

if (data.length) {
    loopInterval = window.setInterval(playLoop, totalTime, data);
    playLoop(data);
}

and remove the setInterval logic from playLoop, so that the loop is played as soon as the recording is stopped.

normanr avatar Jan 18 '21 23:01 normanr