BaseContext
class Core ↳ extends Emitter<"statechange" | "tick">
Emitter gives classes which extend it the ability to listen for and emit events. Inspiration and reference from Jerome Etienne’s MicroEvent. MIT (c) 2011 Jerome Etienne.
Constructor
Section titled “Constructor”new BaseContext()Properties
Section titled “Properties”latencyHint
Section titled “latencyHint”latencyHint: number | AudioContextLatencyCategorylookAhead
Section titled “lookAhead”lookAhead: numbercurrentTime
Section titled “currentTime”read-only
currentTime: numberThe currentTime read-only property of the BaseAudioContext interface returns a double representing an ever-increasing hardware timestamp in seconds that can be used for scheduling audio playback, visualizing timelines, etc. It starts at 0.
sampleRate
Section titled “sampleRate”read-only
sampleRate: numberThe sampleRate property of the BaseAudioContext interface returns a floating point number representing the sample rate, in samples per second, used by all nodes in this audio context. This limitation means that sample-rate converters are not supported.
read-only
state: AudioContextStateThe state read-only property of the BaseAudioContext interface returns the current state of the AudioContext.
Methods
Section titled “Methods”addAudioWorkletModule()
Section titled “addAudioWorkletModule()”addAudioWorkletModule(_url: string): Promise<void>Parameters
- _url
string
Returns Promise<void>
clearInterval()
Section titled “clearInterval()”clearInterval(_id: number): thisParameters
- _id
number
Returns this
clearTimeout()
Section titled “clearTimeout()”clearTimeout(_id: number): thisParameters
- _id
number
Returns this
createAnalyser()
Section titled “createAnalyser()”createAnalyser(): AnalyserNodeThe createAnalyser() method of the BaseAudioContext interface creates an AnalyserNode, which can be used to expose audio time and frequency data and create data visualizations.
Returns AnalyserNode
createAudioWorkletNode()
Section titled “createAudioWorkletNode()”createAudioWorkletNode(_name: string, _options?: Partial<AudioWorkletNodeOptions>): AudioWorkletNodeParameters
- _name
string - _options
Partial<AudioWorkletNodeOptions>optional
Returns AudioWorkletNode
createBiquadFilter()
Section titled “createBiquadFilter()”createBiquadFilter(): BiquadFilterNodeThe createBiquadFilter() method of the BaseAudioContext interface creates a BiquadFilterNode, which represents a second order filter configurable as several different common filter types.
Returns BiquadFilterNode
createBuffer()
Section titled “createBuffer()”createBuffer(_numberOfChannels: number, _length: number, _sampleRate: number): AudioBufferThe createBuffer() method of the BaseAudioContext Interface is used to create a new, empty AudioBuffer object, which can then be populated by data, and played via an AudioBufferSourceNode.
Parameters
- _numberOfChannels
number - _length
number - _sampleRate
number
Returns AudioBuffer
createBufferSource()
Section titled “createBufferSource()”createBufferSource(): AudioBufferSourceNodeThe createBufferSource() method of the BaseAudioContext Interface is used to create a new AudioBufferSourceNode, which can be used to play audio data contained within an AudioBuffer object. AudioBuffers are created using BaseAudioContext.createBuffer or returned by BaseAudioContext.decodeAudioData when it successfully decodes an audio track.
Returns AudioBufferSourceNode
createChannelMerger()
Section titled “createChannelMerger()”createChannelMerger(_numberOfInputs?: number): ChannelMergerNodeThe createChannelMerger() method of the BaseAudioContext interface creates a ChannelMergerNode, which combines channels from multiple audio streams into a single audio stream.
Parameters
- _numberOfInputs
numberoptional
Returns ChannelMergerNode
createChannelSplitter()
Section titled “createChannelSplitter()”createChannelSplitter(_numberOfOutputs?: number): ChannelSplitterNodeThe createChannelSplitter() method of the BaseAudioContext Interface is used to create a ChannelSplitterNode, which is used to access the individual channels of an audio stream and process them separately.
Parameters
- _numberOfOutputs
numberoptional
Returns ChannelSplitterNode
createConstantSource()
Section titled “createConstantSource()”createConstantSource(): ConstantSourceNodeThe createConstantSource() property of the BaseAudioContext interface creates a ConstantSourceNode object, which is an audio source that continuously outputs a monaural (one-channel) sound signal whose samples all have the same value.
Returns ConstantSourceNode
createConvolver()
Section titled “createConvolver()”createConvolver(): ConvolverNodeThe createConvolver() method of the BaseAudioContext interface creates a ConvolverNode, which is commonly used to apply reverb effects to your audio. See the spec definition of Convolution for more information.
Returns ConvolverNode
createDelay()
Section titled “createDelay()”createDelay(_maxDelayTime?: number): DelayNodeThe createDelay() method of the BaseAudioContext Interface is used to create a DelayNode, which is used to delay the incoming audio signal by a certain amount of time.
Parameters
- _maxDelayTime
numberoptional
Returns DelayNode
createDynamicsCompressor()
Section titled “createDynamicsCompressor()”createDynamicsCompressor(): DynamicsCompressorNodeThe createDynamicsCompressor() method of the BaseAudioContext Interface is used to create a DynamicsCompressorNode, which can be used to apply compression to an audio signal.
Returns DynamicsCompressorNode
createGain()
Section titled “createGain()”createGain(): GainNodeThe createGain() method of the BaseAudioContext interface creates a GainNode, which can be used to control the overall gain (or volume) of the audio graph.
Returns GainNode
createIIRFilter()
Section titled “createIIRFilter()”createIIRFilter(_feedForward: number[] | Float32Array<ArrayBuffer>, _feedback: number[] | Float32Array<ArrayBuffer>): IIRFilterNodeThe createIIRFilter() method of the BaseAudioContext interface creates an IIRFilterNode, which represents a general infinite impulse response (IIR) filter which can be configured to serve as various types of filter.
Parameters
- _feedForward
number[] | Float32Array<ArrayBuffer> - _feedback
number[] | Float32Array<ArrayBuffer>
Returns IIRFilterNode
createMediaElementSource()
Section titled “createMediaElementSource()”createMediaElementSource(_element: HTMLMediaElement): MediaElementAudioSourceNodeParameters
- _element
HTMLMediaElement
Returns MediaElementAudioSourceNode
createMediaStreamDestination()
Section titled “createMediaStreamDestination()”createMediaStreamDestination(): MediaStreamAudioDestinationNodeReturns MediaStreamAudioDestinationNode
createMediaStreamSource()
Section titled “createMediaStreamSource()”createMediaStreamSource(_stream: MediaStream): MediaStreamAudioSourceNodeParameters
- _stream
MediaStream
Returns MediaStreamAudioSourceNode
createOscillator()
Section titled “createOscillator()”createOscillator(): OscillatorNodeThe createOscillator() method of the BaseAudioContext interface creates an OscillatorNode, a source representing a periodic waveform. It basically generates a constant tone.
Returns OscillatorNode
createPanner()
Section titled “createPanner()”createPanner(): PannerNodeThe createPanner() method of the BaseAudioContext Interface is used to create a new PannerNode, which is used to spatialize an incoming audio stream in 3D space.
Returns PannerNode
createPeriodicWave()
Section titled “createPeriodicWave()”createPeriodicWave(_real: number[] | Float32Array<ArrayBuffer>, _imag: number[] | Float32Array<ArrayBuffer>, _constraints?: PeriodicWaveConstraints): PeriodicWaveThe createPeriodicWave() method of the BaseAudioContext interface is used to create a PeriodicWave. This wave is used to define a periodic waveform that can be used to shape the output of an OscillatorNode.
Parameters
- _real
number[] | Float32Array<ArrayBuffer> - _imag
number[] | Float32Array<ArrayBuffer> - _constraints
PeriodicWaveConstraintsoptional
Returns PeriodicWave
createStereoPanner()
Section titled “createStereoPanner()”createStereoPanner(): StereoPannerNodeThe createStereoPanner() method of the BaseAudioContext interface creates a StereoPannerNode, which can be used to apply stereo panning to an audio source. It positions an incoming audio stream in a stereo image using a low-cost panning algorithm.
Returns StereoPannerNode
createWaveShaper()
Section titled “createWaveShaper()”createWaveShaper(): WaveShaperNodeThe createWaveShaper() method of the BaseAudioContext interface creates a WaveShaperNode, which represents a non-linear distortion. It is used to apply distortion effects to your audio.
Returns WaveShaperNode
decodeAudioData()
Section titled “decodeAudioData()”decodeAudioData(_audioData: ArrayBuffer): Promise<AudioBuffer>The decodeAudioData() method of the BaseAudioContext Interface is used to asynchronously decode audio file data contained in an ArrayBuffer that is loaded from fetch(), XMLHttpRequest, or FileReader. The decoded AudioBuffer is resampled to the AudioContext’s sampling rate, then passed to a callback or promise.
Parameters
- _audioData
ArrayBuffer
Returns Promise<AudioBuffer>
emit()
Section titled “emit()”↳ inherited from Emitter
emit(event: "statechange" | "tick", ...args: any[]): thisInvoke all of the callbacks bound to the event with any arguments passed in.
Parameters
-
event
"statechange" | "tick"The name of the event.
-
args
any[]The arguments to pass to the functions listening.
Returns this
getConstant()
Section titled “getConstant()”getConstant(_val: number): AudioBufferSourceNodeParameters
- _val
number
Returns AudioBufferSourceNode
↳ inherited from Emitter
off(event: "statechange" | "tick", callback?: (...args: any[]) => void): thisRemove the event listener.
Parameters
-
event
"statechange" | "tick"The event to stop listening to.
-
callback
(…args: any[]) => voidoptionalThe callback which was bound to the event with Emitter.on. If no callback is given, all callbacks events are removed.
Returns this
↳ inherited from Emitter
on(event: "statechange" | "tick", callback: (...args: any[]) => void): thisBind a callback to a specific event.
Parameters
-
event
"statechange" | "tick"The name of the event to listen for.
-
callback
(…args: any[]) => voidThe callback to invoke when the event is emitted
Returns this
once()
Section titled “once()”↳ inherited from Emitter
once(event: "statechange" | "tick", callback: (...args: any[]) => void): thisBind a callback which is only invoked once
Parameters
-
event
"statechange" | "tick"The name of the event to listen for.
-
callback
(…args: any[]) => voidThe callback to invoke when the event is emitted
Returns this
setInterval()
Section titled “setInterval()”setInterval(_fn: (...args: any[]) => void, _interval: number): numberParameters
- _fn
(…args: any[]) => void - _interval
number
Returns number
setTimeout()
Section titled “setTimeout()”setTimeout(_fn: (...args: any[]) => void, _timeout: number): numberParameters
- _fn
(…args: any[]) => void - _timeout
number
Returns number
mixin()
Section titled “mixin()”static ↳ inherited from Emitter
mixin(constr: any): voidAdd Emitter functions (on/off/emit) to the object
Parameters
- constr
any
Inherited members
Section titled “Inherited members”- From
Tone: debug, version, disposed, toString(), getDefaults()