我正在尝试使用 Web Audio API 编写自相关算法。自相关仅依赖于时域中的数据,而不依赖于频域中的数据,因此我仅使用 getByteTimeDomainData()
。我很难找到有关 AnalyserNode 如何实现的信息。从我在MDN Docs中读到的内容来看我不清楚 FFT 是否仅在调用 getByteFrequencyData() 时运行,或者是否无论如何都会运行。大型 FFT 非常昂贵,所以我不希望它们随意运行。
最佳答案
根据规范,我认为期望是在您要求时计算 FFT。
getByteFrequencyData()
:
The most recent
fftSize
frames are used in computing the frequency data.
如果您过于频繁地请求它,它甚至会返回缓存的结果:
If another call to
getByteFrequencyData()
orgetFloatFrequencyData()
occurs within the same render quantum as a previous call, the current frequency data is not updated with the same data. Instead, the previously computed data is returned.
这种措辞还表明计算应该根据请求进行。
关于javascript - AnalyserNode 在什么时候执行 FFT?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57827830/