0

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.

dschu
  • 4,992
  • 5
  • 31
  • 48

2 Answers2

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.

Raymond Toy
  • 5,490
  • 10
  • 13
  • Hm, then Math.pow(2, 11) should work, but sadly it doesn't. – dschu Apr 25 '17 at 15:35
  • 1
    Checked the code. 2048 is the max. Not sure if Math.pow(2,11) returns exactly 2048 or not, due to roundoff. – Raymond Toy Apr 25 '17 at 16:58
  • Thanks for checking the code. I guess I'll open a ticket in Apples bugtracker then. Because Firefox and Chrome implemented it as in the spec. Would you mind to update your answer. Will mark it as correct then, thanks. – dschu Apr 25 '17 at 17:00
0

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.

Kerry Davis
  • 171
  • 1
  • 4
  • 12