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 |
瀏覽器相容度
BCD tables only load in the browser