AudioContextOptions dictionary (used when instantiating an AudioContext ) may contain a property named sampleRate , which indicates the sample rate to use for the new context. The value must be a floating-point value indicating the sample rate, in samples per second, for which to configure the new context; additionally, the value must be one which is supported by AudioBuffer.sampleRate .

句法

audioContextOptions.sampleRate = 44100;
var sampleRate = audioContextOptions.sampleRate;
					

The desired sample rate for the AudioContext , specified in samples per second. The value must be compatible with AudioBuffer.sampleRate . This value should typically be between 8,000 Hz and 96,000 Hz; the default will vary depending on the output device, but the sample rate 44,100 Hz is the most common.

sampleRate property is not included in the options, or the options are not specified when creating the audio context, the new context's output device's preferred sample rate is used by default.

规范

规范 状态 注释
Web 音频 API
The definition of 'AudioContextOptions.sampleRate' in that specification.
工作草案 初始定义。

浏览器兼容性

The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request. 更新 GitHub 上的兼容性数据
桌面 移动
Chrome Edge Firefox Internet Explorer Opera Safari Android webview Chrome for Android Firefox for Android Opera for Android Safari on iOS Samsung Internet
sampleRate Chrome 74 Edge 79 Firefox 61 IE No Opera No Safari ? WebView Android 74 Chrome Android 74 Firefox Android 61 Opera Android ? Safari iOS ? Samsung Internet Android 11.0

图例

完整支持

完整支持

不支持

不支持

兼容性未知 ?

兼容性未知

另请参阅

元数据

  • 最后修改: