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/app.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) (limited to 'tools/mq_editor/app.js') diff --git a/tools/mq_editor/app.js b/tools/mq_editor/app.js index 380bb12..1c6d548 100644 --- a/tools/mq_editor/app.js +++ b/tools/mq_editor/app.js @@ -46,27 +46,20 @@ document.getElementById('hpK2').addEventListener('input', function() { document.getElementById('hpK2Val').textContent = k >= 1.0 ? 'bypass' : fmtHz(f); }); -function invalidatePartialSpectrum() { - if (!viewer) return; - viewer.synthOpts = getSynthParams().opts; - viewer._partialSpecCache = null; - viewer.renderPartialSpectrum(viewer.spectrumTime, true); -} - // Show/hide global resonator params when forceResonator toggled document.getElementById('forceResonator').addEventListener('change', function() { document.getElementById('globalResParams').style.display = this.checked ? '' : 'none'; - invalidatePartialSpectrum(); + if (viewer) viewer.render(); }); document.getElementById('globalR').addEventListener('input', function() { document.getElementById('globalRVal').textContent = parseFloat(this.value).toFixed(4); - invalidatePartialSpectrum(); + if (viewer) viewer.render(); }); document.getElementById('globalGain').addEventListener('input', function() { document.getElementById('globalGainVal').textContent = parseFloat(this.value).toFixed(2); - invalidatePartialSpectrum(); + if (viewer) viewer.render(); }); -document.getElementById('forceRGain').addEventListener('change', invalidatePartialSpectrum); +document.getElementById('forceRGain').addEventListener('change', () => { if (viewer) viewer.render(); }); let audioBuffer = null; let viewer = null; @@ -207,7 +200,8 @@ function loadAudioBuffer(buffer, label) { document.getElementById('exploreBtn').disabled = false; document.getElementById('contourBtn').disabled = false; editor.setViewer(viewer); - viewer.onPartialSelect = (i) => editor.onPartialSelect(i); + viewer.onGetSynthOpts = () => getSynthParams().opts; + viewer.onPartialSelect = (i) => editor.onPartialSelect(i); viewer.onRender = () => editor.onRender(); viewer.onBeforeChange = pushUndo; viewer.onExploreMove = (time, freq) => { -- cgit v1.2.3