A data structure for holding multiple buffers in a Map-like datastructure.

const pianoSamples = new Tone.ToneAudioBuffers({
	A1: "",
	A2: "",
}, () => {
	const player = new Tone.Player().toDestination();
	// play one of the samples when they all load
	player.buffer = pianoSamples.get("A2");

// To pass in additional parameters in the second parameter
const buffers = new Tone.ToneAudioBuffers({
	 urls: {
		 A1: "A1.mp3",
		 A2: "A2.mp3",
	 onload: () => console.log("loaded"),
	 baseUrl: ""


  • Tone
    • ToneAudioBuffers


new ToneAudioBuffers (
urls?:ToneAudioBuffersUrlMap ,

An object literal or array of urls to load.

onload?:undefined | () => void ,

The callback to invoke when the buffers are loaded.

baseUrl?:undefined | string

A prefix url to add before all the urls

) => ToneAudioBuffers
new ToneAudioBuffers (
options?:Partial<ToneAudioBuffersOptions >
) => ToneAudioBuffers


baseUrl #


A path which is prefixed before every url.

debug #


Set this debug flag to log all events that happen in this class.

disposed #

readonly boolean

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.

loaded #

readonly boolean

If the buffers are loaded or not

static version #


The version number semver


add #

Add a buffer by name and url to the Buffers

add (
name:string | number ,

A unique name to give the buffer

url:string | AudioBuffer | ToneAudioBuffer ,

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

callback= noOp:() => void ,

The callback to invoke when the url is loaded.

onerror= noOp:(e) => void

Invoked if the buffer can't be loaded

) => this

dispose #

disconnect and dispose.

dispose ( ) => this

get #

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

get (
name:string | number

The key or index of the buffer.

) => ToneAudioBuffer

static getDefaults #

Returns all of the default options belonging to the class.

getDefaults ( ) => ToneAudioBuffersOptions

has #

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

has (
name:string | number

The key or index of the buffer.

) => boolean

toString #

Convert the class to a string

const osc = new Tone.Oscillator();
toString ( ) => string