javascript-piano
javascript-piano copied to clipboard
Loop replay takes a while to start
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.