Optional
url: string | AudioBuffer | ToneAudioBufferThe url to load, or the audio buffer to set.
Optional
onload: ((buffer) => void)A callback which is invoked after the buffer is loaded.
It's recommended to use ToneAudioBuffer.on('load', callback)
instead
since it will give you a callback when all buffers are loaded.
Optional
onerror: ((error) => void)The callback to invoke if there is an error
Optional
options: Partial<ToneAudioBufferOptions>Set this debug flag to log all events that happen in this class.
Readonly
nameCallback when the buffer is loaded.
Static
baseA path which is prefixed before every url.
Static
downloadsAll of the downloads
Static
versionThe version number semver
Indicates if the instance was disposed. 'Disposing' an instance means that all of the Web Audio nodes that were created for the instance are disconnected and freed for garbage collection.
The duration of the buffer in seconds.
The length of the buffer in samples
If the buffer is loaded or not
The number of discrete audio channels. Returns 0 if no buffer is loaded.
Reverse the buffer.
The sample rate of the AudioBuffer
Makes an fetch request for the selected url then decodes the file as an audio buffer. Invokes the callback once the audio buffer loads.
The url of the buffer to load. filetype support depends on the browser.
A Promise which resolves with this ToneAudioBuffer
Pass in an AudioBuffer or ToneAudioBuffer to set the value of this buffer.
Cut a subsection of the array and return a buffer of the subsection. Does not modify the original buffer
The time to start the slice
The end time to slice. If none is given will default to the end of the buffer
Get the buffer as an array. Single channel buffers will return a 1-dimensional Float32Array, and multichannel buffers will return multidimensional arrays.
Optional
channel: numberOptionally only copy a single channel from the array.
Static
fromCreate a ToneAudioBuffer from the array. To create a multichannel AudioBuffer, pass in a multidimensional array.
The array to fill the audio buffer
A ToneAudioBuffer created from the array
Static
fromCreates a ToneAudioBuffer from a URL, returns a promise which resolves to a ToneAudioBuffer
The url to load.
A promise which resolves to a ToneAudioBuffer
Static
getStatic
loadStatic
loadedStatic
supportsChecks a url's extension to see if the current browser can play that file type.
The url/extension to test
If the file extension can be played
Tone.ToneAudioBuffer.supportsType("wav"); // returns true
Tone.ToneAudioBuffer.supportsType("path/to/file.wav"); // returns true
AudioBuffer loading and storage. ToneAudioBuffer is used internally by all classes that make requests for audio files such as Tone.Player, Tone.Sampler and Tone.Convolver.
Example