Add cutoff max falloff decay selector

Introduce a new dropdown to control how fast the max-cutoff marker
decays toward the live cutoff on the realtime spectrum. Options:
  Off   — max cutoff holds indefinitely (manual reset only)
  Slow  — 1% gap reduction per frame
  Medium — 3% gap reduction per frame
  Fast   — 8% gap reduction per frame

Previously the max-cutoff line only went up and never came back down
unless the user clicked Reset.
This commit is contained in:
Armin 2026-07-06 18:10:05 +02:00
commit 1972add309
2 changed files with 13 additions and 0 deletions

View file

@ -38,6 +38,12 @@
<option value="medium" selected>Hold: Medium</option>
<option value="fast">Hold: Fast</option>
</select>
<select id="cutoffFalloff" class="window-select" title="Cutoff max falloff decay">
<option value="off" selected>Cutoff: Off</option>
<option value="slow">Cutoff: Slow</option>
<option value="medium">Cutoff: Medium</option>
<option value="fast">Cutoff: Fast</option>
</select>
</div>
<div class="chart-container" style="position:relative">
<canvas id="waveformChart"></canvas>

View file

@ -668,6 +668,13 @@ const App = {
const nyquist = sr / 2;
const cutoffHz = (cutoffBin / len) * nyquist;
if (cutoffHz > this.cutoffMaxHz) this.cutoffMaxHz = cutoffHz;
const falloffSel = document.getElementById('cutoffFalloff');
if (falloffSel && falloffSel.value !== 'off' && this.isPlaying && cutoffHz < this.cutoffMaxHz) {
const falloffMap = { slow: 0.01, medium: 0.03, fast: 0.08 };
const rate = falloffMap[falloffSel.value] ?? 0;
const gap = this.cutoffMaxHz - cutoffHz;
if (gap > 1) this.cutoffMaxHz -= gap * rate;
}
const displayHz = this.cutoffHold && this.cutoffMaxHz > 0 ? this.cutoffMaxHz : cutoffHz;
const displayBin = Math.round((displayHz / nyquist) * len);