summaryrefslogtreecommitdiff
path: root/client/lib/util.js
diff options
context:
space:
mode:
authorjulian laplace <julescarbon@gmail.com>2025-07-07 19:54:02 +0200
committerjulian laplace <julescarbon@gmail.com>2025-07-07 19:54:02 +0200
commitdfbd36be4341f633cb51d187d3245efbc9d500a8 (patch)
tree15a1006ba51a9c4b2773161bae888cc0522fcdff /client/lib/util.js
parent95a494a5570ba7933943cfe2093f1357c5f087f4 (diff)
transitions, fix colors, add help
Diffstat (limited to 'client/lib/util.js')
-rw-r--r--client/lib/util.js15
1 files changed, 10 insertions, 5 deletions
diff --git a/client/lib/util.js b/client/lib/util.js
index 5bf93dc..d0a3914 100644
--- a/client/lib/util.js
+++ b/client/lib/util.js
@@ -23,10 +23,13 @@ function choice(a) {
function mod(n, m) {
return n - m * Math.floor(n / m);
}
-function roundFreq(freq) {
- return Math.round(freq * 100);
+function roundInterval(interval) {
+ return Math.round(interval * 10000000);
}
-const frequencyInRange = (freq) => 20 < freq && freq < 15000;
+const intervalInRange = (interval, root) =>
+ 20 < interval * root && interval * root < 15000;
+const lerp = (n, a, b) => (b - a) * n + a;
+const clamp = (n, a = 0, b = 1) => (n < a ? a : n < b ? n : b);
function requestAudioContext(fn) {
if (window.location.protocol !== "https:") {
@@ -75,7 +78,9 @@ export {
choice,
mod,
browser,
- roundFreq,
- frequencyInRange,
+ lerp,
+ clamp,
+ roundInterval,
+ intervalInRange,
requestAudioContext,
};