AudioContextOptions - Web APIs 编辑

The AudioContextOptions dictionary is used to specify configuration options when constructing a new AudioContext object to represent a graph of web audio nodes. It is only used when calling the AudioContext() constructor.

Properties

latencyHint Optional
The type of playback that the context will be used for, as a value from the AudioContextLatencyCategory enum or a double-precision floating-point value indicating the preferred maximum latency of the context in seconds. The user agent may or may not choose to meet this request; check the value of AudioContext.baseLatency to determine the true latency after creating the context.
sampleRate Optional
The sampleRate to be used by the AudioContext, specified in samples per second. The value may be any value supported by AudioBuffer. If not specified, the preferred sample rate for the context's output device is used by default.

Constants

Standard values for latencyHint

The latencyHint property can be number specifying a preferred maximum latency in seconds or a string from the AudioContextLatencyCategory enumerated string, which selects a standard value for a given type of audio usage:

ValueDescription
"balanced"The user agent should balance audio output latency and power consumption when selecting a latency value.
"interactive"The audio is involved in interactive elements, such as responding to user actions or needing to coincide with visual cues such as a video or game action. The user agent should select the lowest possible latency that doesn't cause glitches in the audio. This is likely to require increased power consumption. This is the default value.
"playback"The user agent should select a latency that will maximize playback time by minimizing power consumption at the expense of latency. Useful for non-interactive playback, such as playing music.

Example

This example instantiates an audio context for music playback (optimized for power consumption over latency), with the sample rate 48,000 Hz.

let musicContext = new AudioContext({
  latencyHint: "playback",
  sampleRate: 48000
});

Specifications

SpecificationStatusComment
Web Audio API
The definition of 'AudioContextOptions' in that specification.
Working DraftInitial definition.

Browser compatibility

BCD tables only load in the browser

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据

词条统计

浏览:138 次

字数:4475

最后编辑:7 年前

编辑次数:0 次

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文