In synth-kit buffers can be generated (with the gen
function) or
retrieved from an audio file (with the sample
) function
- Source:
Methods
(static) gen(generators, samples, options) → {function}
Generate a BufferNode. It returns a no-parameter function that returns a buffer. This way, it's easy to memoize (cache) buffers.
Parameters:
Name | Type | Description |
---|---|---|
generators |
function | Array.<function()> | a generator or a list of generators (to create a buffer with multiple channels) |
samples |
Integer | the length in samples |
options |
Object | (Optional) options can include:
|
- Source:
Returns:
a function with no parameters that returns the desired buffer
- Type
- function
(static) sample(url, options) → {function}
Fetch a remote audio sample. You get a function that returns an AudioBuffer when loaded or null otherwise. Or you can chain like a promise.
Parameters:
Name | Type | Description |
---|---|---|
url |
String | the url of the file |
options |
Object | (Optional) options can include:
|
- Source:
Returns:
a function the returns the buffer
- Type
- function
Examples
source(sample('server.com/audio-file.mp3')).start()
// use the Promise like interface
sample('audio-file.mp3').then(function (buffer) {
source(buffer).start()
})
(static) source(buffer, options) → {AudioNode}
Create a buffer source (a BufferSourceNode)
Parameters:
Name | Type | Description |
---|---|---|
buffer |
Buffer | function | the buffer (or a function that returns a buffer) |
options |
Object | (Optional) options can include:
|
- Source:
Returns:
a BufferSourceNode
- Type
- AudioNode
Example
source(sample('snare.wav')).start()
source(sample('amen-break.mp3'), { loop: true })
(static) white(length, options) → {AudioNode}
White noise source node.
Parameters:
Name | Type | Description |
---|---|---|
length |
Integer | lenth in samples |
options |
Object | (Optional) the same options that |
- Source:
- See:
-
- source
Returns:
the white noise audio node generator
- Type
- AudioNode
Example
conn(white(seconds(1)), perc(), dest()).start()