getMasterLimiterNode
Added in 5.8.0
getMasterLimiterNode(): DynamicsCompressorNode | null;
Returns the live limiter node, so you can fine-tune it or read how much gain reduction is
being applied. Returns null when the master limiter is disabled.
| Return Type | Description |
|---|---|
DynamicsCompressorNode | null | The limiter node, or null when the limiter is off |
caution
Do not connect or disconnect this node yourself. The sound manager owns its position in the
audio graph and will rewire it when you toggle the limiter or change master spatial audio.
Reading and writing its AudioParam values is fine.
Example
Adjust the limiter to taste:
const limiter = soundHub.getMasterLimiterNode();
if (limiter) {
limiter.threshold.value = -6; // start limiting earlier
limiter.ratio.value = 12; // slightly softer than the default brick wall
limiter.release.value = 0.4; // recover more slowly
}
Show a gain reduction meter:
function drawMeter() {
const limiter = soundHub.getMasterLimiterNode();
// `reduction` is 0 when nothing is being held back, and negative dB when it is
const amount = limiter ? Math.abs(limiter.reduction) : 0;
meterBar.style.width = `${Math.min(100, (amount / 20) * 100)}%`;
requestAnimationFrame(drawMeter);
}
drawMeter();