Optionalurl: string | ToneAudioBuffer | AudioBuffer
The url to load, or the audio buffer to set.
Optionalonload: (buffer: ToneAudioBuffer) => 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.
Optionalonerror: (error: Error) => void
The callback to invoke if there is an error
Optionaloptions: Partial<ToneAudioBufferOptions>Set this debug flag to log all events that happen in this class.
ReadonlynameThe name of the class
Callback when the buffer is loaded.
StaticbaseA path which is prefixed before every url.
StaticdownloadsAll of the downloads
StaticversionThe 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
clean up
Set the audio buffer from the array. To create a multichannel AudioBuffer, pass in a multidimensional array.
The array to fill the audio buffer
The audio buffer stored in the object.
Returns the Float32Array representing the PCM audio data for the specific channel.
The channel number to return
The audio as a TypedArray
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
ProtectedlogPrints the outputs to the console log for debugging purposes.
Prints the contents only if either the object has a property
called debug set to true, or a variable called TONE_DEBUG_CLASS
is set to the name of the class.
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
Optionalend: number
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.
Optionalchannel: number
Optionally only copy a single channel from the array.
Sums multiple channels into 1 channel
OptionalchanNum: number
Optionally only copy a single channel from the array.
StaticfromCreate 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
StaticfromCreates a ToneAudioBuffer from a URL, returns a promise which resolves to a ToneAudioBuffer
The url to load.
A promise which resolves to a ToneAudioBuffer
StaticgetReturns all of the default options belonging to the class.
StaticloadLoads a url using fetch and returns the AudioBuffer.
StaticloadedReturns a Promise which resolves when all of the buffers have loaded
StaticsupportsChecks 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
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