import { AudioBus } from "./AudioBus.js";
export class AudioMixer {
    context;
    master;
    buses = new Map();
    constructor(context) {
        this.context = context;
        this.master = new AudioBus("master", context);
        this.buses.set(this.master.name, this.master);
    }
    createBus(name, destination = this.master.input) {
        if (this.buses.has(name)) {
            throw new Error(`Audio bus already exists: ${name}`);
        }
        const bus = new AudioBus(name, this.context, destination);
        this.buses.set(name, bus);
        return bus;
    }
    getBus(name) {
        const bus = this.buses.get(name);
        if (!bus) {
            throw new Error(`Unknown audio bus: ${name}`);
        }
        return bus;
    }
    dispose() {
        for (const bus of [...this.buses.values()].reverse()) {
            bus.dispose();
        }
        this.buses.clear();
    }
}
//# sourceMappingURL=AudioMixer.js.map