A data structure for holding multiple buffers in a Map-like datastructure.
import { Player, ToneAudioBuffers } from "tone";
const pianoSamples = new ToneAudioBuffers({
C1: "https://tonejs.github.io/examples/audio/casio/C1.mp3",
C2: "https://tonejs.github.io/examples/audio/casio/C2.mp3",
}, () => {
const player = new Player().toDestination();
// play one of the samples when they all load
player.buffer = pianoSamples.get("C2");
player.start();
});
import { ToneAudioBuffers } from "tone";
// To pass in additional parameters in the second parameter
const buffers = new ToneAudioBuffers({
urls: {
C1: "C1.mp3",
C2: "C2.mp3",
},
onload: () => console.log("loaded"),
baseUrl: "https://tonejs.github.io/examples/audio/casio/"
});
The callback to invoke when the buffers are loaded.
A prefix url to add before all the urls
A path which is prefixed before every url.
Set this debug flag to log all events that happen in this class.
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.
If the buffers are loaded or not
The version number semver
Add a buffer by name and url to the Buffers
A unique name to give the buffer
Either the url of the bufer, or a buffer which will be added with the given name.
The callback to invoke when the url is loaded.
Get a buffer by name. If an array was loaded, then use the array index.
Returns all of the default options belonging to the class.
True if the buffers object has a buffer by that name.
The key or index of the buffer.
Convert the class to a string
import { Oscillator } from "tone";
const osc = new Oscillator();
console.log(osc.toString());