setMasterLimiter
Added in 5.8.0
setMasterLimiter(enabled: boolean): void;
Turns the master limiter on or off at runtime. Safe to call while sounds are playing: only the output chain is rewired, playback is not interrupted.
| Parameter | Type | Description |
|---|---|---|
enabled | boolean | true to insert the limiter before the output, false to remove it |
| Return Type | Description |
|---|---|
void | Nothing |
Calling it with the value it already has does nothing, so it is safe to call repeatedly.
Example
// Let the user decide, for example behind a checkbox
checkbox.addEventListener('change', (e) => {
soundHub.setMasterLimiter((e.target as HTMLInputElement).checked);
});
// Or enable it only while a busy scene is active
function startBossFight() {
soundHub.setMasterLimiter(true);
}
function endBossFight() {
soundHub.setMasterLimiter(false);
}
You can also enable it up front through the config instead:
const soundHub = new SoundHub({ masterLimiter: true });