Tone.js Cheat Sheet
Tone.js is the go-to framework for making music in the browser. The essentials: starting audio, playing synths, and driving everything from the Transport clock.
Start & play
await Tone.start()Resume audio (call from a user gesture)const s = new Tone.Synth().toDestination()Create a synth routed to the speakerss.triggerAttackRelease("C4", "8n")Play C4 for an eighth notes.triggerAttack("C4"); s.triggerRelease()Note on / note off separatelyTime & Transport
Tone.Transport.bpm.value = 120Set the tempoTone.Transport.start()Start the global clock"4n" "8n" "1m"Note-value time: quarter, eighth, one measureTone.Transport.scheduleRepeat(cb, "8n")Run a callback every eighth noteLoops & sequences
new Tone.Loop(t => s.triggerAttackRelease("C4","8n",t), "4n").start(0)Repeat a callbacknew Tone.Sequence((t,n)=>s.triggerAttackRelease(n,"8n",t), ["C4","E4","G4"], "8n").start(0)Step through notesnew Tone.Pattern((t,n)=>{}, ["C4","E4"], "up")Arpeggiate a set of notesInstruments
new Tone.PolySynth(Tone.Synth)Polyphonic — play chordsnew Tone.FMSynth()FM synthesis voicenew Tone.MembraneSynth()Kick / tom drum soundnew Tone.Sampler({ C4: "C4.mp3" })Play back mapped samplesEffects & routing
s.chain(new Tone.Filter(800), Tone.Destination)Route through effects to outputnew Tone.Reverb(2)Reverb (decay in seconds)new Tone.FeedbackDelay("8n", 0.4)Tempo-able delays.volume.value = -6Set level in dBTone.js — Web Audio framework for interactive music. · Tone.js in the tool directory →