AudioClipPlayerPlays and manages AudioClip instances inside a Channel.
import { AudioClipPlayer, AudioClip, Channel } from "@fluex/fluexgl-dsp";
...
const context = audioDevice.GetContext();
const channel = audioDevice.CreateChannel();
const player = new AudioClipPlayer(context);
const clip = new AudioClip(audioSourceData);
player.AttachAudioClip(clip);
player.Send(channel);
Constructs a new AudioClipPlayer and wires it into the provided Channel.
new AudioClipPlayer(context: AudioContext): AudioClipPlayer;
context: AudioContext - The AudioContext used to create this player’s internal audio nodes.label: stringA human-readable label for debugging / UI purposes. Defaults to "AudioClipPlayer".
id: stringA unique id, automatically generated on construction. Should NOT be changed.
audioClips: AudioClip[]All AudioClip instances currently attached to this player.
outputGainNode: GainNode | nullInternal output gain node. This is where volume is applied and what gets connected to a target via Send().
context: AudioContext | nullThe AudioContext used to create this player’s internal nodes. Set during construction.
channel: Channel | Master | nullThe current send target (Channel or Master) this player is connected to. null when not routed.
AttachAudioClip(audioClip: AudioClip): voidAttaches an AudioClip to this player. Initializes the clip with this player and stores it in audioClips. Throws if the clip is already attached.
audioClip: AudioClip - The clip to attach.voidDetachAudioClip(clip: AudioClip): voidDetaches a previously attached AudioClip from this player. Throws if the clip is not attached.
clip: AudioClip - The clip to detach.voidSend(channel: Channel | Master): voidRoutes this player’s outputGainNode to a Channel or the Master by connecting to the target’s input node.
voidUnsend(): voidDisconnects this player’s outputGainNode from its current target (if any) and clears channel.
No arguments
voidSetVolume(value: number): voidSets the output volume by writing to outputGainNode.gain.value. The value is clamped between 0 and 1.
value: number - Volume from 0.0 (silent) to 1.0 (full scale). Values outside the range are clamped.voidStopAll(): voidStops playback for all attached clips by calling Stop() on each clip in audioClips.
No arguments
voidDispose(): voidStops all clips, disconnects routing, disconnects the output node, and clears internal references (clips, nodes, context, channel). Use when you no longer need this player.
No arguments
voidSetLabel(label: string): voidUpdates the label of this player.
label: string - New label.voidThis class does not emit custom events.
This class does not define public getters or setters.
import { AudioClip, Channel } from "@fluex/fluexgl-dsp";
const context = new AudioContext();
const channel = new Channel(context);
// Use the Channel-owned player in real usage
const clip = new AudioClip(audioSourceData);
channel.AttachAudioClip(clip);
// Stop everything routed through the channel’s player
channel.audioClipPlayer.StopAll();