Open nicschumann opened 2 years ago
Leaning towards the 2nd bullet point above. It's the most compatible with the layout of the library, and keeps this thing "drag and drop": all functionality will still be accessible through a single setup call to .init()
and a single usage call to .analyze(x : Float32Array)
.
Not all browsers allow you to set the sample-rate on device. The main issue is Firefox, which vomits when you ask it to set the sample-rate of the
AudioContext
to anything other than the hardware sample-rate of the microphone. There are multiple options for dealing with this:AudioWorklet
node which implements a resampling transform from the native sample-rate (probably44.1kHz
or96kHz
) to the target sample rate of8kHz
. This is nice because it leverages resampling off of the browser's main thread.