The Patchbay_

Sonic Pi Cheat Sheet

The essentials of Sonic Pi — playing notes and samples, live loops, synths and effects, and the randomness that makes it fun.

Notes & timing

play 60Play MIDI note 60 (middle C)
play :c4Play a named note
sleep 1Wait one beat before the next line
play_pattern_timed [:c,:e,:g], 0.25Play a list with a time each

Samples

sample :bd_hausTrigger a built-in sample
sample :ambi_choir, rate: 0.5Half speed / down an octave
sample :loop_amen, beat_stretch: 4Stretch a loop to 4 beats

Live loops

live_loop :drums do
  sample :bd_haus
  sleep 0.5
end
A loop you can redefine while it runs
sync :drumsWait for another loop's cue
cue :tickBroadcast a cue to sync to

Synths & FX

use_synth :tb303Set the synth for following notes
synth :prophet, note: :e2, cutoff: 100Play a synth with parameters
with_fx :reverb do
  play :e3
end
Wrap notes in an effect
use_bpm 128Set the tempo

Parameters

amp:Volume
pan:Stereo position −1 to 1
attack: / release:Envelope times
cutoff:Filter cutoff (0–130)

Randomness & iteration

rrand(60, 72)Random float in a range
choose([:c, :e, :g])Pick one at random
one_in(3)True roughly one time in three
4.times do
  play :c4
  sleep 0.5
end
Repeat a block

Chords & scales

play chord(:e3, :minor)Play a chord at once
play_pattern chord(:c, :major7)Arpeggiate a chord
(scale :c, :major).to_aThe notes of a scale as a list

Sonic Pi — Ruby-based live coding for education & performance. · Sonic Pi in the tool directory →

← All cheat sheets