Tone.js is a JavaScript Web Audio framework for building interactive music in the browser. It offers scheduling, synthesizers, effects, and sample playback atop the Web Audio API.
Overview
Tone.js wraps the browser Web Audio API so musicians and developers can build web-based audio applications with an interface modeled on familiar workstation concepts. A global transport synchronizes and schedules events, and the library ships ready-made synthesizers and effects alongside lower-level pieces for custom instruments and control signals.
Install it with npm and import it as a module, or load a hosted build from a CDN before your scripts. Common workflows include triggering notes on basic and polyphonic synths, loading audio files through players and samplers, and routing audio through serial or parallel effect chains. Time values can be expressed in seconds or in musical units such as quarter notes and measures.
Scheduling relies on sample-accurate AudioContext timing abstracted through helpers like Tone.now(), while the transport can be started, stopped, looped, and retimed during playback. Browsers require a user gesture before audio plays; calling Tone.start() from a click or keydown handler unlocks the context.
Signal-rate parameter control mirrors native Web Audio behavior, and the library leans on built-in nodes such as GainNode and WaveShaperNode for processing on desktop and mobile browsers. You can supply or replace the underlying AudioContext when integrating with existing audio setups.
Key features
- Global transport for timing and loops
- Built-in monophonic and polyphonic synths
- Sample players and multi-sample instruments
- Flexible serial and parallel effect routing
- Musical time strings alongside seconds
- Audio-rate signal automation
- Web Audio API compatibility shims
- npm and CDN installation paths
Use cases
- Browser-based music apps
- Interactive audio on websites
- Scheduled musical events
- Custom synth and effect chains
- Sample-based instruments in the web