Fix blurry VU meter LEDs by using integer segment width

This commit is contained in:
Armin 2026-07-08 18:20:29 +02:00
commit af866881ff

View file

@ -207,8 +207,8 @@ footer .footer-track { flex: 1; min-width: 0; white-space: nowrap; overflow: hid
</select>
<span style="font-size:11px;color:#6b7089">Peak Decay:</span>
<select id="decaySelect">
<option value="0.995">Slow</option>
<option value="0.985" selected>Medium</option>
<option value="0.998" selected>Slow</option>
<option value="0.985">Medium</option>
<option value="0.97">Fast</option>
<option value="0.94">Very Fast</option>
</select>
@ -541,9 +541,10 @@ function drawSpectrum() {
const gap = 4;
const labelW = 12;
const segCount = 32;
const segArea = vw - labelW - segCount;
const segW = segArea / segCount;
const segG = 1;
const segW = Math.floor((vw - labelW - (segCount - 1) * segG) / segCount);
const totalSegW = segCount * segW + (segCount - 1) * segG;
const segLeft = labelW + Math.floor(((vw - labelW) - totalSegW) / 2);
function getLevel(analyserCh) {
const td = new Uint8Array(analyserCh.fftSize);
analyserCh.getByteTimeDomainData(td);
@ -567,7 +568,7 @@ function drawSpectrum() {
if (level > peak) peak = level;
else peak *= 0.990;
for (let i = 0; i < segCount; i++) {
const sx = labelW + i * (segW + segG);
const sx = segLeft + i * (segW + segG);
const on = i < lit;
const pi = Math.round(peak * segCount);
vuctx.fillStyle = on ? '#84a0c6' : '#1e2132';