Skip to content

Commit

Permalink
fixed ta' tb' calculation for loop modifier buttons
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Grahn committed Dec 6, 2023
1 parent cde95bc commit d87e817
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 25 deletions.
34 changes: 9 additions & 25 deletions js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -600,51 +600,35 @@ var updateLoopUI=function(updateSlider=true){
}
}

var compDeltaByBeat=function(d, b){
return b*Math.round(d/b);
}

var onLoopBackwards=function(){
let dt=timeB-timeA;
if(beatNormal) {
dt=compDeltaByBeat(dt, beatNormal);
}
if(timeA-dt<0) return;
timeA-=dt;
timeB-=dt;
if(timeA-tLavg-dt<0) return;
timeB=timeA-tLavg;
timeA=timeB-dt;
loopMeas.splice(0);
updateLoopUI();
}

var onLoopHalve=function(){
let dt=timeB-timeA;
if(beatNormal) {
dt=compDeltaByBeat(dt, beatNormal);
}
timeB-=dt/2;
timeB=timeA+(dt-tLavg)/2;
loopMeas.splice(0);
updateLoopUI();
}

var onLoopDouble=function(){
let dt=timeB-timeA;
if(beatNormal) {
dt=compDeltaByBeat(dt, beatNormal);
}
if(timeB+dt>getDuration()) return;
timeB+=dt;
if(timeB+tLavg+dt>getDuration()) return;
timeB+=tLavg+dt;
loopMeas.splice(0);
updateLoopUI();
}

var onLoopForwards=function(){
let dt=timeB-timeA;
if(beatNormal) {
dt=compDeltaByBeat(dt, beatNormal);
}
if(timeB+dt>getDuration()) return;
timeA+=dt;
timeB+=dt;
if(timeB+tLavg+dt>getDuration()) return;
timeA=timeB+tLavg;
timeB=timeA+dt;
loopMeas.splice(0);
updateLoopUI();
}
Expand Down
Binary file modified zip/ABLoopPlayer.zip
Binary file not shown.

0 comments on commit d87e817

Please sign in to comment.