Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is Web Audio API's bit depth?

What is the bit depth of Web Audio API's audio context?

For example if you want to create a custom curve to use with WaveShaperNode what is the appropriate Float32Array size?

I have seen developers using 65536 which is for 16-Bit audio, but i cant find any info in the spec.

like image 788
zya Avatar asked Sep 18 '13 14:09

zya


1 Answers

Actually, internally the system uses Float32, which has a significand of 23 bits. Using floating point allows the ability to avoid most clipping problems, while enabling good precision. This means technically there is little point in ever attempting to create a waveshaping curve larger than 8388608 (2^23) samples; but in reality, a 16-bit curve is pretty high-resolution (signal-to-noise is ~96dB). A lot of the reason for 32-bit audio processing was to avoid clipping problems, not improving SNR of input/output; use of floating point helps this dramatically. The WaveShaperNode specifically clips to [-1, +1] (most nodes don't), incidentally.

So in short - just use 16-bit (65535), but make sure your signal is in the -1,+1 range.

like image 120
cwilso Avatar answered Oct 20 '22 17:10

cwilso