buffer
Array buffer manipulation functions
This is part of dsp-kit
Example
var buffer = const sine = buffer
Example
var dsp = dspbuffer
Array
buffer~zeros(size) ⇒ Create a buffer (a Float64Array) filled with zeros
Kind: inner method of buffer
Returns: Array
- the buffer
Param | Type |
---|---|
size | Integer |
buffer~generate(buffer, fn)
Generate a buffer using a function
Kind: inner method of buffer
Param | Type | Description |
---|---|---|
buffer | Number | Array |
The buffer (to reuse) or a buffer length to create one |
fn | function |
the generator function. It receives the following parameters: - n: a number from [0..1] - index: a number from [0...length] - length: the buffer length |
Example
const sine = buffer
Array
buffer~map(fn, source, destination) ⇒ Map a buffer with a function
This function can be partially applied (see examples)
Kind: inner method of buffer
Returns: Array
- the mapped buffer
Param | Type | Description |
---|---|---|
fn | function |
the mapping function |
source | Array |
the source |
destination | Array |
(Optional) if no one is provided, a new buffer is created |
Example
const sine = bufferbuffer // => a buffer with the gain doubled// partially appliedconst doubleGain = buffer // => a buffer with the gain doubled
buffer~copy(source, destination)
Copy two buffers
Kind: inner method of buffer
Param | Type | Description |
---|---|---|
source | Array |
the source buffer |
destination | Array |
(Optional) the destination buffer (a new buffer is created if no one is provided) |
Example
buffer