AudioDeviceRepresents an audio output device wrapper that owns an AudioContext and helps create and manage Channel and Master routing objects. Usually constructed when calling ResolveDefaultAudioOutputDevice().
import { AudioDevice } from "@fluex/fluexgl-dsp";
// MediaDeviceInfo is typically retrieved from navigator.mediaDevices.enumerateDevices()
const deviceInfo = myMediaDeviceInfo;
const device = new AudioDevice(deviceInfo);
const channel = device.CreateChannel();
// Create an additional master bus and set it as active
const master = device.CreateMasterChannel();
device.SetMasterChannel(master);
Constructs a new AudioDevice for the given output device and creates an internal AudioContext along with its default master channel.
new AudioDevice(public deviceInfo: MediaDeviceInfo): AudioDevice;
deviceInfo: MediaDeviceInfo - The selected output device information (from enumerateDevices()).id: stringA unique id for this AudioDevice instance. Automatically generated when constructing the device. Should NOT be changed.
timestamp: numberCreation timestamp (Date.now()) for this AudioDevice instance.
context: AudioContextThe AudioContext owned by this device. Used for creating channels and master busses.
masterChannel: MasterThe currently selected active Master channel for this device.
masterChannels: Master[]All created Master channels owned by this device.
GetMasterChannel(): MasterReturns the currently active Master channel.
No arguments
SetMasterChannel(channel: Master): voidSets the active Master channel. This is typically one of the entries in masterChannels.
channel: Master - The master channel to set as active.voidCreateMasterChannel(): MasterCreates a new Master channel using this device’s AudioContext, stores it in masterChannels, and returns it.
No arguments
GetContext(): AudioContextReturns this device’s AudioContext.
No arguments
AudioContextCreateChannel(): ChannelCreates and returns a new Channel using this device’s AudioContext.
No arguments
This class does not emit custom events.
This class does not define public getters or setters.
const device = new AudioDevice(deviceInfo);
const a = device.CreateChannel();
const b = device.CreateChannel();
// Route a into b, and b into the active master
a.Send(b);
b.Send(device.GetMasterChannel());
const device = new AudioDevice(deviceInfo);
const masterA = device.GetMasterChannel();
const masterB = device.CreateMasterChannel();
// Switch active master
device.SetMasterChannel(masterB);
// You can still keep references to older master channels
console.log(masterA.id, masterB.id);