BaseAudioContext
The BaseAudioContext
interface acts as a base definition for online and offline audio-processing graphs, as represented by AudioContext
and OfflineAudioContext
respectively.
Documentation BaseAudioContext by Mozilla Contributors, licensed under CC-BY-SA 2.5.
Instance Members
destination: AudioDestinationNode
Returns an AudioDestinationNode
representing the final destination of all audio in the context. It can be thought of as the audio-rendering device.
sampleRate: Float
Returns a float representing the sample rate (in samples per second) used by all nodes in this context. The sample-rate of an AudioContext
cannot be changed.
currentTime: Float
Returns a double representing an ever-increasing hardware time in seconds used for scheduling. It starts at 0
.
listener: AudioListener
Returns the AudioListener
object, used for 3D spatialization.
state: AudioContextState
Returns the current state of the AudioContext
.
onstatechange: haxe.Function
An event handler that runs when an event of type statechange
has fired. This occurs when the AudioContext
's state changes, due to the calling of one of the state change methods (AudioContext.suspend
, AudioContext.resume
, or AudioContext.close
).
resume(): js.lib.Promise<Void>
Resumes the progression of time in an audio context that has previously been suspended/paused.
Returns |
---|
js.lib.Promise<Void> |
createBuffer(numberOfChannels: Int, length: Int, sampleRate: Float): AudioBuffer
Creates a new, empty AudioBuffer
object, which can then be populated by data and played via an AudioBufferSourceNode
.
Name | Type |
---|---|
numberOfChannels |
Int |
length |
Int |
sampleRate |
Float |
Returns |
---|
AudioBuffer |
decodeAudioData(audioData: js.lib.ArrayBuffer, ?successCallback: Function, ?errorCallback: Function): js.lib.Promise<AudioBuffer>
Asynchronously decodes audio file data contained in an ArrayBuffer
. In this case, the ArrayBuffer is usually loaded from an XMLHttpRequest
's response
attribute after setting the responseType
to arraybuffer
. This method only works on complete files, not fragments of audio files.
Name | Type | Default |
---|---|---|
audioData |
js.lib.ArrayBuffer | |
successCallback |
Function | (optional) |
errorCallback |
Function | (optional) |
Returns |
---|
js.lib.Promise<AudioBuffer> |
createBufferSource(): AudioBufferSourceNode
Creates an AudioBufferSourceNode
, which can be used to play and manipulate audio data contained within an AudioBuffer
object. AudioBuffer
s are created using AudioContext.createBuffer
or returned by AudioContext.decodeAudioData
when it successfully decodes an audio track.
Returns |
---|
AudioBufferSourceNode |
createConstantSource(): ConstantSourceNode
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 |
createScriptProcessor(?bufferSize: Int = 0, ?numberOfInputChannels: Int = 2, ?numberOfOutputChannels: Int = 2): ScriptProcessorNode
Creates a ScriptProcessorNode
, which can be used for direct audio processing via JavaScript.
Name | Type | Default |
---|---|---|
bufferSize |
Int | 0 |
numberOfInputChannels |
Int | 2 |
numberOfOutputChannels |
Int | 2 |
Returns |
---|
ScriptProcessorNode |
createAnalyser(): AnalyserNode
Creates an AnalyserNode
, which can be used to expose audio time and frequency data and for example to create data visualisations.
Returns |
---|
AnalyserNode |
createGain(): GainNode
Creates a GainNode
, which can be used to control the overall volume of the audio graph.
Returns |
---|
GainNode |
Creates a DelayNode
, 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.
Name | Type | Default |
---|---|---|
maxDelayTime |
Float | 1.0 |
Returns |
---|
DelayNode |
createBiquadFilter(): BiquadFilterNode
Creates a BiquadFilterNode
, which represents a second order filter configurable as several different common filter types: high-pass, low-pass, band-pass, etc
Returns |
---|
BiquadFilterNode |
createIIRFilter(feedforward: Array<Float>, feedback: Array<Float>): IIRFilterNode
Creates an IIRFilterNode
, which represents a second order filter configurable as several different common filter types.
Name | Type |
---|---|
feedforward |
Array<Float> |
feedback |
Array<Float> |
Returns |
---|
IIRFilterNode |
createWaveShaper(): WaveShaperNode
Creates a WaveShaperNode
, which is used to implement non-linear distortion effects.
Returns |
---|
WaveShaperNode |
createPanner(): PannerNode
Creates a PannerNode
, which is used to spatialise an incoming audio stream in 3D space.
Returns |
---|
PannerNode |
createStereoPanner(): StereoPannerNode
Creates a StereoPannerNode
, which can be used to apply stereo panning to an audio source.
Returns |
---|
StereoPannerNode |
createConvolver(): ConvolverNode
Creates a ConvolverNode
, which can be used to apply convolution effects to your audio graph, for example a reverberation effect.
Returns |
---|
ConvolverNode |
createChannelSplitter(?numberOfOutputs: Int = 6): ChannelSplitterNode
Creates a ChannelSplitterNode
, which is used to access the individual channels of an audio stream and process them separately.
Name | Type | Default |
---|---|---|
numberOfOutputs |
Int | 6 |
Returns |
---|
ChannelSplitterNode |
createChannelMerger(?numberOfInputs: Int = 6): ChannelMergerNode
Creates a ChannelMergerNode
, which is used to combine channels from multiple audio streams into a single audio stream.
Name | Type | Default |
---|---|---|
numberOfInputs |
Int | 6 |
Returns |
---|
ChannelMergerNode |
createDynamicsCompressor(): DynamicsCompressorNode
Creates a DynamicsCompressorNode
, which can be used to apply acoustic compression to an audio signal.
Returns |
---|
DynamicsCompressorNode |
createOscillator(): OscillatorNode
Creates an OscillatorNode
, a source representing a periodic waveform. It basically generates a tone.
Returns |
---|
OscillatorNode |
createPeriodicWave(real: js.lib.Float32Array, imag: js.lib.Float32Array, ?constraints: Null<PeriodicWaveConstraints>): PeriodicWave
Creates a PeriodicWave
, used to define a periodic waveform that can be used to determine the output of an OscillatorNode
.
Name | Type | Default |
---|---|---|
real |
js.lib.Float32Array | |
imag |
js.lib.Float32Array | |
constraints |
Null<PeriodicWaveConstraints> | (optional) |
Returns |
---|
PeriodicWave |