Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WebAudio API sampling rate

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?

like image 216
jorgeh Avatar asked Jan 17 '13 20:01

jorgeh


2 Answers

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).

like image 59
cwilso Avatar answered Oct 08 '22 15:10

cwilso


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.

like image 1
Raymond Toy Avatar answered Oct 08 '22 14:10

Raymond Toy