diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-18 21:36:07 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-18 21:36:07 +0100 |
| commit | f48397c58248ca338c258b1de762314926fe681f (patch) | |
| tree | 219ddcc63f1600ae5604d655bb4c6faabd91ca33 /tools/mq_editor/mq_synth.js | |
| parent | eeecb76eef15f684b7909ff22fd054680c2a3498 (diff) | |
feat(mq_editor): movable inner bezier control points + clamp() refactor
- P1/P2 in amp editor now draggable horizontally; t0<t1<t2<t3 enforced
- Add clamp() to utils.js; replace all Math.max/min clamping patterns
- Cursor hints: move for P1/P2, ns-resize for P0/P3
- Remove test_fft.html
- Docs: Delete key, style.css/utils.js in architecture, bezier editor section
handoff(Claude): inner control points done, clamp() adopted everywhere
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tools/mq_editor/mq_synth.js')
| -rw-r--r-- | tools/mq_editor/mq_synth.js | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/mq_editor/mq_synth.js b/tools/mq_editor/mq_synth.js index 00867a9..a9f387c 100644 --- a/tools/mq_editor/mq_synth.js +++ b/tools/mq_editor/mq_synth.js @@ -42,8 +42,8 @@ function synthesizeMQ(partials, sampleRate, duration, integratePhase = true, opt // r controls pole radius (bandwidth): r→1 = narrow, r→0 = wide. // gainNorm = sqrt(1 - r²) normalises steady-state output power to ~A. const res = partial.resonator || {}; - const r = options.forceRGain ? Math.min(0.9999, Math.max(0, options.globalR)) - : (res.r != null ? Math.min(0.9999, Math.max(0, res.r)) : 0.995); + const r = options.forceRGain ? clamp(options.globalR, 0, 0.9999) + : (res.r != null ? clamp(res.r, 0, 0.9999) : 0.995); const gainComp = options.forceRGain ? options.globalGain : (res.gainComp != null ? res.gainComp : 1.0); const gainNorm = Math.sqrt(Math.max(0, 1.0 - r * r)); @@ -131,7 +131,7 @@ function synthesizeMQ(partials, sampleRate, duration, integratePhase = true, opt // LP: y[n] = k1*x[n] + (1-k1)*y[n-1] — options.k1 in (0,1], omit to bypass // HP: y[n] = k2*(y[n-1] + x[n] - x[n-1]) — options.k2 in (0,1], omit to bypass if (options.k1 != null) { - const k1 = Math.max(0, Math.min(1, options.k1)); + const k1 = clamp(options.k1, 0, 1); let y = 0.0; for (let i = 0; i < numSamples; ++i) { y = k1 * pcm[i] + (1.0 - k1) * y; @@ -139,7 +139,7 @@ function synthesizeMQ(partials, sampleRate, duration, integratePhase = true, opt } } if (options.k2 != null) { - const k2 = Math.max(0, Math.min(1, options.k2)); + const k2 = clamp(options.k2, 0, 1); let y = 0.0, xp = 0.0; for (let i = 0; i < numSamples; ++i) { const x = pcm[i]; |
