Class AudioNode

java.lang.Object
com.codename1.media.audio.AudioNode
Direct Known Subclasses:
AnalyserNode, AudioDestinationNode, AudioProcessorNode, AudioScheduledSourceNode, BiquadFilterNode, ChannelMergerNode, ChannelSplitterNode, ConvolverNode, DelayNode, DynamicsCompressorNode, GainNode, IIRFilterNode, MicrophoneSourceNode, PannerNode, StereoPannerNode, WaveShaperNode

public abstract class AudioNode extends Object

A processing block of an audio graph, the Web Audio AudioNode.

Nodes are created by a context (context.createGain() and so on) and wired with connect(AudioNode); audio is heard once a path reaches BaseAudioContext.getDestination(). Each input mixes everything connected to it to a channel count decided by getChannelCountMode(), getChannelCount() and getChannelInterpretation(), following the specification's mixing rules.

A cycle in the graph must contain a DelayNode; a cycle without one is rendered as silence, as the specification requires. Every method may be called from any thread; changes reach the renderer at its next render quantum.

  • Method Details

    • getContext

      public BaseAudioContext getContext()

      The context that created this node.

      Returns

      the context

    • getNumberOfInputs

      public int getNumberOfInputs()

      The number of inputs.

      Returns

      0 for a source node

    • getNumberOfOutputs

      public int getNumberOfOutputs()

      The number of outputs.

      Returns

      0 for the destination

    • getChannelCount

      public int getChannelCount()

      The channel count inputs are mixed to, subject to the channel count mode.

      Returns

      the channel count

    • setChannelCount

      public void setChannelCount(int count)

      Sets the channel count.

      Parameters
      • count: 1 to 32, or less for nodes that restrict it
    • getChannelCountMode

      public ChannelCountMode getChannelCountMode()

      How the channel count of each input is decided.

      Returns

      the mode

    • setChannelCountMode

      public void setChannelCountMode(ChannelCountMode mode)

      Sets how the channel count of each input is decided.

      Parameters
      • mode: the mode
    • getChannelInterpretation

      public ChannelInterpretation getChannelInterpretation()

      How channels are up-mixed and down-mixed.

      Returns

      the interpretation

    • setChannelInterpretation

      public void setChannelInterpretation(ChannelInterpretation interpretation)

      Sets how channels are up-mixed and down-mixed.

      Parameters
      • interpretation: the interpretation
    • connect

      public AudioNode connect(AudioNode destination)

      Connects output 0 to input 0 of destination.

      Parameters
      • destination: the node to feed
      Returns

      destination, so connections can be chained

    • connect

      public AudioNode connect(AudioNode destination, int output, int input)

      Connects an output of this node to an input of destination. Connecting the same pair twice has no further effect.

      Parameters
      • destination: the node to feed

      • output: the output of this node

      • input: the input of destination

      Returns

      destination

    • connect

      public void connect(AudioParam param)

      Connects output 0 to an AudioParam, whose value then has this output, mixed down to mono, added to it.

      Parameters
      • param: the parameter to modulate
    • connect

      public void connect(AudioParam param, int output)

      Connects an output to an AudioParam.

      Parameters
      • param: the parameter to modulate

      • output: the output of this node

    • disconnect

      public void disconnect()
      Removes every outgoing connection.
    • disconnect

      public void disconnect(int output)

      Removes every connection from one output.

      Parameters
      • output: the output of this node
    • disconnect

      public void disconnect(AudioNode destination)

      Removes every connection to destination.

      Parameters
      • destination: the node to stop feeding
    • disconnect

      public void disconnect(AudioNode destination, int output, int input)

      Removes one connection.

      Parameters
      • destination: the node fed

      • output: the output of this node

      • input: the input of destination

    • disconnect

      public void disconnect(AudioParam param)

      Removes every connection to param.

      Parameters
      • param: the parameter to stop modulating