summaryrefslogtreecommitdiff
path: root/tools/mq_editor/utils.js
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-18 22:59:15 +0100
committerskal <pascal.massimino@gmail.com>2026-02-18 22:59:15 +0100
commitcd771a49d1d59b1403ef7f358398fa2f0f646cc4 (patch)
tree512ca89f54e3a92f65f7d1a7c51193c461f5c23a /tools/mq_editor/utils.js
parent080f457040ca54256325b922ebd67cde5c0dc030 (diff)
feat(mq_editor): replace replicas with harmonics model
- Fundamental f0 always synthesized; harmonics added at n*freq_mult - decay^n amplitude rolloff per harmonic (capped at 0.90) - Resonator mode also expanded across harmonics (per-harmonic y1/y2 state) - UI: h.decay, h.freq (default 2.0), jitter, spread↑/↓ params - Viewer: faint dotted harmonic bands with spread visualization - Default freq_mult=2.0 (natural harmonic series) handoff(Gemini): harmonics model complete, ready for next task Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tools/mq_editor/utils.js')
-rw-r--r--tools/mq_editor/utils.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/tools/mq_editor/utils.js b/tools/mq_editor/utils.js
index ed34b8e..7ab274e 100644
--- a/tools/mq_editor/utils.js
+++ b/tools/mq_editor/utils.js
@@ -55,16 +55,29 @@ function getCanvasCoords(e, canvas) {
// Build upper/lower band point arrays for a frequency curve.
// factorAbove/factorBelow are fractional offsets (e.g. 0.02 = ±2%).
+// freqMult: optional frequency scaling for harmonics (default 1.0).
// Returns { upper: [[x,y],...], lower: [[x,y],...] }
-function buildBandPoints(viewer, curve, factorAbove, factorBelow) {
+function buildBandPoints(viewer, curve, factorAbove, factorBelow, freqMult = 1.0) {
const STEPS = 60;
const upper = [], lower = [];
for (let i = 0; i <= STEPS; ++i) {
const t = curve.t0 + (curve.t3 - curve.t0) * i / STEPS;
if (t < viewer.t_view_min - 0.01 || t > viewer.t_view_max + 0.01) continue;
- const f = evalBezier(curve, t);
+ const f = evalBezier(curve, t) * freqMult;
upper.push([viewer.timeToX(t), viewer.freqToY(f * (1 + factorAbove))]);
lower.push([viewer.timeToX(t), viewer.freqToY(f * (1 - factorBelow))]);
}
return { upper, lower };
}
+
+// Build center line points at freq * freqMult along the curve.
+function buildCenterPoints(viewer, curve, freqMult = 1.0) {
+ const STEPS = 60;
+ const pts = [];
+ for (let i = 0; i <= STEPS; ++i) {
+ const t = curve.t0 + (curve.t3 - curve.t0) * i / STEPS;
+ if (t < viewer.t_view_min - 0.01 || t > viewer.t_view_max + 0.01) continue;
+ pts.push([viewer.timeToX(t), viewer.freqToY(evalBezier(curve, t) * freqMult)]);
+ }
+ return pts;
+}