The Patchbay_

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 speakers
s.triggerAttackRelease("C4", "8n")Play C4 for an eighth note
s.triggerAttack("C4"); s.triggerRelease()Note on / note off separately

Time & Transport

Tone.Transport.bpm.value = 120Set the tempo
Tone.Transport.start()Start the global clock
"4n" "8n" "1m"Note-value time: quarter, eighth, one measure
Tone.Transport.scheduleRepeat(cb, "8n")Run a callback every eighth note

Loops & sequences

new Tone.Loop(t => s.triggerAttackRelease("C4","8n",t), "4n").start(0)Repeat a callback
new Tone.Sequence((t,n)=>s.triggerAttackRelease(n,"8n",t), ["C4","E4","G4"], "8n").start(0)Step through notes
new Tone.Pattern((t,n)=>{}, ["C4","E4"], "up")Arpeggiate a set of notes

Instruments

new Tone.PolySynth(Tone.Synth)Polyphonic — play chords
new Tone.FMSynth()FM synthesis voice
new Tone.MembraneSynth()Kick / tom drum sound
new Tone.Sampler({ C4: "C4.mp3" })Play back mapped samples

Effects & routing

s.chain(new Tone.Filter(800), Tone.Destination)Route through effects to output
new Tone.Reverb(2)Reverb (decay in seconds)
new Tone.FeedbackDelay("8n", 0.4)Tempo-able delay
s.volume.value = -6Set level in dB

Tone.js — Web Audio framework for interactive music. · Tone.js in the tool directory →

← All cheat sheets