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 notesleep 1Wait one beat before the next lineplay_pattern_timed [:c,:e,:g], 0.25Play a list with a time eachSamples
sample :bd_hausTrigger a built-in samplesample :ambi_choir, rate: 0.5Half speed / down an octavesample :loop_amen, beat_stretch: 4Stretch a loop to 4 beatsLive loops
live_loop :drums do sample :bd_haus sleep 0.5 endA loop you can redefine while it runs
sync :drumsWait for another loop's cuecue :tickBroadcast a cue to sync toSynths & FX
use_synth :tb303Set the synth for following notessynth :prophet, note: :e2, cutoff: 100Play a synth with parameterswith_fx :reverb do play :e3 endWrap notes in an effect
use_bpm 128Set the tempoParameters
amp:Volumepan:Stereo position −1 to 1attack: / release:Envelope timescutoff:Filter cutoff (0–130)Randomness & iteration
rrand(60, 72)Random float in a rangechoose([:c, :e, :g])Pick one at randomone_in(3)True roughly one time in three4.times do play :c4 sleep 0.5 endRepeat a block
Chords & scales
play chord(:e3, :minor)Play a chord at onceplay_pattern chord(:c, :major7)Arpeggiate a chord(scale :c, :major).to_aThe notes of a scale as a listSonic Pi — Ruby-based live coding for education & performance. · Sonic Pi in the tool directory →