build | ||
examples | ||
gulp | ||
test | ||
Tone | ||
utils | ||
.gitignore | ||
.jshintrc | ||
bower.json | ||
CHANGELOG.md | ||
LICENSE.md | ||
package.json | ||
README.md |
Tone.js
Tone.js is a Web Audio framework for creating interactive music in the browser. The architecture of Tone.js aims to be familiar to both musicians and audio programmers looking to create web-based audio applications. On the high-level, Tone offers common DAW (digital audio workstation) features like a global transport for scheduling and timing events and prebuilt synths and effects. For signal-processing programmers (coming from languages like Max/MSP), Tone provides a wealth of high performance, low latency building blocks and DSP modules to build your own synthesizers, effects, and complex control signals.
Demos
- Jazz.Computer - Yotam Mann
- motionEmotion - emotion & gesture-based arpeggiator and synthesizer
- A Tone.js Plugin Architecture with GUIs
- p5.sound - build with Tone.js
- Hypercube by @eddietree
- randomcommander.io by Jake Albaugh
- Tone.js + NexusUI by taylorbf
- Solarbeat - Luke Twyman
- João Costa - Wind
- Abe Rubenstein - Block Chords
Using Tone.js? I'd love to hear it: yotammann@gmail.com
Installation
Tone can be installed in a few of ways:
The fastest way to include Tone.js on your page is to use the CDN (not for production use, please):
<script type="text/javascript" src="http://cdn.tonejs.org/latest/Tone.min.js"></script>
It's always much safer to use a specific version rather than just "latest".
Hello World
//create one of Tone's built-in synthesizers and connect it to the master output
var synth = new Tone.SimpleSynth().toMaster();
//play a middle c for the duratino of an 8th note
synth.triggerAttackRelease("C4", "8n");
Tone.Transport
A unique feature of the library is the oscillator-based Transport which allows for application-wide synchronization of sources and signals. The Transport allows you to register callbacks at precise moments along the timeline which are invoked right before the event with the exact time of the event. Additionally, because the Transport is implemented with an oscillator, it is capable of elaborate tempo curves and automation.
Time
In the Tone library, time can be described in a number of ways. Any method which takes a time as a parameter will accept the number in seconds as well as a tempo-relative form.
For example to "4n"
is a quarter-note and "4:2:0" is the third beat of the fifth measure (remember we're counting from 0).
Sources
Aside from the 4 basic oscillator types (sine, square, triangle, sawtooth), Tone.js provides a few other sources such as a buffer player (Tone.Player), a noise generator, and two additional oscillator types (pwm, pulse).
Instruments
Tone has a few prebuilt synthesizers. Read more about their common interface.
Effects
Tone.js also has a few stereo and mono effects some of which also have their own presets. Read more about using effects.
Signals
Like the underlying Web Audio API, Tone.js is built with audio-rate signal control over nearly everything. This is a powerful feature which allows for sample-accurate synchronization of multiple parameters with a single signal. Signals are built entirely without the ScriptProcessorNode so they do not introduce much latency and processing overhead. Instead, all signal math and logic let GainNodes and WaveShaperNodes do all of the work so that all processing is done in the underlying Assembly/C/C++ provided by the API. Signals are used extensively internally and are also useful for general DSP and control signal logic and transformations.
Read more about signals.
AudioContext
Tone.js creates an AudioContext when it loads and shims it for maximum browser compatibility. The AudioContext can be found at Tone.context
or from within any Object extending Tone as this.context
.
Tone also let's you set your own AudioContext using Tone.setContext
.
Performance
Tone.js uses very few ScriptProcessorNodes. Nearly all of the Tone Modules find a native Web Audio component workaround, making extensive use of the GainNode and WaveShaperNode especially, which enables Tone.js to work well on both desktop and mobile browsers. While the ScriptProcessorNode is extremely powerful, it introduces a lot of latency and the potential for glitches more than any other node.