ChannelAn audio routing unit that can host an effect chain, attach audio clips via an internal AudioClipPlayer, and send its output to another Channel or the Master.
import { Channel } from "@fluex/fluexgl-dsp";
const channel = new Channel(context);
channel.Send(master);
Constructs a new Channel and initializes its internal audio nodes (input → effects → panner → analyser → gain → output) and its AudioClipPlayer.
new Channel(context: AudioContext): Channel;
context: AudioContext - The AudioContext used to create this channel's internal audio nodes.id: stringA unique id, automatically generated when constructing a new channel. Should NOT be changed.
label: stringA custom label for this channel. Can be changed.
input: AudioNode | nullInput node for this channel. Internally created as a GainNode and used as the start of the routing chain.
stereoPannerNode: StereoPannerNode | nullStereo panner node for left/right balance control inside this channel.
analyserNode: AnalyserNode | nullAnalyser node used for visualization / analysis of this channel's signal.
gainNode: GainNode | nullGain node used to control the channel's volume after analysis.
output: AudioNode | nullOutput node of this channel. This node is connected to other channels when calling Send().
effects: Effector[]List of attached Effector instances. These are wired between input and stereoPannerNode.
context: AudioContext | nullThe AudioContext this channel was constructed with.
sends: Channel[]Channels this channel is currently connected to via Send().
audioClipPlayer: AudioClipPlayer | nullAudioClipPlayer owned by this channel. Used to attach and play AudioClip instances into this channel.
AddEffect(effect: Effector): voidAdds an Effector to this channel, initializes it using this channel's AudioContext, and rebuilds the internal effect chain routing.
effect: Effector - The effect instance to add.voidAttachEffect(effect: Effector): voidAlias for AddEffect(effect).
effect: Effector - The effect instance to attach.voidRemoveEffect(effect: Effector): voidRemoves an attached Effector from this channel, disconnects its audio node, and rebuilds the internal effect chain routing.
effect: Effector - The effect instance to remove.voidDetachEffect(effect: Effector): voidAlias for RemoveEffect(effect).
effect: Effector - The effect instance to detach.voidSend(channel: Channel | Master): voidConnects this channel's output to another Channel (to its input) or to the Master. Prevents self-links, mismatched AudioContexts, duplicate links, and feedback loops.
voidUnsend(channel: Channel | Master): voidDisconnects this channel from a previously linked Channel or Master and removes it from sends.
voidHasAudioClipPlayer(): booleanReturns whether this channel has a constructed AudioClipPlayer.
No arguments
boolean - true if audioClipPlayer is defined, otherwise false.UnsendToAllChannels(): voidDisconnects this channel from all channels currently stored in sends.
No arguments
voidAttachAudioClip(audioClip: AudioClip): voidAttaches an AudioClip to this channel via its internal AudioClipPlayer.
audioClip: AudioClip - The audio clip to attach.voidThis class does not emit custom events.
This class does not define public getters or setters.
import { DspPipeline, Channel } from "@fluex/fluexgl-dsp";
(async function () {
const pipeline = new DspPipeline({
pathToWasm: "/FluexGL-DSP-WASM/fluexgl-dsp-wasm_bg.wasm",
pathToWorklet: "/FluexGL-DSP-WASM/fluexgl-dsp-processor.worklet",
options: {
overrideMaxAudioBufferNodes: true
}
});
await pipeline.InitializeDpsPipeline();
const audioDevice = await pipeline.ResolveDefaultAudioOutputDevice();
if (!audioDevice) return;
const context = audioDevice.GetContext();
const master = audioDevice.GetMasterChannel();
const channel = new Channel(context);
channel.Send(master);
})()
import { DspPipeline } from "@fluex/fluexgl-dsp";
(async function () {
const pipeline = new DspPipeline({
pathToWasm: "/FluexGL-DSP-WASM/fluexgl-dsp-wasm_bg.wasm",
pathToWorklet: "/FluexGL-DSP-WASM/fluexgl-dsp-processor.worklet",
options: {
overrideMaxAudioBufferNodes: true
}
});
await pipeline.InitializeDpsPipeline();
const audioDevice = await pipeline.ResolveDefaultAudioOutputDevice();
if (!audioDevice) return;
const context = audioDevice.GetContext();
const master = audioDevice.GetMasterChannel();
const channel = audioDevice.CreateChannel();
channel.Send(master);
})()
import { DspPipeline } from "@fluex/fluexgl-dsp";
(async function () {
const pipeline = new DspPipeline({
pathToWasm: "/FluexGL-DSP-WASM/fluexgl-dsp-wasm_bg.wasm",
pathToWorklet: "/FluexGL-DSP-WASM/fluexgl-dsp-processor.worklet",
options: {
overrideMaxAudioBufferNodes: true
}
});
await pipeline.InitializeDpsPipeline();
const audioDevice = await pipeline.ResolveDefaultAudioOutputDevice();
if (!audioDevice) return;
const master = audioDevice.GetMasterChannel();
const channel1 = audioDevice.CreateChannel();
const channel2 = audioDevice.CreateChannel();
const channel3 = audioDevice.CreateChannel();
channel1.Send(channel2);
channel2.Send(channel3);
channel3.Send(master);
})()