Class BaseAudioContext

java.lang.Object
org.htmlunit.corejs.javascript.ScriptableObject
All Implemented Interfaces:
Serializable, Cloneable, org.htmlunit.corejs.javascript.ConstProperties, org.htmlunit.corejs.javascript.debug.DebuggableObject, org.htmlunit.corejs.javascript.Scriptable, org.htmlunit.corejs.javascript.SymbolScriptable
Direct Known Subclasses:
AudioContext, OfflineAudioContext

public class BaseAudioContext extends EventTarget
A JavaScript object for BaseAudioContext.
See Also:
  • Constructor Details

    • BaseAudioContext

      public BaseAudioContext()
      Creates an instance.
  • Method Details

    • jsConstructor

      public void jsConstructor()
      Creates an instance.
      Overrides:
      jsConstructor in class EventTarget
    • createBufferSource

      public AudioBufferSourceNode createBufferSource()
      Returns:
      a new AudioBufferSourceNode, which can be used to play audio data contained within an AudioBuffer object.
    • createBuffer

      public AudioBuffer createBuffer()
      Returns:
      new, empty AudioBuffer object, which can then be populated by data, and played via an AudioBufferSourceNode.
    • createGain

      public GainNode createGain()
      Returns:
      a GainNode, which can be used to control the overall gain (or volume) of the audio graph.
    • decodeAudioData

      public Object decodeAudioData(org.htmlunit.corejs.javascript.typedarrays.NativeArrayBuffer buffer, org.htmlunit.corejs.javascript.Function success, org.htmlunit.corejs.javascript.Function error)
      The decodeAudioData() method of the BaseAudioContext Interface is used to asynchronously decode audio file data contained in an ArrayBuffer. In this case the ArrayBuffer is loaded from XMLHttpRequest and FileReader. The decoded AudioBuffer is resampled to the AudioContext's sampling rate, then passed to a callback or promise.
      Parameters:
      buffer - An ArrayBuffer containing the audio data to be decoded, usually grabbed from XMLHttpRequest, WindowOrWorkerGlobalScope.fetch() or FileReader
      success - A callback function to be invoked when the decoding successfully finishes. The single argument to this callback is an AudioBuffer representing the decodedData (the decoded PCM audio data). Usually you'll want to put the decoded data into an AudioBufferSourceNode, from which it can be played and manipulated how you want.
      error - An optional error callback, to be invoked if an error occurs when the audio data is being decoded.
      Returns:
      the promise or null