AudioBuffer
Objects of these types are designed to hold small audio snippets, typically less than 45 s. For longer sounds, objects implementing the MediaElementAudioSourceNode
are more suitable. The buffer contains data in the following format: non-interleaved IEEE754 32-bit linear PCM with a nominal range between -1
and +1
, that is, 32bits floating point buffer, with each samples between -1.0 and 1.0. If the AudioBuffer
has multiple channels, they are stored in separate buffer.
Documentation AudioBuffer by Mozilla Contributors, licensed under CC-BY-SA 2.5.
Instance Members
sampleRate: Float
Returns a float representing the sample rate, in samples per second, of the PCM data stored in the buffer.
length: Int
Returns an integer representing the length, in sample-frames, of the PCM data stored in the buffer.
duration: Float
Returns a double representing the duration, in seconds, of the PCM data stored in the buffer.
numberOfChannels: Int
Returns an integer representing the number of discrete audio channels described by the PCM data stored in the buffer.
getChannelData(channel: Int): js.lib.Float32Array
Returns a Float32Array
containing the PCM data associated with the channel, defined by the channel
parameter (with 0
representing the first channel).
Name | Type |
---|---|
channel |
Int |
Returns |
---|
js.lib.Float32Array |
copyFromChannel(destination: js.lib.Float32Array, channelNumber: Int, ?startInChannel: Int = 0): Void
Copies the samples from the specified channel of the AudioBuffer
to the destination
array.
Name | Type | Default |
---|---|---|
destination |
js.lib.Float32Array | |
channelNumber |
Int | |
startInChannel |
Int | 0 |
copyToChannel(source: js.lib.Float32Array, channelNumber: Int, ?startInChannel: Int = 0): Void
Copies the samples to the specified channel of the AudioBuffer
, from the source
array.
Name | Type | Default |
---|---|---|
source |
js.lib.Float32Array | |
channelNumber |
Int | |
startInChannel |
Int | 0 |
new(options: AudioBufferOptions): Void
Name | Type |
---|---|
options |
AudioBufferOptions |