explaingit

tonejs/tone.js

14,609TypeScript

TLDR

Tone.js is a JavaScript library for making interactive music in a web browser.

Mindmap

A visual breakdown will appear here once this repo is fully enriched.

In plain English

Tone.js is a JavaScript library for making interactive music in a web browser. It sits on top of the Web Audio API and tries to feel familiar to two groups: musicians who think in terms of bars and beats, and audio programmers who care about sample-accurate timing. The README says the library offers digital audio workstation style features such as a global transport for scheduling, along with prebuilt synthesizers and effects, plus lower-level building blocks for making your own. You can install it from npm with npm install tone and import it in JavaScript with import * as Tone from tone, or you can drop a script tag from unpkg.com directly into an HTML page. The simplest hello world is two lines: create a new Tone.Synth, attach it to the speakers with toDestination, then call triggerAttackRelease with a note name like C4 and a duration like an eighth note. The library has its own time language. Methods that expect a time can take a number of seconds, or a string like 4n for a quarter note, 8t for an eighth note triplet, or 1m for one measure. There are matching methods triggerAttack and triggerRelease for note on and note off, and Tone.now returns the current AudioContext time. Browsers will not play any audio until the user interacts with the page, so the README stresses calling await Tone.start inside a click or keydown handler before scheduling anything. For arrangement, Tone.getTransport returns a clock you can start, stop, loop, and tempo-shift on the fly. The example builds two monophonic synths, wraps them in Tone.Loop callbacks at quarter note intervals offset by an eighth, starts the transport, and ramps the BPM up to 800 over ten seconds. Because JavaScript callbacks are not precisely timed, the loop passes the exact event time into the callback, and the README is firm that you should use that value when triggering notes. The instruments section lists Tone.FMSynth, Tone.AMSynth, and Tone.NoiseSynth, all monophonic, and Tone.PolySynth which wraps a monophonic synth to allow chords. For real recordings, Tone.Player loads and plays back an audio file, and Tone.Sampler combines several pitch-labeled audio files into a polyphonic instrument that fills in missing notes by pitch shifting. Tone.loaded returns a promise that resolves when all audio buffers are ready. Sources can also be routed through one or more effects before reaching the speakers.

Open on GitHub → Explain another repo

Generated 2026-05-21 · Model: sonnet-4-6 · Verify against the repo before relying on details.