Is it possible to specify the sampling rate (sampleRate
attribute of the AudioContext
object) for a real-time audio context?
For what I read, it is possible to specify the sampleRate
for an OfflineAudioContext
object (the constructor takes 3 arguments, the last one being the sample rate), but the real-time AudioContext
doesn't take any arguments.
I imagine is not possible, as probably that is defined by the browser itself, but maybe there's a way?
No, it's not possible to do this, other than setting the sampling rate of your sound card at the operating system level (not all i/o devices support this).
An update. The latest version of the spec now does allow you to specify the sample rate. Use new AudioContext({sampleRate: desiredRate})
to choose the desired sample rate. The browser will take care of resampling everything to work with the actual sample rate of the audio hardware. This is supported on every browser, except, perhaps, Safari.
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