export class AudioBus {
    name;
    input;
    output;
    muted = false;
    storedVolume = 1;
    constructor(name, context, destination) {
        this.name = name;
        this.input = context.createGain();
        this.output = context.createGain();
        this.input.connect(this.output);
        this.output.connect(destination ?? context.destination);
    }
    setVolume(value) {
        if (!Number.isFinite(value) || value < 0) {
            throw new Error("Audio bus volume must be a non-negative finite number");
        }
        this.storedVolume = value;
        if (!this.muted) {
            this.output.gain.value = value;
        }
    }
    mute(value = true) {
        this.muted = value;
        this.output.gain.value = value ? 0 : this.storedVolume;
    }
    dispose() {
        this.input.disconnect();
        this.output.disconnect();
    }
}
//# sourceMappingURL=AudioBus.js.map