Skip to content

Module: src/settings/AudioControls

The AudioControls component provides an equalizer for adjusting multiple frequency bands of the audio output. It integrates with the player’s internal audio processing chain and provides real-time feedback for all adjustments. This component is part of the player’s extended audio feature set and attaches its UI to the 'controls' popup component.

Version
1.0.0
Author
Frank Kudermann - alphanull
License
MIT
Requires
DomSmith
Source
AudioControls.js, line 13

Constructor

new AudioControls(player, parent, optionsopt)

Creates an instance of the AudioControls Component.

Parameters:
Name Type Attributes Description
player Player

Reference to the media player instance.

parent Popup

Reference to the parent instance (In this case the settings popup).

options Object optional

Additional options.

Parameters:
Name Type Attributes Description
apiKey symbol optional

Token for extended access to the player API.

Members

Holds the instance configuration for this component.

Properties
Name Type Attributes Default Description
bands Array<number> optional [1, 1, 1, 1, 1]

Default frequency band values. Each band controls a specific frequency range from low to high.

Type
Object
Source
AudioControls.js, line 20

Reference to the main player instance.

Type
Player
Source
AudioControls.js, line 28

Secret key only known to the player instance and initialized components. Used to be able to restrict access to API methods in conjunction with secure mode.

Type
symbol
Source
AudioControls.js, line 35

Reference to the DomSmith instance. Displays UI elements for the equalizer.

Type
DomSmith
Source
AudioControls.js, line 41

Use the shared AudioContext from the player's Audio Manager.

Type
AudioContext
Source
AudioControls.js, line 47

Logarithmically spaced crossover frequencies.

Type
Array<number>
Source
AudioControls.js, line 53

Stores all frequency bands.

Type
Array<{gainNode: GainNode, filters: Array<BiquadFilterNode>}>
Source
AudioControls.js, line 59

Master output gain node.

Type
GainNode
Source
AudioControls.js, line 65

Gain node for the bypass path.

Type
GainNode
Source
AudioControls.js, line 71

Input gain node for the equalizer path.

Type
GainNode
Source
AudioControls.js, line 77

Output gain node for the equalizer path.

Type
GainNode
Source
AudioControls.js, line 83

Main input gain node that connects to both bypass and EQ paths.

Type
GainNode
Source
AudioControls.js, line 89

Stores shared filter instances to optimize processing.

Type
Array<{low: Array<BiquadFilterNode>, high: Array<BiquadFilterNode>}> | null
Source
AudioControls.js, line 95

Methods

private #createSubgraph()

Creates the audio processing subgraph for the equalizer. Sets up gain nodes for master output, bypass, and EQ paths.

Source
AudioControls.js, line 207

private #buildLinkwitzRileyChain()

Builds a multi-band Linkwitz-Riley crossover filter chain. This method divides the frequency spectrum into multiple bands and applies separate gain nodes to each band.

Source
AudioControls.js, line 237

private #createLinkwitzRiley(freq) → Object

Creates a 4th-order Linkwitz-Riley crossover at a given frequency. This method generates two cascaded biquad filters for both low-pass and high-pass filtering, resulting in a smooth crossover.

Parameters:
Name Type Description
freq number

The crossover frequency in Hz.

Returns

An object containing low-pass and high-pass filter arrays.

Type Object
Source
AudioControls.js, line 308

private #applySettings(targetopt)

Updates the gains of the equalizer bands when a slider changes or during initialization. If all sliders remain at neutral (1.0), the EQ is bypassed entirely. Otherwise, the equalizer bands are adjusted dynamically based on user input.

Parameters:
Name Type Attributes Description
target Event optional

The event object containing the modified slider reference.

Source
AudioControls.js, line 347

private #fadeGain(gParam, value)

Smoothly transitions the gain parameter to a target value. Uses setTargetAtTime for a subtle and natural fade effect.

Parameters:
Name Type Description
gParam AudioParam

The gain parameter to adjust.

value number

The target gain value.

Source
AudioControls.js, line 391

private #reset()

Resets all equalizer bands to their default values. Updates the UI and applies the default band settings.

Source
AudioControls.js, line 402

private #disconnectAudio()

Disconnects and cleans up all audio nodes related to the equalizer. Ensures that all gain nodes, filters, and input/output connections are properly removed.

Source
AudioControls.js, line 416

destroy()

This method removes all events, subscriptions and DOM nodes created by this component.

Source
AudioControls.js, line 446