Tone.MultiPlayer
↳ EXTENDS ToneTone.MultiPlayer is well suited for one-shots, multi-sampled istruments or any time you need to play a bunch of audio buffers.
CONSTRUCTOR
new Tone.MultiPlayer (The buffers which are available to the MultiPlayer
The callback to invoke when all of the buffers are loaded.
DEFAULTS
EXAMPLE
var multiPlayer = new MultiPlayer({
"kick" : "path/to/kick.mp3",
"snare" : "path/to/snare.mp3",
}, function(){
multiPlayer.start("kick");
});
EXAMPLE
//can also store the values in an array
var multiPlayer = new MultiPlayer(["path/to/kick.mp3", "path/to/snare.mp3"],
function(){
//if an array is passed in, the samples are referenced to by index
multiPlayer.start(1);
});Members
.state
↝ Tone.State READONLY #Returns the playback state of the source. “started” if there are any buffers playing. “stopped” otherwise.
Methods
.add ( )
#The name to that the buffer is refered to in start/stop methods.
The url of the buffer to load or the buffer.
The function to invoke after the buffer is loaded.
Add another buffer to the available buffers.
.start ( )
#The name of the buffer to start. Or pass in a buffer which will be started.
When to start the buffer.
The offset into the buffer to play from.
How long to play the buffer for.
The interval to repitch the buffer.
The gain to play the sample at.
this
Start a buffer by name. The start method allows a number of options to be passed in such as offset, interval, and gain. This is good for multi-sampled instruments and sound sprites where samples are repitched played back at different velocities.
.stop ( )
#The buffer to stop.
When to stop the buffer
this
Stop all instances of the currently playing buffer at the given time.
.stopAll ( )
#When to stop the buffers.
this
Stop all currently playing buffers at the given time.