Movatterモバイル変換


[0]ホーム

URL:


  1. Web
  2. Web APIs
  3. BaseAudioContext

BaseAudioContext

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨April 2021⁩.

TheBaseAudioContext interface of theWeb Audio API acts as a base definition for online and offline audio-processing graphs, as represented byAudioContext andOfflineAudioContext respectively. You wouldn't useBaseAudioContext directly — you'd use its features via one of these two inheriting interfaces.

ABaseAudioContext can be a target of events, therefore it implements theEventTarget interface.

EventTarget BaseAudioContext

Instance properties

BaseAudioContext.audioWorkletRead onlySecure context

Returns theAudioWorklet object, which can be used to create and manageAudioNodes in which JavaScript code implementing theAudioWorkletProcessor interface are run in the background to process audio data.

BaseAudioContext.currentTimeRead only

Returns a double representing an ever-increasing hardware time in seconds used for scheduling. It starts at0.

BaseAudioContext.destinationRead only

Returns anAudioDestinationNode representing the final destination of all audio in the context. It can be thought of as the audio-rendering device.

BaseAudioContext.listenerRead only

Returns theAudioListener object, used for 3D spatialization.

BaseAudioContext.sampleRateRead only

Returns a float representing the sample rate (in samples per second) used by all nodes in this context. The sample-rate of anAudioContext cannot be changed.

BaseAudioContext.stateRead only

Returns the current state of theAudioContext.

Instance methods

Also implements methods from the interfaceEventTarget.

BaseAudioContext.createAnalyser()

Creates anAnalyserNode, which can be used to expose audio time and frequency data and for example to create data visualizations.

BaseAudioContext.createBiquadFilter()

Creates aBiquadFilterNode, which represents a second order filter configurable as several different common filter types: high-pass, low-pass, band-pass, etc

BaseAudioContext.createBuffer()

Creates a new, emptyAudioBuffer object, which can then be populated by data and played via anAudioBufferSourceNode.

BaseAudioContext.createBufferSource()

Creates anAudioBufferSourceNode, which can be used to play and manipulate audio data contained within anAudioBuffer object.AudioBuffers are created usingAudioContext.createBuffer() or returned byAudioContext.decodeAudioData() when it successfully decodes an audio track.

BaseAudioContext.createConstantSource()

Creates aConstantSourceNode object, which is an audio source that continuously outputs a monaural (one-channel) sound signal whose samples all have the same value.

BaseAudioContext.createChannelMerger()

Creates aChannelMergerNode, which is used to combine channels from multiple audio streams into a single audio stream.

BaseAudioContext.createChannelSplitter()

Creates aChannelSplitterNode, which is used to access the individual channels of an audio stream and process them separately.

BaseAudioContext.createConvolver()

Creates aConvolverNode, which can be used to apply convolution effects to your audio graph, for example a reverberation effect.

BaseAudioContext.createDelay()

Creates aDelayNode, which is used to delay the incoming audio signal by a certain amount. This node is also useful to create feedback loops in a Web Audio API graph.

BaseAudioContext.createDynamicsCompressor()

Creates aDynamicsCompressorNode, which can be used to apply acoustic compression to an audio signal.

BaseAudioContext.createGain()

Creates aGainNode, which can be used to control the overall volume of the audio graph.

BaseAudioContext.createIIRFilter()

Creates anIIRFilterNode, which represents a second order filter configurable as several different common filter types.

BaseAudioContext.createOscillator()

Creates anOscillatorNode, a source representing a periodic waveform. It basically generates a tone.

BaseAudioContext.createPanner()

Creates aPannerNode, which is used to spatialize an incoming audio stream in 3D space.

BaseAudioContext.createPeriodicWave()

Creates aPeriodicWave, used to define a periodic waveform that can be used to determine the output of anOscillatorNode.

BaseAudioContext.createScriptProcessor()Deprecated

Creates aScriptProcessorNode, which can be used for direct audio processing via JavaScript.

BaseAudioContext.createStereoPanner()

Creates aStereoPannerNode, which can be used to apply stereo panning to an audio source.

BaseAudioContext.createWaveShaper()

Creates aWaveShaperNode, which is used to implement non-linear distortion effects.

BaseAudioContext.decodeAudioData()

Asynchronously decodes audio file data contained in anArrayBuffer. In this case, theArrayBuffer is usually loaded from anXMLHttpRequest'sresponse attribute after setting theresponseType toarraybuffer. This method only works on complete files, not fragments of audio files.

Events

statechange

Fired when theAudioContext's state changes due to the calling of one of the state change methods (AudioContext.suspend,AudioContext.resume, orAudioContext.close).

Examples

js
const audioContext = new AudioContext();const oscillatorNode = audioContext.createOscillator();const gainNode = audioContext.createGain();const finish = audioContext.destination;

Specifications

Specification
Web Audio API
# BaseAudioContext

Browser compatibility

See also

Help improve MDN

Learn how to contribute

This page was last modified on byMDN contributors.


[8]ページ先頭

©2009-2025 Movatter.jp