@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
stringcontaining 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
strings containing URLs to audio files, an array ofAudioBufferobjects, or an object with property values containing eitherstrings orAudioBufferobjects.
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
stringcontaining 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.