diff --git a/index.html b/index.html
index ee4c17e..4495187 100644
--- a/index.html
+++ b/index.html
@@ -583,15 +583,11 @@ function drawSpectrum() {
if (levelR > vuSmoothR) vuSmoothR = levelR; else vuSmoothR = vuSmoothR * vuSmooth + levelR * (1 - vuSmooth);
levelL = vuSmoothL;
levelR = vuSmoothR;
- function drawVuRow(y, level, peak, hold) {
+ function drawVuRow(y, level) {
const lit = Math.round(level * segCount);
- if (level > peak) { peak = level; hold = 0; }
- else if (hold < vuPeakGrace) { hold++; }
- else { peak *= 0.990; }
for (let i = 0; i < segCount; i++) {
const sx = segLeft + i * (segW + segG);
const on = i < lit;
- const pi = Math.round(peak * segCount);
vuctx.fillStyle = on ? '#84a0c6' : '#1e2132';
vuctx.fillRect(sx, y, segW, rowH);
if (on) {
@@ -601,17 +597,26 @@ function drawSpectrum() {
vuctx.fillStyle = grd;
vuctx.fillRect(sx, y, segW, 2);
}
- if (i === pi && peak > 0.05) {
- vuctx.fillStyle = '#e98989';
- vuctx.fillRect(sx, y, segW, rowH);
- }
}
- return [peak, hold];
}
- const rL = drawVuRow(0, levelL, vuPeakL, vuPeakHoldL);
- vuPeakL = rL[0]; vuPeakHoldL = rL[1];
- const rR = drawVuRow(gap + rowH, levelR, vuPeakR, vuPeakHoldR);
- vuPeakR = rR[0]; vuPeakHoldR = rR[1];
+ if (levelL > vuPeakL) { vuPeakL = levelL; vuPeakHoldL = 0; }
+ else if (vuPeakHoldL < vuPeakGrace) { vuPeakHoldL++; }
+ else { vuPeakL *= 0.990; }
+ if (levelR > vuPeakR) { vuPeakR = levelR; vuPeakHoldR = 0; }
+ else if (vuPeakHoldR < vuPeakGrace) { vuPeakHoldR++; }
+ else { vuPeakR *= 0.990; }
+ drawVuRow(0, levelL);
+ drawVuRow(gap + rowH, levelR);
+ const piL = Math.round(vuPeakL * segCount);
+ const piR = Math.round(vuPeakR * segCount);
+ if (vuPeakL > 0.05) {
+ vuctx.fillStyle = '#e98989';
+ vuctx.fillRect(segLeft + piL * (segW + segG), 0, segW, rowH);
+ }
+ if (vuPeakR > 0.05) {
+ vuctx.fillStyle = '#e98989';
+ vuctx.fillRect(segLeft + piR * (segW + segG), gap + rowH, segW, rowH);
+ }
}
animId = requestAnimationFrame(drawSpectrum);
}