From c804808870cf3775362c02e40ea7d3d082ed0d91 Mon Sep 17 00:00:00 2001 From: skal Date: Thu, 19 Feb 2026 00:32:54 +0100 Subject: fix(mq_editor): jitter + central spectrum invalidation MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit mq_synth.js: - jitter was only used as a static initial phase offset (inaudible); now drives per-sample LCG frequency perturbation (±jitter fraction of instantaneous freq) in both sinusoidal (integratePhase path) and resonator modes (separate jitterSeed, independent from noise excitation) - disableJitter option now correctly gates jitter to 0 in both modes (was never read before) viewer.js / app.js: - remove invalidatePartialSpectrum() and onResonatorParamChange callback; replace with viewer.onGetSynthOpts callback, called inside _computePartialSpectrum to pull fresh synthOpts at compute time - all UI changes (resonator r/gain, forceResonator, globalR/gain, forceRGain, sinusoidal params) now use viewer.render() as the single invalidation path — no more split between render() and invalidatePartialSpectrum() handoff(Gemini): jitter active on both synth modes; spectrum always sees fresh synthOpts via onGetSynthOpts; viewer.render() is the only invalidation path needed. Co-Authored-By: Claude Sonnet 4.6 --- tools/mq_editor/viewer.js | 2 ++ 1 file changed, 2 insertions(+) (limited to 'tools/mq_editor/viewer.js') diff --git a/tools/mq_editor/viewer.js b/tools/mq_editor/viewer.js index c841acb..4744b96 100644 --- a/tools/mq_editor/viewer.js +++ b/tools/mq_editor/viewer.js @@ -55,6 +55,7 @@ class SpectrogramViewer { this.partialSpectrumCtx = this.partialSpectrumCanvas ? this.partialSpectrumCanvas.getContext('2d') : null; this._partialSpecCache = null; // {partialIndex, time, specData?} — see renderPartialSpectrum this.synthOpts = {}; // synth options forwarded to synthesizeMQ (forceResonator, etc.) + this.onGetSynthOpts = null; // callback() → opts; called before each spectrum compute // Selection and editing this.selectedPartial = -1; @@ -727,6 +728,7 @@ class SpectrogramViewer { // return {squaredAmp, maxDB, sampleRate, fftSize}. Uses this.synthOpts (forceResonator etc). // freqCurve times are shifted so synthesizeMQ's t=0 aligns with tStart = time − window/2. _computePartialSpectrum(partial, time) { + if (this.onGetSynthOpts) this.synthOpts = this.onGetSynthOpts(); const sampleRate = this.audioBuffer.sampleRate; const FFT_SIZE = 2048; const windowDuration = FFT_SIZE / sampleRate; -- cgit v1.2.3