jorgeh
jorgeh

Reputation: 1767

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?

Upvotes: 10

Views: 6860

Answers (2)

Raymond Toy
Raymond Toy

Reputation: 6048

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.

Upvotes: 3

cwilso
cwilso

Reputation: 13908

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

Upvotes: 6

Related Questions