diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-18 16:22:54 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-18 16:22:54 +0100 |
| commit | bc07ea00a9f2f418e6b460884c3925b72ff2a358 (patch) | |
| tree | 01b297108d78d42a3f1ddefe6ff3e5ba8aa0dea3 /tools/mq_editor/utils.js | |
| parent | e6605b8d30d1e284f317313421e8f46af48640e6 (diff) | |
refactor(mq_editor): unify freq+amp into single bezier curve
freqCurve now carries a0-a3 (amplitude control values) alongside
v0-v3 (frequency). Both components share the same t0-t3 time
parameterization. evalBezierAmp() added to utils.js.
ampCurve removed from partials and synth pipeline.
Amp panel drag now changes only a_i; t is read-only (shared with freq).
handoff(Claude): unified freq/amp bezier done
Diffstat (limited to 'tools/mq_editor/utils.js')
| -rw-r--r-- | tools/mq_editor/utils.js | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/tools/mq_editor/utils.js b/tools/mq_editor/utils.js index c38b1f5..96d807c 100644 --- a/tools/mq_editor/utils.js +++ b/tools/mq_editor/utils.js @@ -13,6 +13,19 @@ function evalBezier(curve, t) { u*u*u * curve.v3; } +// Evaluate amplitude component of unified bezier curve at time t +function evalBezierAmp(curve, t) { + const dt = curve.t3 - curve.t0; + if (dt <= 0) return curve.a0; + let u = (t - curve.t0) / dt; + u = Math.max(0, Math.min(1, u)); + const u1 = 1.0 - u; + return u1*u1*u1 * curve.a0 + + 3*u1*u1*u * curve.a1 + + 3*u1*u*u * curve.a2 + + u*u*u * curve.a3; +} + // Get canvas-relative {x, y} from a mouse event function getCanvasCoords(e, canvas) { const rect = canvas.getBoundingClientRect(); |
