Skip to content

Instantly share code, notes, and snippets.

@tdhooper
Last active August 29, 2015 14:07
Show Gist options
  • Save tdhooper/81eade7000121b8cd3a5 to your computer and use it in GitHub Desktop.
Save tdhooper/81eade7000121b8cd3a5 to your computer and use it in GitHub Desktop.
wavepot reverse
var lastLog = 0;
function logMessage(m) {
var now = Date.now();
var timeSinceLast = now - lastLog;
if (timeSinceLast < 500) {
return false;
}
console.log(m);
lastLog = now;
}
var tLast = 0;
var tAdjustLast = 0;
function clockDiff(_t) {
if (_t === 0) {
tLast = 0;
}
var diff = _t - tLast;
tLast = _t;
return diff;
}
function clockAdjust(_t) {
var diff = clockDiff(_t);
var reverse = false;
if (_t % 20 < 6) {
reverse = true;
}
logMessage(reverse);
var tAdjust;
if (reverse) {
tAdjust = tAdjustLast - diff;
} else {
tAdjust = tAdjustLast + diff;
}
if (tAdjust < 0) {
return 0;
}
tAdjustLast = tAdjust;
return tAdjustLast;
}
function clock(_t){
t = clockAdjust(_t);
t *= bpm / 120;
tt = tau * t;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment