Interface AudioContext
audioWorklet: AudioWorklet;
baseLatency: number;
currentTime: number;
destination: AudioDestinationNode;
listener: AudioListener;
onstatechange: (this: BaseAudioContext, ev: Event) => any;
outputLatency: number;
sampleRate: number;
state: AudioContextState;
addEventListener<K extends "statechange">(
type: K,
listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): void;
addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): void;
close(): Promise<void>;
createAnalyser(): AnalyserNode;
createBiquadFilter(): BiquadFilterNode;
createBuffer(
numberOfChannels: number,
length: number,
sampleRate: number,
): AudioBuffer;
createBufferSource(): AudioBufferSourceNode;
createChannelMerger(numberOfInputs?: number): ChannelMergerNode;
createChannelSplitter(numberOfOutputs?: number): ChannelSplitterNode;
createConstantSource(): ConstantSourceNode;
createConvolver(): ConvolverNode;
createDelay(maxDelayTime?: number): DelayNode;
createDynamicsCompressor(): DynamicsCompressorNode;
createGain(): GainNode;
createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode;
createIIRFilter(
feedforward: Iterable<number>,
feedback: Iterable<number>,
): IIRFilterNode;
createMediaElementSource(
mediaElement: HTMLMediaElement,
): MediaElementAudioSourceNode;
createMediaStreamDestination(): MediaStreamAudioDestinationNode;
createMediaStreamSource(
mediaStream: MediaStream,
): MediaStreamAudioSourceNode;
createOscillator(): OscillatorNode;
createPanner(): PannerNode;
createPeriodicWave(
real: number[] | Float32Array,
imag: number[] | Float32Array,
constraints?: PeriodicWaveConstraints,
): PeriodicWave;
createPeriodicWave(
real: Iterable<number>,
imag: Iterable<number>,
constraints?: PeriodicWaveConstraints,
): PeriodicWave;
createScriptProcessor(
bufferSize?: number,
numberOfInputChannels?: number,
numberOfOutputChannels?: number,
): ScriptProcessorNode;
createStereoPanner(): StereoPannerNode;
createWaveShaper(): WaveShaperNode;
decodeAudioData(
audioData: ArrayBuffer,
successCallback?: DecodeSuccessCallback,
errorCallback?: DecodeErrorCallback,
): Promise<AudioBuffer>;
dispatchEvent(event: Event): boolean;
getOutputTimestamp(): AudioTimestamp;
removeEventListener<K extends "statechange">(
type: K,
listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void;
removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void;
resume(): Promise<void>;
suspend(): Promise<void>;
}
Hierarchy
- BaseAudioContext
- AudioContext (View Summary)
Index
Properties
Methods
Properties
Readonly
audioWorklet
Available only in secure contexts.
Readonly
baseLatency
Readonly
currentTime
Readonly
destination
Readonly
listener
onstatechange
Readonly
outputLatency
Readonly
sampleRate
Readonly
state
Methods
addEventListener
- addEventListener<K extends "statechange">(
type: K,
listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any,
options?: boolean | AddEventListenerOptions,
): 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.
Type Parameters
Parameters
- type: K
- listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any
Optional
options: boolean | AddEventListenerOptions
Returns void
- addEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | AddEventListenerOptions,
): 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
- type: string
- listener: EventListenerOrEventListenerObject
Optional
options: boolean | AddEventListenerOptions
Returns void
close
createAnalyser
- createAnalyser(): AnalyserNode
Returns AnalyserNode
createBiquadFilter
- createBiquadFilter(): BiquadFilterNode
Returns BiquadFilterNode
createBuffer
- createBuffer(
numberOfChannels: number,
length: number,
sampleRate: number,
): AudioBuffer Parameters
- numberOfChannels: number
- length: number
- sampleRate: number
Returns AudioBuffer
createBufferSource
- createBufferSource(): AudioBufferSourceNode
Returns AudioBufferSourceNode
createChannelMerger
- createChannelMerger(numberOfInputs?: number): ChannelMergerNode
Parameters
Optional
numberOfInputs: number
Returns ChannelMergerNode
createChannelSplitter
- createChannelSplitter(numberOfOutputs?: number): ChannelSplitterNode
Parameters
Optional
numberOfOutputs: number
Returns ChannelSplitterNode
createConstantSource
- createConstantSource(): ConstantSourceNode
Returns ConstantSourceNode
createConvolver
- createConvolver(): ConvolverNode
Returns ConvolverNode
createDelay
createDynamicsCompressor
- createDynamicsCompressor(): DynamicsCompressorNode
Returns DynamicsCompressorNode
createGain
createIIRFilter
- createIIRFilter(feedforward: number[], feedback: number[]): IIRFilterNode
Parameters
- feedforward: number[]
- feedback: number[]
Returns IIRFilterNode
- createIIRFilter(
feedforward: Iterable<number>,
feedback: Iterable<number>,
): IIRFilterNode Returns IIRFilterNode
createMediaElementSource
- createMediaElementSource(
mediaElement: HTMLMediaElement,
): MediaElementAudioSourceNode Parameters
- mediaElement: HTMLMediaElement
Returns MediaElementAudioSourceNode
createMediaStreamDestination
- createMediaStreamDestination(): MediaStreamAudioDestinationNode
Returns MediaStreamAudioDestinationNode
createMediaStreamSource
- createMediaStreamSource(mediaStream: MediaStream): MediaStreamAudioSourceNode
Parameters
- mediaStream: MediaStream
Returns MediaStreamAudioSourceNode
createOscillator
- createOscillator(): OscillatorNode
Returns OscillatorNode
createPanner
- createPanner(): PannerNode
Returns PannerNode
createPeriodicWave
- createPeriodicWave(
real: number[] | Float32Array,
imag: number[] | Float32Array,
constraints?: PeriodicWaveConstraints,
): PeriodicWave Parameters
- real: number[] | Float32Array
- imag: number[] | Float32Array
Optional
constraints: PeriodicWaveConstraints
Returns PeriodicWave
- createPeriodicWave(
real: Iterable<number>,
imag: Iterable<number>,
constraints?: PeriodicWaveConstraints,
): PeriodicWave Parameters
- real: Iterable<number>
- imag: Iterable<number>
Optional
constraints: PeriodicWaveConstraints
Returns PeriodicWave
createScriptProcessor
- createScriptProcessor(
bufferSize?: number,
numberOfInputChannels?: number,
numberOfOutputChannels?: number,
): ScriptProcessorNode Parameters
Optional
bufferSize: numberOptional
numberOfInputChannels: numberOptional
numberOfOutputChannels: number
Returns ScriptProcessorNode
createStereoPanner
- createStereoPanner(): StereoPannerNode
Returns StereoPannerNode
createWaveShaper
- createWaveShaper(): WaveShaperNode
Returns WaveShaperNode
decodeAudioData
- decodeAudioData(
audioData: ArrayBuffer,
successCallback?: DecodeSuccessCallback,
errorCallback?: DecodeErrorCallback,
): Promise<AudioBuffer> Parameters
- audioData: ArrayBuffer
Optional
successCallback: DecodeSuccessCallbackOptional
errorCallback: DecodeErrorCallback
Returns Promise<AudioBuffer>
dispatchEvent
getOutputTimestamp
- getOutputTimestamp(): AudioTimestamp
Returns AudioTimestamp
removeEventListener
- removeEventListener<K extends "statechange">(
type: K,
listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any,
options?: boolean | EventListenerOptions,
): void Removes the event listener in target's event listener list with the same type, callback, and options.
Type Parameters
Parameters
- type: K
- listener: (this: AudioContext, ev: BaseAudioContextEventMap[K]) => any
Optional
options: boolean | EventListenerOptions
Returns void
- removeEventListener(
type: string,
listener: EventListenerOrEventListenerObject,
options?: boolean | EventListenerOptions,
): void Removes the event listener in target's event listener list with the same type, callback, and options.
Parameters
- type: string
- listener: EventListenerOrEventListenerObject
Optional
options: boolean | EventListenerOptions
Returns void
An audio-processing graph built from audio modules linked together, each represented by an AudioNode.
MDN Reference