Tone.Buffer
↳ EXTENDS ToneBuffer loading and storage. Tone.Buffer is used internally by all classes that make requests for audio files such as Tone.Player, Tone.Sampler and Tone.Convolver.
Aside from load callbacks from individual buffers, Tone.Buffer provides static methods which keep track of the loading progress of all of the buffers. These methods are Tone.Buffer.onload, Tone.Buffer.onprogress, and Tone.Buffer.onerror.
CONSTRUCTOR
new Tone.Buffer (The url to load, or the audio buffer to set.
A callback which is invoked after the buffer is loaded. It’s recommended to use Tone.Buffer.onload instead since it will give you a callback when ALL buffers are loaded.
DEFAULTS
EXAMPLE
var buffer = new Tone.Buffer("path/to/sound.mp3", function(){
//the buffer is now available.
var buff = buffer.get();
});Members
Methods
.load ( )
#The url to load
The callback to invoke on load. don’t need to set if onload is already set.
this
Load url into the buffer.
.set ( )
#the buffer
this
Pass in an AudioBuffer or Tone.Buffer to set the value of this buffer.
Static Methods
.load ( )
#The url of the buffer to load. filetype support depends on the browser.
The function to invoke when the url is loaded.
returns the XHR
Makes an xhr reqest for the selected url then decodes the file as an audio buffer. Invokes the callback once the audio buffer loads.
.supportsType ( )
#The url/extension to test
If the file extension can be played
Checks a url’s extension to see if the current browser can play that file type.
EXAMPLE
Tone.Buffer.supportsType("wav"); //returns true
Tone.Buffer.supportsType("path/to/file.wav"); //returns true