UNPKG

@babylonjs/core

Version:

Getting started? Play directly with the Babylon.js API using our [playground](https://playground.babylonjs.com/). It also contains a lot of samples to learn how to use it.

45 lines 1.53 kB
import { AbstractNamedAudioNode } from "./abstractAudioNode.js"; import { _GetVolumeAudioProperty, _GetVolumeAudioSubNode } from "./subNodes/volumeAudioSubNode.js"; import { _AudioAnalyzer } from "./subProperties/audioAnalyzer.js"; /** * Abstract class representing an audio bus with volume control. * * An audio bus is a node in the audio graph that can have multiple inputs and outputs. It is typically used to group * sounds together and apply effects to them. */ export class AbstractAudioBus extends AbstractNamedAudioNode { constructor(name, engine) { super(name, engine, 3 /* AudioNodeType.HAS_INPUTS_AND_OUTPUTS */); this._analyzer = null; } /** * The analyzer features of the bus. */ get analyzer() { return this._analyzer ?? (this._analyzer = new _AudioAnalyzer(this._subGraph)); } /** * The output volume of the bus. */ get volume() { return _GetVolumeAudioProperty(this._subGraph, "volume"); } set volume(value) { // The volume subnode is created on initialization and should always exist. const node = _GetVolumeAudioSubNode(this._subGraph); if (!node) { throw new Error("No volume subnode"); } node.volume = value; } /** * Releases associated resources. */ dispose() { super.dispose(); this._analyzer?.dispose(); this._analyzer = null; this._subGraph.dispose(); } } //# sourceMappingURL=abstractAudioBus.js.map