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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With