Skip to content

Installation

Yotam Mann edited this page Dec 1, 2014 · 27 revisions

Installation

There are a few ways to download and install Tone.js.

Downloading

Using

RequireJS is the recommended way to use Tone.js but it can also be used just as well without it.

without RequireJS

Tone.js can be used like any other script or library by dropping the into the

of your page. A global called Tone will be added to the window.
<script type="text/javascript" src="path/to/Tone.js"></script>

To use any of the instrument and effect presets, be sure to grab the Tone.Presets build which is not included in the default build.

RequireJS

RequireJS is a JavaScript module loader which Tone.js uses internally for dependency management. It is a powerful tool for development and deploying. Using r.js (RequireJS's optimizer) can bring package size down significantly since it will only include the modules used in your code.

Build

You can use the built file with Require like any other external script.

require(["Tone"], function(Tone){
    var synth = new Tone.MonoSynth();
    //...etc

Directory

For the full RequireJS experience, maintain the directory structure of the library and reference all modules from the root directory "Tone". Add a path to the root directory. This will require familiarizing yourself with the directory structure.

require.config({
    baseUrl: "./base",
    paths: {
        "Tone" : "path/to/Tone.js/Tone"
    }
});
require(["Tone/core/Transport"], function(Transport){
    //...