summaryrefslogtreecommitdiff
path: root/tools/mq_editor/app.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/mq_editor/app.js')
-rw-r--r--tools/mq_editor/app.js4
1 files changed, 2 insertions, 2 deletions
diff --git a/tools/mq_editor/app.js b/tools/mq_editor/app.js
index 9b05789..dd0a24f 100644
--- a/tools/mq_editor/app.js
+++ b/tools/mq_editor/app.js
@@ -4,13 +4,13 @@
function k1ToHz(k, sr) {
if (k >= 1.0) return sr / 2;
const cosW = (2 - 2*k - k*k) / (2*(1 - k));
- return Math.acos(Math.max(-1, Math.min(1, cosW))) * sr / (2 * Math.PI);
+ return Math.acos(clamp(cosW, -1, 1)) * sr / (2 * Math.PI);
}
// HP: y[n] = k*(y[n-1]+x[n]-x[n-1]) => -3dB from peak at cos(w) = 2k/(1+k²)
function k2ToHz(k, sr) {
if (k >= 1.0) return 0;
const cosW = 2*k / (1 + k*k);
- return Math.acos(Math.max(-1, Math.min(1, cosW))) * sr / (2 * Math.PI);
+ return Math.acos(clamp(cosW, -1, 1)) * sr / (2 * Math.PI);
}
function fmtHz(f) {
return f >= 1000 ? (f/1000).toFixed(1) + 'k' : Math.round(f) + 'Hz';