GainNode.gain
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since April 2021.
GainNode
介面的 gain
屬性是 a-rate AudioParam
,代表增益的數值。
語法
js
var audioCtx = new AudioContext();
var gainNode = audioCtx.createGain();
gainNode.gain.value = 0.5;
傳回值
一個 AudioParam
.
備註:
雖然傳回的 AudioParam
是唯讀的,但是它所代表的值可以更改。
範例
See BaseAudioContext.createGain()
for example code showing how to use an AudioContext
to create a GainNode
, which is then used to mute and unmute the audio by changing the gain property value.
規格
Specification |
---|
Web Audio API # dom-gainnode-gain |
瀏覽器相容度
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
gain |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.