audio-buffer-from
Create AudioBuffer from any source.
Usage
var createBuffer = //mono-buffer 1024 samplesvar abuf = //stereo-buffer 1024 samplesvar abuf2 = //buffer from data with bound audio contextvar abuf3 = //empty 1-sample mono buffer with default contextvar abuf4 = //0-length no-context buffervar abuf5 = //from durationvar abuf6 = //from pcm datavar abuf7 = //from data-urivar abuf8 = //from base64 stringvar abuf9 = //from node Buffervar abuf10 =
API
audioBuffer = createBuffer(source|length, channels|format|options)
Create audio buffer from any source
data or a number indicating length
, pass options
to ensure output buffer parameters. A channels
number or format
string can be used to shorthand options argument.
Source:
Type | Interpretation |
---|---|
null |
Blank 1-sample length buffer. |
Number |
Length of resulting buffer. |
Array of Arrays |
Every subarray is considered a channel data. |
AudioBuffer |
Clone other AudioBuffer. |
AudioBufferList |
Coalesce AudioBufferList to AudioBuffer. |
Audio |
Retrieve AudioBuffer from Audio. |
Object |
Create based on length /duration , channels /numberOfChannels and sampleRate properties. |
Array of Numbers |
Raw data, interpreted by options.format , defaults to float64 . |
Float32Array |
Raw float32 data, amplitude range is -1..+1 . |
Float64Array |
Raw float64 data, amplitude range is -1..+1 . |
Int8Array |
Raw int8 data, amplitude range is -128..+127 . |
Uint8Array |
Raw uint8 data, amplitude range is 0..255 . |
TypedArray |
Any other typed array, described by options.format argument (see pcm-convert). |
ArrayBuffer |
Raw data, interpreted by options.format . |
Buffer |
Raw data, interpreted by options.format . |
base64 string |
Base64-encoded data. |
dataURI string |
DataURI string. |
ndarray |
Create from ndarray instance. The shape property is considered as [length, channels] . |
ndsamples |
Create from ndsamples instance, similar to ndarray. |
Options:
Property | Default | Meaning |
---|---|---|
length |
1 |
Buffer length. If 0 , buffer is unbound from context. |
context |
audio-context |
Audio context to bind. null -context creates context-free audio buffer. |
channels , numberOfChannels |
1 |
Buffer number of channels. |
sampleRate , rate |
44100 |
Buffer sample rate. |
format |
null |
Source pcm format string or object, see audio-format. If null , it will be detected from the source . |
Related
License
© 2017 Dmitry Yv. MIT License