优化频谱、修改频谱均值加成

pull/930/merge
lyswhut 2022-01-04 09:41:18 +08:00
parent 1371bbe6fb
commit 4f51a8ce31
1 changed files with 5 additions and 3 deletions

View File

@ -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