@generative-music/utilities
v5.2.0
Published
A collection of common utilities for Web Audio API generative music systems
Downloads
32
Readme
@generative-music/utilities
A collection of common utilities for Web Audio API generative music systems.
Usage
This package exports the following utilities:
getBuffer()
Create a Tone.js Buffer
object for a URL or an AudioBuffer
.
Syntax
getBuffer(url).then(toneBuffer => {
// do something with the Tone.js Buffer
});
Parameters
- url: Either a
string
containing a URL to an audio file, or anAudioBuffer
.
Return value
A Promise
that resolves to a Tone.js Buffer
for the specified audio.
getBuffers()
Create a Tone.js Buffers
object for a group of URLs or AudioBuffer
objects.
Syntax
getBuffers(urlMap).then(toneBuffers => {
// do something with the Tone.js Buffers
});
Parameters
- urlMap: Either an array of
string
s containing URLs to audio files, an array ofAudioBuffer
objects, or an object with property values containing eitherstring
s orAudioBuffer
objects.
Return value
A Promise
that resolves to a Tone.js Buffers
object for the specified audio.
getSampler()
Create a Tone.js Sampler
.
Syntax
getSampler(urlMap).then(sampler => {
// do something with the Tone.js Sampler
});
Parameters
- urlMap - An object that maps pitches to either a
string
containing a URL or anAudioBuffer
. Pitches can be notated as Midi or in scientific pitch notation.
Return value
A Promise
that resolves to a Tone.js Sampler
for the specified audio.