summaryrefslogtreecommitdiff
path: root/tools/mq_editor/editor.js
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-18 18:44:21 +0100
committerskal <pascal.massimino@gmail.com>2026-02-18 18:44:21 +0100
commiteff75e6d15eaebccec814b37504a6eeff53fb9e8 (patch)
tree6b57a7336bd40be09f58d3ef4a9fcf6e3aedfc05 /tools/mq_editor/editor.js
parent9b1439582853c24d240d1e62290f33809097bbe8 (diff)
feat(mq_editor): switch curve interpolation to Lagrange through all control points
Replace cubic Bezier with Lagrange interpolation so P1/P2 are actual points on the curve. Eval uses stored t1/t2 as arbitrary knot positions. fitBezier keeps least-squares but with Lagrange basis at u=1/3,2/3. Remove endpoint companion drag (no longer tangent handles). TODO: support arbitrary number of inner control points. handoff(Claude): Lagrange interpolation replaces Bezier in mq_editor curve eval/fit. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tools/mq_editor/editor.js')
-rw-r--r--tools/mq_editor/editor.js15
1 files changed, 2 insertions, 13 deletions
diff --git a/tools/mq_editor/editor.js b/tools/mq_editor/editor.js
index 0854ec0..a7d0879 100644
--- a/tools/mq_editor/editor.js
+++ b/tools/mq_editor/editor.js
@@ -25,8 +25,7 @@ class PartialEditor {
// Private state
this._selectedIndex = -1;
- this._dragPointIndex = -1;
- this._dragCompanionOff = null; // {dt, dv} offset of companion handle relative to anchor
+ this._dragPointIndex = -1;
this._amp = { tMin: 0, tMax: 1, ampTop: 1 };
this._setupButtons();
@@ -496,12 +495,7 @@ class PartialEditor {
for (let i = 0; i < 4; ++i) {
if (Math.hypot(this._tToX(curve['t' + i]) - x, this._ampToY(curve['a' + i]) - y) <= 8) {
if (this.onBeforeChange) this.onBeforeChange();
- this._dragPointIndex = i;
- this._dragCompanionOff = null;
- if (i === 0)
- this._dragCompanionOff = { da: curve.a1 - curve.a0 };
- else if (i === 3)
- this._dragCompanionOff = { da: curve.a2 - curve.a3 };
+ this._dragPointIndex = i;
canvas.style.cursor = 'grabbing';
e.preventDefault();
return;
@@ -516,11 +510,6 @@ class PartialEditor {
const curve = this.partials[this._selectedIndex].freqCurve;
const i = this._dragPointIndex;
curve['a' + i] = Math.max(0, this._yToAmp(y));
- if (this._dragCompanionOff) {
- const off = this._dragCompanionOff;
- if (i === 0) { curve.a1 = curve.a0 + off.da; }
- else { curve.a2 = curve.a3 + off.da; }
- }
this._renderAmpEditor();
if (this.viewer) this.viewer.render();
e.preventDefault();