From 7f9567b1ec4c1b10577e3699b432cee0bdf8489a Mon Sep 17 00:00:00 2001 From: mtvpls Date: Thu, 14 May 2026 22:39:58 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=9F=B3=E8=B0=B1=E5=9B=BE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/music/page.tsx | 40 ++++++++++++++++++++++++++++++---------- 1 file changed, 30 insertions(+), 10 deletions(-) diff --git a/src/app/music/page.tsx b/src/app/music/page.tsx index b0f85db..58dc3a6 100644 --- a/src/app/music/page.tsx +++ b/src/app/music/page.tsx @@ -11,6 +11,9 @@ import LyricsPiPWindow from '@/components/LyricsPiPWindow'; const SPECTRUM_BIN_COUNT = 96; const SPECTRUM_IDLE_LEVEL = 0.02; const SPECTRUM_EDGE_TRIM = 8; +const SPECTRUM_REFERENCE_VOLUME = 10; +const SPECTRUM_MIN_VOLUME = 5; +const SPECTRUM_MAX_REFERENCE_VOLUME = 15; type MusicSource = 'wy' | 'tx' | 'kw' | 'kg' | 'mg'; @@ -128,9 +131,9 @@ function AudioSpectrumCanvas({ ctx.clearRect(0, 0, width, height); const targetPitch = compact ? 4.2 : 4.6; - const gap = 1; + const gap = Math.max(1, Math.round(dpr)); const count = Math.max(1, Math.floor(rect.width / targetPitch)); - const barWidth = Math.max(2, Math.floor((width - gap * (count - 1)) / count)); + const barWidth = Math.max(2 * dpr, (width - gap * (count - 1)) / count); const cubeHeight = compact ? Math.max(2, Math.round(2 * dpr)) : Math.max(2, Math.round(2.5 * dpr)); const cubeGap = 1; const scaleBase = compact ? height * 1.55 : height * 1.42; @@ -153,7 +156,7 @@ function AudioSpectrumCanvas({ for (let i = 0; i < count; i++) { const q = Math.max(SPECTRUM_IDLE_LEVEL, sampleBar(i)) * scaleBase; const cubeCount = Math.max(1, Math.ceil(q / Math.max(1, barWidth * 0.9))); - const x = i * (barWidth + gap); + const x = i === count - 1 ? width - barWidth : i * (barWidth + gap); for (let segment = 0; segment < cubeCount; segment++) { const y = height - segment * (cubeHeight + cubeGap); @@ -172,7 +175,7 @@ function AudioSpectrumCanvas({ return (