Last active
August 29, 2015 14:07
-
-
Save tdhooper/81eade7000121b8cd3a5 to your computer and use it in GitHub Desktop.
wavepot reverse
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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