nx.js
Classes

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

PropertyTypeDescription
onstatechangenull | (this, ev) => anyMDN Reference

Accessors

audioWorklet

get audioWorklet(): AudioWorklet

Available only in secure contexts.

MDN Reference

Returns

AudioWorklet

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

AudioDestinationNode

Implementation of

globalThis.BaseAudioContext.destination


listener

get listener(): AudioListener

MDN Reference

Returns

AudioListener

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

ParameterType
typestring
callbacknull | EventListenerOrEventListenerObject<any>
options?boolean | AddEventListenerOptions

Returns

void

Implementation of

globalThis.BaseAudioContext.addEventListener

Inherited from

EventTarget.addEventListener

See

https://developer.mozilla.org/docs/Web/API/EventTarget/addEventListener


createAnalyser()

createAnalyser(): AnalyserNode

MDN Reference

Returns

AnalyserNode

Implementation of

globalThis.BaseAudioContext.createAnalyser


createBiquadFilter()

createBiquadFilter(): BiquadFilterNode

MDN Reference

Returns

BiquadFilterNode

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

ParameterType
numberOfChannelsnumber
lengthnumber
sampleRatenumber

Returns

AudioBuffer

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

AudioBufferSourceNode

Implementation of

globalThis.BaseAudioContext.createBufferSource

See

https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createBufferSource


createChannelMerger()

createChannelMerger(numberOfInputs?): ChannelMergerNode

MDN Reference

Parameters

ParameterType
numberOfInputs?number

Returns

ChannelMergerNode

Implementation of

globalThis.BaseAudioContext.createChannelMerger


createChannelSplitter()

createChannelSplitter(numberOfOutputs?): ChannelSplitterNode

MDN Reference

Parameters

ParameterType
numberOfOutputs?number

Returns

ChannelSplitterNode

Implementation of

globalThis.BaseAudioContext.createChannelSplitter


createConstantSource()

createConstantSource(): ConstantSourceNode

MDN Reference

Returns

ConstantSourceNode

Implementation of

globalThis.BaseAudioContext.createConstantSource


createConvolver()

createConvolver(): ConvolverNode

MDN Reference

Returns

ConvolverNode

Implementation of

globalThis.BaseAudioContext.createConvolver


createDelay()

createDelay(maxDelayTime?): DelayNode

MDN Reference

Parameters

ParameterType
maxDelayTime?number

Returns

DelayNode

Implementation of

globalThis.BaseAudioContext.createDelay


createDynamicsCompressor()

createDynamicsCompressor(): DynamicsCompressorNode

MDN Reference

Returns

DynamicsCompressorNode

Implementation of

globalThis.BaseAudioContext.createDynamicsCompressor


createGain()

createGain(): GainNode

Creates a GainNode for controlling volume.

Returns

GainNode

Implementation of

globalThis.BaseAudioContext.createGain

See

https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createGain


createIIRFilter()

createIIRFilter(feedforward, feedback): IIRFilterNode

MDN Reference

Parameters

ParameterType
feedforwardIterable<number, any, any> | number[]
feedbackIterable<number, any, any> | number[]

Returns

IIRFilterNode

Implementation of

globalThis.BaseAudioContext.createIIRFilter


createOscillator()

createOscillator(): OscillatorNode

MDN Reference

Returns

OscillatorNode

Implementation of

globalThis.BaseAudioContext.createOscillator


createPanner()

createPanner(): PannerNode

MDN Reference

Returns

PannerNode

Implementation of

globalThis.BaseAudioContext.createPanner


createPeriodicWave()

createPeriodicWave(real, imag, constraints?): PeriodicWave

MDN Reference

Parameters

ParameterType
realIterable<number, any, any> | number[] | Float32Array
imagIterable<number, any, any> | number[] | Float32Array
constraints?PeriodicWaveConstraints

Returns

PeriodicWave

Implementation of

globalThis.BaseAudioContext.createPeriodicWave


createScriptProcessor()

createScriptProcessor(bufferSize?, numberOfInputChannels?, numberOfOutputChannels?): ScriptProcessorNode

Parameters

ParameterType
bufferSize?number
numberOfInputChannels?number
numberOfOutputChannels?number

Returns

ScriptProcessorNode

Implementation of

globalThis.BaseAudioContext.createScriptProcessor

Deprecated

MDN Reference


createStereoPanner()

createStereoPanner(): StereoPannerNode

Creates a StereoPannerNode for panning across the stereo field.

Returns

StereoPannerNode

Implementation of

globalThis.BaseAudioContext.createStereoPanner

See

https://developer.mozilla.org/docs/Web/API/BaseAudioContext/createStereoPanner


createWaveShaper()

createWaveShaper(): WaveShaperNode

MDN Reference

Returns

WaveShaperNode

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

ParameterType
audioDataArrayBuffer
successCallback?null | DecodeSuccessCallback
errorCallback?null | DecodeErrorCallback

Returns

Promise<AudioBuffer>

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

ParameterType
eventEvent

Returns

boolean

Implementation of

globalThis.BaseAudioContext.dispatchEvent

Overrides

EventTarget.dispatchEvent

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

ParameterType
typestring
callbacknull | 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

On this page