Skip to content

Installation

Yotam Mann edited this page Apr 15, 2015 · 27 revisions

Installation

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

Downloading

  • Github - full | min
  • Bower - bower install tone
  • npm - npm install tone
  • cdn - CDN (not for production use, please)

Using

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>

or from the Tone's CDN

<script type="text/javascript" src="http://cdn.tonejs.org/latest/Tone.min.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){
    //...