Tone.Buffers

↳ EXTENDS Tone

A data structure for holding multiple buffers.

CONSTRUCTOR

new Tone.Buffers (
urls
, [
callback
] )
urls

An object literal or array of urls to load.

type: Object or Array
callback

The callback to invoke when the buffers are loaded.

optional

DEFAULTS

{
onload : Tone.noOp ,
baseUrl :
}

EXAMPLE

//load a whole bank of piano samples
var pianoSamples = new Tone.Buffers({
	"C4" : "path/to/C4.mp3"
	"C#4" : "path/to/C#4.mp3"
	"D4" : "path/to/D4.mp3"
	"D#4" : "path/to/D#4.mp3"
	...
}, function(){
	//play one of the samples when they all load
	player.buffer = pianoSamples.get("C4");
	player.start();
});
	

EXAMPLE

//To pass in additional parameters in the second parameter
var buffers = new Tone.Buffers(urls, {
	"onload" : callback,
	"baseUrl" : "../path/to/audio/"
})

Members

.baseUrl

String #

A path which is prefixed before every url.

</>

.loaded

Boolean READONLY #

If the buffers are loaded or not

</>

Methods

.add ( )

#
name

A unique name to give the buffer

type: String
url

Either the url of the bufer, or a buffer which will be added with the given name.

callback

The callback to invoke when the url is loaded.

optional

Add a buffer by name and url to the Buffers

</>

.dispose ( )

#
↪ returns Tone.Buffers

this

Clean up.

</>

.get ( )

#
name

The key or index of the buffer.

↪ returns Tone.Buffer

Get a buffer by name. If an array was loaded, then use the array index.

</>

.has ( )

#
name

The key or index of the buffer.

↪ returns Boolean

True if the buffers object has a buffer by that name.

</>
docs generated Sep 15 2019