从AudioContext AnalyserNode获得的频率不连续

问题描述

如果我以正弦/波形形式提供频率的声音,则我从AudioContext的AnalyserNode获得的响应就像水平条一样。缺少转换:

enter image description here

似乎频率分辨率太低。

我的工作程序在这里https://codepen.io/doganmeh/pen/rNeEyPB

以下是发声器:https://www.szynalski.com/tone-generator/(单击“播放”,然后缓慢上下滑动条)

代码的相关部分:

let audio_context = new AudioContext({
    sampleRate: 1024 * 4,});

let analyser = new AnalyserNode(audio_context,{
    fftSize: 1024 * 4,maxDecibels: -20,minDecibels: -80,smoothingTimeConstant: 0
});

let bars_data = new Uint8Array(analyser.frequencyBinCount)  // fftSize/2

analyser.getByteFrequencyData(bars_data);

// display frequency bars_data (not shown here,see the linked code)
// get the note from the bars and show as a dot

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)