From bc07ea00a9f2f418e6b460884c3925b72ff2a358 Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 18 Feb 2026 16:22:54 +0100 Subject: 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 --- tools/mq_editor/utils.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'tools/mq_editor/utils.js') 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(); -- cgit v1.2.3