The index is not in the allowed range

只愿长相守 提交于 2019-12-12 01:48:35

问题


I'm currently having an issue with the Tone.Analyzer in Safari 10.1. When initializing the Tone.Analyzer with a size > Math.pow(2, 10) (1024) I get the following error: IndexSizeError (DOM Exception 1): The index is not in the allowed range.

I've also submitted this to the ToneJS repository, but I feel like this is more like an bug in Safari, right?

Code

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

However, I can't find any information on the interwebz, which browser accepts which size, 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)

Does Safaris Audio APIs getByteFrequencyData haven't implemented higher sizes? Would love to implement a highly accurate equalizer, but the sample size needs to be > 4000 for the lower frequencies.


回答1:


An early version of the WebAudio spec said that 2048 was the largest FFT size for the AnalyserNode. Later versions made the limit at least 32k, Safari still implements the old limit.




回答2:


I have similar issue. Not using Tone.js but Safari 11 AudioContext.analyser.fftSize does appear to be limited to 2048 and no more. I actually need the maximum of 32K. The same code, does however, work perfectly fine in Chrome on an Apple Desktop.

Alternative (regrettably) appears to require importing an open source JS FFT (I like https://github.com/audioplastic/ooura although I have not tried the JS version...C version is excellent). Would much rather webRTC do the heavy lifting of both the Time domain and Frequency domain sampling and computing. Would be much more future proof not to mention lighter solution.



来源:https://stackoverflow.com/questions/43606218/the-index-is-not-in-the-allowed-range

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!