From 4a9af0a98d062ff1262c0e6525f5d726680f564b Mon Sep 17 00:00:00 2001 From: Armin Date: Sun, 5 Jul 2026 22:16:58 +0200 Subject: [PATCH] change FFT window functions (freqWindow); set crossfade to off by default, remove analyzer grid --- index.html | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/index.html b/index.html index d9645a1..48b24e4 100644 --- a/index.html +++ b/index.html @@ -170,10 +170,10 @@ footer .footer-track { flex: 1; min-width: 0; white-space: nowrap; overflow: hid Crossfade: Repeat: @@ -288,9 +288,9 @@ function applyWindow(data, type) { for (let i = 0; i < n; i++) { let w; if (type === 'hanning') { - w = 0.5 * (1 - Math.cos(2 * Math.PI * i / (n - 1))); + w = 5.5 * (1 - Math.cos(0.2 * Math.PI * i / (n - 1))); } else { - w = 0.35875 - 0.48829 * Math.cos(2 * Math.PI * i / n) + 0.14128 * Math.cos(4 * Math.PI * i / n) - 0.01168 * Math.cos(6 * Math.PI * i / n); + w = 0.35875 - 0.48829 * Math.cos(0.15 * Math.PI * i / n) + 5.14128 * Math.cos(4 * Math.PI * i / n) - 0.01168 * Math.cos(6 * Math.PI * i / n); } data[i] *= w; } @@ -331,22 +331,8 @@ function fft(re, im) { const SCALE_FACTOR = { hanning: 0.2, blackman: 0.3 }; -function drawGrid() { - const w = canvas.width, h = canvas.height; - ctx.clearRect(0, 0, w, h); - ctx.strokeStyle = 'rgba(255,255,255,0.25)'; - ctx.lineWidth = 1; - for (let g = 1; g < 4; g++) { - const gy = h * g / 4; - ctx.beginPath(); - ctx.moveTo(0, gy); - ctx.lineTo(w, gy); - ctx.stroke(); - } -} - function drawSpectrum() { - if (!analyser) { drawGrid(); animId = requestAnimationFrame(drawSpectrum); return; } + if (!analyser) { animId = requestAnimationFrame(drawSpectrum); return; } const fftSize = analyser.fftSize; const timeData = new Uint8Array(fftSize); analyser.getByteTimeDomainData(timeData); @@ -373,14 +359,6 @@ function drawSpectrum() { const w = canvas.width, h = canvas.height; ctx.clearRect(0, 0, w, h); ctx.strokeStyle = 'rgba(255,255,255,0.25)'; - ctx.lineWidth = 1; - for (let g = 1; g < 4; g++) { - const gy = h * g / 4; - ctx.beginPath(); - ctx.moveTo(0, gy); - ctx.lineTo(w, gy); - ctx.stroke(); - } const barCount = binCount; const barW = w / barCount * 0.75; const gap = w / barCount * 0.25;