Tone.MultiPlayer

↳ EXTENDS Tone
DEPRECATED:

Use Tone.Players instead.

Tone.MultiPlayer is well suited for one-shots, multi-sampled instruments or any time you need to play a bunch of audio buffers.

CONSTRUCTOR

new Tone.MultiPlayer (
buffers
,
onload
)
buffers

The buffers which are available to the MultiPlayer

type: Object or Array or Tone.Buffers
onload

The callback to invoke when all of the buffers are loaded.

type: function

DEFAULTS

{
onload : Tone.noOp ,
fadeIn : 0 ,
fadeOut : 0
}

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

.buffers

Tone.Buffers #

All the buffers belonging to the player.

</>

.fadeIn

Time #

The fade in envelope which is applied to the beginning of the BufferSource

</>

.fadeOut

Time #

The fade out envelope which is applied to the end of the BufferSource

</>

.mute

boolean #

Mute the output.

EXAMPLE

//mute the output
source.mute = true;
</>

.state

Tone.State READONLY #

Returns the playback state of the source. “started” if there are any buffers playing. “stopped” otherwise.

</>

Methods

.add ( )

#
name

The name to that the buffer is refered to in start/stop methods.

type: String
url

The url of the buffer to load or the buffer.

callback

The function to invoke after the buffer is loaded.

Add another buffer to the available buffers.

</>

.dispose ( )

#
↪ returns Tone.MultiPlayer

this

Clean up.

</>

.start ( )

#
bufferName

The name of the buffer to start.

type: String
time

When to start the buffer.

type: Time
offset

The offset into the buffer to play from.

type: Time
default: 0
duration

How long to play the buffer for.

type: Time
optional
pitch

The interval to repitch the buffer.

default: 0
gain

The gain to play the sample at.

type: Gain
default: 1
↪ returns Tone.MultiPlayer

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.

</>

.startLoop ( )

#
bufferName

The name of the buffer to start.

type: String
time

When to start the buffer.

type: Time
offset

The offset into the buffer to play from.

type: Time
default: 0
loopStart

The start of the loop.

type: Time
optional
loopEnd

The end of the loop.

type: Time
optional
pitch

The interval to repitch the buffer.

default: 0
gain

The gain to play the sample at.

type: Gain
default: 1
↪ returns Tone.MultiPlayer

this

Start a looping buffer by name. Similar to start, but the buffer is looped instead of played straight through. Can still be stopped with stop.

</>

.stop ( )

#
bufferName

The buffer to stop.

type: String
time

When to stop the buffer

type: Time
optional
↪ returns Tone.MultiPlayer

this

Stop the first played instance of the buffer name.

</>

.stopAll ( )

#
time

When to stop the buffers.

type: Time
optional
↪ returns Tone.MultiPlayer

this

Stop all currently playing buffers at the given time.

</>
docs generated Sep 15 2019