No description
Find a file
2015-11-04 16:02:35 -05:00
build removing p5.Tone from the build 2015-11-04 16:01:50 -05:00
examples mic example 2015-09-30 14:01:19 -04:00
gulp updating testing flags 2015-11-04 15:59:09 -05:00
test updating testing flags 2015-11-04 15:59:09 -05:00
Tone using random index in randomOnce 2015-11-03 19:40:45 -05:00
.gitignore updated test runner 2015-08-31 11:44:49 -04:00
.jshintrc adding MediaStreamTrack 2015-09-28 20:58:52 -04:00
bower.json include utils for bower 2014-12-10 12:45:33 +00:00
CHANGELOG.md noting changes 2015-11-04 16:02:35 -05:00
LICENSE.md added license 2015-04-12 22:26:06 -04:00
package.json update test script 2015-10-12 00:00:45 -04:00
README.md blurb about MIDI 2015-09-30 13:29:30 -04:00

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.

API

Examples

Demos

Using Tone.js? I'd love to hear it: yotammann@gmail.com

Installation

Tone can be installed in a few of ways:

  • Download Tone.js from Github - full | min
  • bower - bower install tone
  • npm - npm install tone

The fastest way to include Tone.js on your page is to use the CDN (hosted by github pages).

<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".

Full Installation Instruction

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 Transport which allows for application-wide synchronization of sources and signals with tempo curves and automation. 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.

Read more.

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).

Read more.

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).

Read more.

Instruments

Tone has a number of instruments which all inherit from Tone.Instrument, giving them the same API for triggering notes. These instruments are all monophonic and can be made polyphonic if they are passed into the second argument of Tone.PolySynth.

Read more.

Effects

Tone.js also has many stereo and mono effects. Each effect lets you change the ratio between the dry (unaffected) and wet signal.

Read more.

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.

MIDI

To use MIDI files, you'll first need to convert them into a JSON format which Tone.js can understand using MidiConvert.

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.

References and Inspiration