change FFT window functions (freqWindow); set crossfade to off by

default, remove analyzer grid
This commit is contained in:
Armin 2026-07-05 22:16:58 +02:00
commit 4a9af0a98d

View file

@ -170,10 +170,10 @@ footer .footer-track { flex: 1; min-width: 0; white-space: nowrap; overflow: hid
</select> </select>
<span style="font-size:11px;color:#555;margin-left:8px">Crossfade:</span> <span style="font-size:11px;color:#555;margin-left:8px">Crossfade:</span>
<select id="crossfadeSelect"> <select id="crossfadeSelect">
<option value="0">Off</option> <option value="0" selected>Off</option>
<option value="1">1s</option> <option value="1">1s</option>
<option value="2">2s</option> <option value="2">2s</option>
<option value="3" selected>3s</option> <option value="3">3s</option>
<option value="5">5s</option> <option value="5">5s</option>
</select> </select>
<span style="font-size:11px;color:#555;margin-left:8px">Repeat:</span> <span style="font-size:11px;color:#555;margin-left:8px">Repeat:</span>
@ -288,9 +288,9 @@ function applyWindow(data, type) {
for (let i = 0; i < n; i++) { for (let i = 0; i < n; i++) {
let w; let w;
if (type === 'hanning') { 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 { } 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; data[i] *= w;
} }
@ -331,22 +331,8 @@ function fft(re, im) {
const SCALE_FACTOR = { hanning: 0.2, blackman: 0.3 }; 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() { function drawSpectrum() {
if (!analyser) { drawGrid(); animId = requestAnimationFrame(drawSpectrum); return; } if (!analyser) { animId = requestAnimationFrame(drawSpectrum); return; }
const fftSize = analyser.fftSize; const fftSize = analyser.fftSize;
const timeData = new Uint8Array(fftSize); const timeData = new Uint8Array(fftSize);
analyser.getByteTimeDomainData(timeData); analyser.getByteTimeDomainData(timeData);
@ -373,14 +359,6 @@ function drawSpectrum() {
const w = canvas.width, h = canvas.height; const w = canvas.width, h = canvas.height;
ctx.clearRect(0, 0, w, h); ctx.clearRect(0, 0, w, h);
ctx.strokeStyle = 'rgba(255,255,255,0.25)'; 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 barCount = binCount;
const barW = w / barCount * 0.75; const barW = w / barCount * 0.75;
const gap = w / barCount * 0.25; const gap = w / barCount * 0.25;