BiquadFilterNode: thuộc tính gain
Baseline
Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
Thuộc tính gain của giao diện BiquadFilterNode là một AudioParam a-rate — một số thực kép biểu diễn gain được dùng trong thuật toán lọc hiện tại.
Khi giá trị của nó dương, nó biểu diễn gain thực; khi âm, nó biểu diễn sự suy giảm.
Nó được biểu diễn theo dB, có giá trị mặc định là 0, và có thể nhận giá trị trong phạm vi danh định từ -40 đến 40.
Giá trị
Một AudioParam.
Note:
Mặc dù AudioParam được trả về là chỉ đọc, giá trị mà nó biểu diễn thì không phải.
Ví dụ
Ví dụ sau cho thấy cách dùng cơ bản của một AudioContext để tạo một nút bộ lọc Biquad. Để xem ví dụ/thông tin đầy đủ hơn, hãy tham khảo bản minh họa Voice-change-O-matic của chúng tôi (xem các dòng 108–193 trong app.js để biết phần mã liên quan).
const audioCtx = new AudioContext();
// Set up the different audio nodes we will use for the app
const analyser = audioCtx.createAnalyser();
const distortion = audioCtx.createWaveShaper();
const gainNode = audioCtx.createGain();
const biquadFilter = audioCtx.createBiquadFilter();
const convolver = audioCtx.createConvolver();
// Connect the nodes together
source = audioCtx.createMediaStreamSource(stream);
source.connect(analyser);
analyser.connect(distortion);
distortion.connect(biquadFilter);
biquadFilter.connect(convolver);
convolver.connect(gainNode);
gainNode.connect(audioCtx.destination);
// Manipulate the Biquad filter
biquadFilter.type = "lowshelf";
biquadFilter.frequency.value = 1000;
biquadFilter.gain.value = 25;
Thông số kỹ thuật
| Thông số kỹ thuật |
|---|
| Web Audio API> # dom-biquadfilternode-gain> |