索引不在允许范围内

The index is not in the allowed range

我目前遇到 Safari 10.1 中的 Tone.Analyzer 问题。 使用 size > Math.pow(2, 10) (1024) 初始化 Tone.Analyzer 时出现以下错误: IndexSizeError (DOM Exception 1): The index is not in the allowed range.

我也submitted this to the ToneJS repository,但我觉得这更像是 Safari 中的一个错误,对吧?

代码

import Tone from 'tone';

const sampleSize = Math.pow(2, 13); // Math.pow(2, 10); works...

this.fft = new Tone.Analyser('fft', sampleSize);
this.panVol = new Tone.PanVol().fan(this.fft).toMaster();

Link to WebpackBin example

但是,我在interwebz上找不到任何信息,哪个浏览器接受哪个尺寸,while the Tone.js documentation mentions, that the Value must be a power of two in the range 32 to 32768. (Same as in the Web Audio API documentation)

Safaris Audio APIs getByteFrequencyData 没有实现更大的尺寸吗? 很想实现一个高精度的均衡器,但对于较低的频率,样本大小需要 > 4000。

WebAudio 规范的早期版本表示 2048 是 AnalyserNode 的最大 FFT 大小。后来的版本至少限制了 32k,Safari 仍然执行旧限制。

我有类似的问题。不使用 Tone.js 但 Safari 11 AudioContext.analyser.fftSize 似乎仅限于 2048,仅此而已。我实际上需要最大 32K。但是,相同的代码在 Apple 桌面上的 Chrome 中运行得非常好。

替代方案(遗憾)似乎需要导入开源 JS FFT(我喜欢 https://github.com/audioplastic/ooura 虽然我没有尝试过 JS 版本...C 版本非常好)。宁愿 webRTC 做时域和频域采样和计算的繁重工作。更不用说更轻的解决方案了。