Options
All
  • Public
  • Public/Protected
  • All
Menu

Class AudioChannel

The audio-channel class used to manage AudioMixer's channels. Each channel have a few basic controllers (Volume, Panning and Basic EQ) to modify the audio-output of all the connected audio sources.

Hierarchy

  • AudioChannel

Index

Constructors

  • Create a new AudioChannel to connect and take control over multiple audio sources.

    example

    Standard JavaScript

    const mixer = muses.createAudioMixer( ) ;
    const channel = new muses.AudioChannel( mixer ) ;
    example

    TypeScript

    const mixer : AudioMixer = createAudioMixer( ) ;
    const channel : AudioChannel = new AudioChannel( mixer ) ;
    // use it [v] ;
    channel.input( $audioElement ) ;
    channel.volume = 0.4 ;
    channel.panning = -0.4 ;

    Parameters

    • mixingConsole: AudioMixer

      The parent AudioMixer instance.

    Returns AudioChannel

Properties

HighEQNode: BiquadFilterNode
LowEQNode: BiquadFilterNode
MidEQNode: BiquadFilterNode
customNodes: AudioNode[] = []
gainNode: GainNode
id: string = "N/A"

The current channel id provided from AudioMixer instance

inputNode: GainNode
mixer: AudioMixer
outputNode: GainNode
stereoPannerNode: StereoPannerNode
tracks: AudioTrack[] = []

All the AudioTracks added to the current channel. WARNING: Other sources (like manual stream-source additions) will be not showed in this array, only AudioTrack instances added through input() method.

Accessors

  • get highEQ(): number
  • set highEQ(value: number): void
  • Get the current high-EQ value

    Returns number

  • Modify the high-EQ value of the current channel (from -40 to 36) dB

    Parameters

    • value: number

      from -40dB to 36dB

    Returns void

  • get lowEQ(): number
  • set lowEQ(value: number): void
  • Get the current low-EQ value

    Returns number

  • Modify the low-EQ value of the current channel (from -40 to 36) dB

    Parameters

    • value: number

      from -40dB to 36dB

    Returns void

  • get midEQ(): number
  • set midEQ(value: number): void
  • Get the current mid-EQ value

    Returns number

  • Modify the mid-EQ value of the current channel (from -40 to 36) dB

    Parameters

    • value: number

      from -40dB to 36dB

    Returns void

  • get muted(): boolean
  • set muted(status: boolean): void
  • Check if the current channel is muted

    Returns boolean

  • Mute output signal from the current channel

    Parameters

    • status: boolean

    Returns void

  • get pan(): number
  • set pan(value: number): void
  • Get the current Panning Effect value

    Returns number

  • Modify the Panning Effect (-1 Left, 1 Right, 0 Center)

    Parameters

    • value: number

    Returns void

  • get volume(): number
  • set volume(value: number): void
  • Get the current Gain value

    Returns number

  • Modify the Gain of the current channel (from 0 to 1)

    Parameters

    • value: number

    Returns void

Methods

  • addNode(customNode: AudioNode): void
  • Add a custom node or effect to the channel (in-order).

    Parameters

    • customNode: AudioNode

      The effect or audio node to connect between the channelOutputNode nad the mixerInputNode.

    Returns void

  • Connect a track to the current audio-channel instance.

    Parameters

    • track: AudioTrack

      The audio-track instance to connect processing nodes.

    Returns AudioChannel

    • The current audio-channel instance.
  • connect(node: AudioContext | AudioNode): void
  • Send outputNode signal to a custom AudioNode or AudioContext instance. Warning: Be sure to disconnect the current audio-context or audio-node.

    Parameters

    • node: AudioContext | AudioNode

    Returns void

    The current channel instance.

  • connectToContext(): AudioContext
  • Connect to the audio-context component (Generally used to hear it in the speakers)

    Returns AudioContext

    The audio-context used in the current channel's mixing-console.

  • disconnect(node?: AudioContext | AudioNode): void
  • Disconnect from one or all current AudioNode receivers.

    Parameters

    • Optional node: AudioContext | AudioNode

    Returns void

  • Disconnect from the audio-context component used in the current channel's mixing-console.

    Returns AudioChannel

    The current audio-channel instance.

  • fadeIn(ms?: number): Promise<boolean>
  • Increase volume smoothly until it's in maximun input volume (this doesn't affect other features like "muted" or "volume" properties)

    Parameters

    • ms: number = 2000

    Returns Promise<boolean>

  • fadeOut(ms?: number): Promise<boolean>
  • Decrease volume smoothly until it is silent

    Parameters

    • ms: number = 2000

    Returns Promise<boolean>

  • input(source: String | MediaStreamAudioSourceNode | AudioTrack | MediaElementAudioSourceNode | HTMLAudioElement): AudioNode | AudioTrack
  • Add a new audio input from an audio-element, stream-source, media-source or create a new element by loading a file from a provided URL

    Parameters

    • source: String | MediaStreamAudioSourceNode | AudioTrack | MediaElementAudioSourceNode | HTMLAudioElement

      An audio-element to create a new AudioTrack instance, an URL of the file to create that element automatically (Base64 supported) or the audio-node to connect directly into channel's inputNode

    Returns AudioNode | AudioTrack

  • reconnectNodes(): void
  • Reconnect all custom nodes if you have added them previously (outputNode -> customNodes -> mixerInputNode). If you don't have custom nodes added, this method will ensure the connection between the channelOutputNode and the mixerInputNode.

    Returns void

  • removeAllNodes(): void
  • Remove all custom nodes from the channel and then reconnect the channel-output with the mixer-input.

    Returns void

  • removeNode(node: AudioNode): void
  • Remove an specific customNode from the channel's customNodes list and then reconnect all nodes.

    Parameters

    • node: AudioNode

      The previously added effect or audio node.

    Returns void

Generated using TypeDoc