mirror of
https://codeberg.org/armin/noiz.git
synced 2026-09-01 05:50:52 +02:00
Fix blurry VU meter LEDs by using integer segment width
This commit is contained in:
parent
9d1318145a
commit
af866881ff
1 changed files with 6 additions and 5 deletions
11
index.html
11
index.html
|
|
@ -207,8 +207,8 @@ footer .footer-track { flex: 1; min-width: 0; white-space: nowrap; overflow: hid
|
||||||
</select>
|
</select>
|
||||||
<span style="font-size:11px;color:#6b7089">Peak Decay:</span>
|
<span style="font-size:11px;color:#6b7089">Peak Decay:</span>
|
||||||
<select id="decaySelect">
|
<select id="decaySelect">
|
||||||
<option value="0.995">Slow</option>
|
<option value="0.998" selected>Slow</option>
|
||||||
<option value="0.985" selected>Medium</option>
|
<option value="0.985">Medium</option>
|
||||||
<option value="0.97">Fast</option>
|
<option value="0.97">Fast</option>
|
||||||
<option value="0.94">Very Fast</option>
|
<option value="0.94">Very Fast</option>
|
||||||
</select>
|
</select>
|
||||||
|
|
@ -541,9 +541,10 @@ function drawSpectrum() {
|
||||||
const gap = 4;
|
const gap = 4;
|
||||||
const labelW = 12;
|
const labelW = 12;
|
||||||
const segCount = 32;
|
const segCount = 32;
|
||||||
const segArea = vw - labelW - segCount;
|
|
||||||
const segW = segArea / segCount;
|
|
||||||
const segG = 1;
|
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) {
|
function getLevel(analyserCh) {
|
||||||
const td = new Uint8Array(analyserCh.fftSize);
|
const td = new Uint8Array(analyserCh.fftSize);
|
||||||
analyserCh.getByteTimeDomainData(td);
|
analyserCh.getByteTimeDomainData(td);
|
||||||
|
|
@ -567,7 +568,7 @@ function drawSpectrum() {
|
||||||
if (level > peak) peak = level;
|
if (level > peak) peak = level;
|
||||||
else peak *= 0.990;
|
else peak *= 0.990;
|
||||||
for (let i = 0; i < segCount; i++) {
|
for (let i = 0; i < segCount; i++) {
|
||||||
const sx = labelW + i * (segW + segG);
|
const sx = segLeft + i * (segW + segG);
|
||||||
const on = i < lit;
|
const on = i < lit;
|
||||||
const pi = Math.round(peak * segCount);
|
const pi = Math.round(peak * segCount);
|
||||||
vuctx.fillStyle = on ? '#84a0c6' : '#1e2132';
|
vuctx.fillStyle = on ? '#84a0c6' : '#1e2132';
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue