chore(HTML): 更新 audio-visualization 部分页面,扩展频谱高频范围
This commit is contained in:
@@ -494,7 +494,7 @@
|
||||
|
||||
// 模式0:频谱柱状图(居中对称 + 镜像)
|
||||
function drawSpectrum() {
|
||||
const barCount = bufferLength / 2;
|
||||
const barCount = bufferLength; // 使用全部频段 bin,保留高频
|
||||
const barWidth = (width * 0.8) / barCount;
|
||||
const gap = 2;
|
||||
const maxBarHeight = height * 0.35;
|
||||
|
||||
@@ -204,7 +204,7 @@
|
||||
// 对数分布采样索引,低频更细腻
|
||||
function buildBands(bins) {
|
||||
const bands = [];
|
||||
const minF = 2, maxF = bins * 0.72;
|
||||
const minF = 2, maxF = bins; // 覆盖全部 bin,保留高频
|
||||
for (let i = 0; i <= BAR_COUNT; i++) {
|
||||
const t = i / BAR_COUNT;
|
||||
bands.push(Math.floor(minF * Math.pow(maxF / minF, t)));
|
||||
|
||||
@@ -895,7 +895,7 @@ function drawFreqBars(high) {
|
||||
const gap = W / barCount * 0.4;
|
||||
|
||||
for (let i = 0; i < barCount; i++) {
|
||||
const freqIdx = Math.floor(i / barCount * (freqData.length * 0.6));
|
||||
const freqIdx = Math.floor(i / barCount * (freqData.length - 1)); // 覆盖全部频段,保留高频
|
||||
const val = freqData[freqIdx] / 255;
|
||||
const barH = val * H * 0.35;
|
||||
const x = i * (barWidth + gap) + gap * 0.5;
|
||||
|
||||
@@ -311,7 +311,7 @@
|
||||
function drawSpectrum(x, y, w, h) {
|
||||
ctx.save();
|
||||
const bars = 64;
|
||||
const step = Math.floor(freqData.length / 2 / bars);
|
||||
const step = Math.floor(freqData.length / bars); // 覆盖全部 bin,保留高频
|
||||
const bw = w / bars;
|
||||
if (peakHold.length !== bars) peakHold = new Array(bars).fill(0);
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ function drawGrid(time) {
|
||||
function drawSkyline() {
|
||||
if (!freqArray) return;
|
||||
const binCount = analyser.frequencyBinCount;
|
||||
const usable = Math.floor(binCount * 0.6);
|
||||
const usable = binCount; // 覆盖全部频段,保留高频
|
||||
const barCount = 80;
|
||||
const barW = W / barCount;
|
||||
const baseY = H * 0.9;
|
||||
|
||||
Reference in New Issue
Block a user