From 4f51a8ce316e6c8e3020d10da91952adc237e0b8 Mon Sep 17 00:00:00 2001 From: lyswhut Date: Tue, 4 Jan 2022 09:41:18 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E9=A2=91=E8=B0=B1=E3=80=81?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A2=91=E8=B0=B1=E5=9D=87=E5=80=BC=E5=8A=A0?= =?UTF-8?q?=E6=88=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/components/common/AudioVisualizer.vue | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/renderer/components/common/AudioVisualizer.vue b/src/renderer/components/common/AudioVisualizer.vue index 07aaadcb..7f3ae1cd 100644 --- a/src/renderer/components/common/AudioVisualizer.vue +++ b/src/renderer/components/common/AudioVisualizer.vue @@ -70,16 +70,18 @@ export default { for (let i = 0; i < bufferLength; i++) { mult = Math.floor(i / maxNum) num = mult % 2 === 0 ? (i - maxNum * mult) : (maxNum - (i - maxNum * mult)) - let spectrum = num > 36 ? 0 : dataArray[num + 20] + let spectrum = num > 80 ? 0 : dataArray[num + 20] frequencyAvg += spectrum * 1.2 } frequencyAvg /= bufferLength - frequencyAvg *= 1.7 + frequencyAvg *= 1.4 frequencyAvg = frequencyAvg / maxNum // ctx.scale(1, 1 + frequencyAvg) for (let i = 0; i < bufferLength; i++) { + if (x > WIDTH) break + barHeight = dataArray[i] // let r = barHeight + (25 * (i / bufferLength)) @@ -87,7 +89,7 @@ export default { // let b = 50 // ctx.fillStyle = 'rgb(' + r + ',' + g + ',' + b + ')' - barHeight = barHeight * frequencyAvg + barHeight * 0.6 + barHeight = barHeight * frequencyAvg + barHeight * 0.4 ctx.fillRect(x, HEIGHT - barHeight, barWidth, barHeight) x += barWidth