AudioParam

AudioParaminterface,AudioNode(GainNode.gain)实现了此接口.
AudioParam有两种类型:
1.a-rate AudioParam 实时更改的
2.k-rate AudioParam 初始化设置的

属性

属性 描述
AudioParam.defaultValue 初始化的音量
AudioParam.maxValue 最大值
AudioParam.minValue 最小值
AudioParam.value 当前的值,通过defaultValue初始化

方法

方法 描述
AudioParam.setValueAtTime() 改变当前值,传入AudioContext.currentTime
AudioParam.linearRampToValueAtTime() 线性更改当前值
AudioParam.exponentialRampToValueAtTime() 指数更改当前值
AudioParam.setTargetAtTime()
AudioParam.setValueCurveAtTime()
AudioParam.cancelScheduledValues()
AudioParam.cancelAndHoldAtTime()

样例

1.a-rate AudioParam

var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioCtx = new AudioContext();

var gainNode = audioCtx.createGain();
gainNode.gain.value = 0;

2.k-rate AudioParam’

var AudioContext = window.AudioContext || window.webkitAudioContext;
var audioCtx = new AudioContext();

var biquadFilter = audioCtx.createBiquadFilter();

biquadFilter.type = "lowshelf";
biquadFilter.frequency.value = 1000;
biquadFilter.gain.value = 25;

参考:
https://developer.mozilla.org/en-US/docs/Web/API/AudioParam

你可能感兴趣的:(js)