--- title: GainNode.gain slug: Web/API/GainNode/gain translation_of: Web/API/GainNode/gain ---

{{ APIRef("Web Audio API") }}

{{ domxref("GainNode") }} 接口的gain属性是一个a-rate {{domxref("AudioParam")}} ,表示可利用的增益量.

语法

var audioCtx = new AudioContext();
var gainNode = audioCtx.createGain();
gainNode.gain.value = 0.5;

An {{domxref("AudioParam")}}.

Note: Though the AudioParam returned is read-only, the value it represents is not.

Example

{{page("/en-US/docs/Web/API/AudioContext.createGain","Example")}}

Specifications

Specification Status Comment
{{SpecName('Web Audio API', '#widl-GainNode-gain', 'gain')}} {{Spec2('Web Audio API')}}  

Browser compatibility

{{Compat("api.GainNode.gain")}}

See also