- Version
- 1.0.0
- License
- MIT
- Requires
- DomSmith
- Source
- AudioControls.js, line 13
Constructor
new AudioControls(player, parent, optionsopt)
Creates an instance of the AudioControls Component.
| 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.
|
Members
private #config :Object
Holds the instance configuration for this component.
| 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
private #player :Player
Reference to the main player instance.
- Type
- Player
- Source
- AudioControls.js, line 28
private #apiKey :symbol
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
private #dom :DomSmith
Reference to the DomSmith instance. Displays UI elements for the equalizer.
- Type
- DomSmith
- Source
- AudioControls.js, line 41
private #audioCtx :AudioContext
Use the shared AudioContext from the player's Audio Manager.
- Type
- AudioContext
- Source
- AudioControls.js, line 47
private #edges :Array<number>
Logarithmically spaced crossover frequencies.
- Type
- Array<number>
- Source
- AudioControls.js, line 53
private #eqBands :Array<{gainNode: GainNode, filters: Array<BiquadFilterNode>}>
Stores all frequency bands.
- Type
- Array<{gainNode: GainNode, filters: Array<BiquadFilterNode>}>
- Source
- AudioControls.js, line 59
private #output :GainNode
Master output gain node.
- Type
- GainNode
- Source
- AudioControls.js, line 65
private #bypassGain :GainNode
Gain node for the bypass path.
- Type
- GainNode
- Source
- AudioControls.js, line 71
private #eqInput :GainNode
Input gain node for the equalizer path.
- Type
- GainNode
- Source
- AudioControls.js, line 77
private #eqOutput :GainNode
Output gain node for the equalizer path.
- Type
- GainNode
- Source
- AudioControls.js, line 83
private #input :GainNode
Main input gain node that connects to both bypass and EQ paths.
- Type
- GainNode
- Source
- AudioControls.js, line 89
private #sharedFilters :Array<{low: Array<BiquadFilterNode>, high: Array<BiquadFilterNode>}>|null
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.
| 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.
| 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.
| 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