summaryrefslogtreecommitdiff
path: root/tools/mq_editor/mq_extract.js
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-19 00:00:06 +0100
committerskal <pascal.massimino@gmail.com>2026-02-19 00:00:06 +0100
commitdb5c023acd237d7015933bd21a5a6dbe5755841d (patch)
tree219ca50b1728a57f3a5e6ba0e0640b0f0739f93b /tools/mq_editor/mq_extract.js
parent618bd1dc9af4beb98584ed817772951007017f79 (diff)
fix(mq_editor): fuse spread_above/below into single spread param
Asymmetric spread offset the pitch center. Replace with a single symmetric `spread` in harmonics config. autodetectSpread now returns max(above, below). Update all defaults, UI, comments, and README. handoff(Gemini): spread is now a single param; no compat shims. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'tools/mq_editor/mq_extract.js')
-rw-r--r--tools/mq_editor/mq_extract.js19
1 files changed, 9 insertions, 10 deletions
diff --git a/tools/mq_editor/mq_extract.js b/tools/mq_editor/mq_extract.js
index 47c21b9..0940cf1 100644
--- a/tools/mq_editor/mq_extract.js
+++ b/tools/mq_editor/mq_extract.js
@@ -270,13 +270,12 @@ function expandPartialsLeft(partials, frames) {
}
}
-// Autodetect spread_above / spread_below from the spectrogram.
-// For each (subsampled) STFT frame within the partial, measures the
-// half-power (-3dB) width of the spectral peak above and below the center.
-// spread = half_bandwidth / f0 (fractional).
+// Autodetect spread from the spectrogram.
+// Measures -3dB half-bandwidth above and below the peak in each STFT frame,
+// returns spread = max(above, below) / f0 as a fractional frequency offset.
function autodetectSpread(partial, stftCache, fftSize, sampleRate) {
const curve = partial.freqCurve;
- if (!curve || !stftCache) return {spread_above: 0.02, spread_below: 0.02};
+ if (!curve || !stftCache) return {spread: 0.02};
const numFrames = stftCache.getNumFrames();
const binHz = sampleRate / fftSize;
@@ -331,9 +330,9 @@ function autodetectSpread(partial, stftCache, fftSize, sampleRate) {
++count;
}
- const spread_above = count > 0 ? Math.sqrt(sumAbove / count) : 0.01;
- const spread_below = count > 0 ? Math.sqrt(sumBelow / count) : 0.01;
- return {spread_above, spread_below};
+ const sa = count > 0 ? Math.sqrt(sumAbove / count) : 0.01;
+ const sb = count > 0 ? Math.sqrt(sumBelow / count) : 0.01;
+ return {spread: Math.max(sa, sb)};
}
// Track a single partial starting from a (time, freq) seed position.
@@ -428,7 +427,7 @@ function trackFromSeed(frames, seedTime, seedFreq, params) {
return {
times: allTimes, freqs: allFreqs, amps: allAmps, phases: allPhases,
muted: false, freqCurve,
- harmonics: { decay: 0.0, freq_mult: 2.0, jitter: 0.05, spread_above: 0.02, spread_below: 0.02 },
+ harmonics: { decay: 0.0, freq_mult: 2.0, jitter: 0.05, spread: 0.02 },
};
}
@@ -522,7 +521,7 @@ function trackIsoContour(stftCache, seedTime, seedFreq, params) {
times: allTimes, freqs: allFreqs, amps: allAmps,
phases: new Array(allTimes.length).fill(0),
muted: false, freqCurve,
- harmonics: { decay: 0.0, freq_mult: 2.0, jitter: 0.05, spread_above: 0.15, spread_below: 0.15 },
+ harmonics: { decay: 0.0, freq_mult: 2.0, jitter: 0.05, spread: 0.15 },
};
}