BaseAudioContext
Base interface for online and offline audio-processing graphs, as represented by AudioContext and OfflineAudioContext respectively.
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext
Extends
Extended by
Implements
Properties
| Property | Type | Description |
|---|---|---|
onstatechange | null | (this, ev) => any | MDN Reference |
Accessors
audioWorklet
get audioWorklet(): AudioWorklet
Available only in secure contexts.
Returns
Implementation of
globalThis.BaseAudioContext.audioWorklet
currentTime
get currentTime(): number
The time, in seconds, of the sample frame currently being processed by
the audio graph. Starts at 0 and increases in real-time while the
context is running.
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/currentTime
Returns
number
Implementation of
globalThis.BaseAudioContext.currentTime
destination
get destination(): AudioDestinationNode
The final destination of the audio graph (the audio output device).
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/destination
Returns
Implementation of
globalThis.BaseAudioContext.destination
listener
get listener(): AudioListener
Returns
Implementation of
globalThis.BaseAudioContext.listener
sampleRate
get sampleRate(): number
The sample rate (in samples per second) used by all nodes in this context.
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/sampleRate
Returns
number
Implementation of
globalThis.BaseAudioContext.sampleRate
state
get state(): AudioContextState
The current state of the audio context: "suspended", "running" or
"closed".
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/state
Returns
AudioContextState
Implementation of
globalThis.BaseAudioContext.state
Methods
addEventListener()
addEventListener(type, callback, options?): void
Appends an event listener for events whose type attribute value is type. The callback argument sets the callback that will be invoked when the event is dispatched.
The options argument sets listener-specific options. For compatibility this can be a boolean, in which case the method behaves exactly as if the value was specified as options's capture.
When set to true, options's capture prevents callback from being invoked when the event's eventPhase attribute value is BUBBLING_PHASE. When false (or not present), callback will not be invoked when event's eventPhase attribute value is CAPTURING_PHASE. Either way, callback will be invoked if event's eventPhase attribute value is AT_TARGET.
When set to true, options's passive indicates that the callback will not cancel the event by invoking preventDefault(). This is used to enable performance optimizations described in § 2.8 Observing event listeners.
When set to true, options's once indicates that the callback will only be invoked once after which the event listener will be removed.
If an AbortSignal is passed for options's signal, then the event listener will be removed when signal is aborted.
The event listener is appended to target's event listener list and is not appended if it has the same type, callback, and capture.
Parameters
| Parameter | Type |
|---|---|
type | string |
callback | null | EventListenerOrEventListenerObject<any> |
options? | boolean | AddEventListenerOptions |
Returns
void
Implementation of
globalThis.BaseAudioContext.addEventListener
Inherited from
See
https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener
createAnalyser()
createAnalyser(): AnalyserNode
Returns
Implementation of
globalThis.BaseAudioContext.createAnalyser
createBiquadFilter()
createBiquadFilter(): BiquadFilterNode
Returns
Implementation of
globalThis.BaseAudioContext.createBiquadFilter
createBuffer()
createBuffer(numberOfChannels, length, sampleRate): AudioBuffer
Creates a new, empty AudioBuffer, which can be filled with data and played via an AudioBufferSourceNode.
Parameters
| Parameter | Type |
|---|---|
numberOfChannels | number |
length | number |
sampleRate | number |
Returns
Implementation of
globalThis.BaseAudioContext.createBuffer
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createBuffer
createBufferSource()
createBufferSource(): AudioBufferSourceNode
Creates an AudioBufferSourceNode for playing an AudioBuffer.
Returns
Implementation of
globalThis.BaseAudioContext.createBufferSource
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createBufferSource
createChannelMerger()
createChannelMerger(numberOfInputs?): ChannelMergerNode
Parameters
| Parameter | Type |
|---|---|
numberOfInputs? | number |
Returns
Implementation of
globalThis.BaseAudioContext.createChannelMerger
createChannelSplitter()
createChannelSplitter(numberOfOutputs?): ChannelSplitterNode
Parameters
| Parameter | Type |
|---|---|
numberOfOutputs? | number |
Returns
Implementation of
globalThis.BaseAudioContext.createChannelSplitter
createConstantSource()
createConstantSource(): ConstantSourceNode
Returns
Implementation of
globalThis.BaseAudioContext.createConstantSource
createConvolver()
createConvolver(): ConvolverNode
Returns
Implementation of
globalThis.BaseAudioContext.createConvolver
createDelay()
createDelay(maxDelayTime?): DelayNode
Parameters
| Parameter | Type |
|---|---|
maxDelayTime? | number |
Returns
Implementation of
globalThis.BaseAudioContext.createDelay
createDynamicsCompressor()
createDynamicsCompressor(): DynamicsCompressorNode
Returns
Implementation of
globalThis.BaseAudioContext.createDynamicsCompressor
createGain()
createGain(): GainNode
Creates a GainNode for controlling volume.
Returns
Implementation of
globalThis.BaseAudioContext.createGain
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createGain
createIIRFilter()
createIIRFilter(feedforward, feedback): IIRFilterNode
Parameters
| Parameter | Type |
|---|---|
feedforward | Iterable<number, any, any> | number[] |
feedback | Iterable<number, any, any> | number[] |
Returns
Implementation of
globalThis.BaseAudioContext.createIIRFilter
createOscillator()
createOscillator(): OscillatorNode
Returns
Implementation of
globalThis.BaseAudioContext.createOscillator
createPanner()
createPanner(): PannerNode
Returns
Implementation of
globalThis.BaseAudioContext.createPanner
createPeriodicWave()
createPeriodicWave(real, imag, constraints?): PeriodicWave
Parameters
| Parameter | Type |
|---|---|
real | Iterable<number, any, any> | number[] | Float32Array |
imag | Iterable<number, any, any> | number[] | Float32Array |
constraints? | PeriodicWaveConstraints |
Returns
Implementation of
globalThis.BaseAudioContext.createPeriodicWave
createScriptProcessor()
createScriptProcessor(bufferSize?, numberOfInputChannels?, numberOfOutputChannels?): ScriptProcessorNode
Parameters
| Parameter | Type |
|---|---|
bufferSize? | number |
numberOfInputChannels? | number |
numberOfOutputChannels? | number |
Returns
Implementation of
globalThis.BaseAudioContext.createScriptProcessor
Deprecated
createStereoPanner()
createStereoPanner(): StereoPannerNode
Creates a StereoPannerNode for panning across the stereo field.
Returns
Implementation of
globalThis.BaseAudioContext.createStereoPanner
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createStereoPanner
createWaveShaper()
createWaveShaper(): WaveShaperNode
Returns
Implementation of
globalThis.BaseAudioContext.createWaveShaper
decodeAudioData()
decodeAudioData(audioData, successCallback?, errorCallback?): Promise<AudioBuffer>
Asynchronously decodes audio file data contained in an ArrayBuffer
into an AudioBuffer.
Supported Audio Formats
Any audio container/codec supported by FFmpeg, including MP3, WAV, OGG Vorbis, Opus, FLAC and AAC/M4A.
Note
Unlike browsers, nx.js does NOT resample the decoded data to the context's sample rate — the returned buffer keeps the file's native rate (resampling happens at playback time).
Parameters
| Parameter | Type |
|---|---|
audioData | ArrayBuffer |
successCallback? | null | DecodeSuccessCallback |
errorCallback? | null | DecodeErrorCallback |
Returns
Implementation of
globalThis.BaseAudioContext.decodeAudioData
See
https://developer.mozilla.org/docs/Web/API/BaseAudioContext/decodeAudioData
dispatchEvent()
dispatchEvent(event): boolean
Dispatches a synthetic event event to target and returns true if either event's cancelable attribute value is false or its preventDefault() method was not invoked, and false otherwise.
Parameters
| Parameter | Type |
|---|---|
event | Event |
Returns
boolean
Implementation of
globalThis.BaseAudioContext.dispatchEvent
Overrides
See
https://developer.mozilla.org/docs/Web/API/EventTarget/dispatchEvent
removeEventListener()
removeEventListener(type, callback, options?): void
Removes the event listener in target's event listener list with the same type, callback, and options.
Parameters
| Parameter | Type |
|---|---|
type | string |
callback | null | EventListenerOrEventListenerObject<any> |
options? | boolean | EventListenerOptions |
Returns
void
Implementation of
globalThis.BaseAudioContext.removeEventListener
Inherited from
EventTarget.removeEventListener
See
https://developer.mozilla.org/docs/Web/API/EventTarget/removeEventListener