Learn SONIC-PI-LIVE with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
1
Simple Live Loop Beat in Sonic Pi
live_loop :beat do
play 36, release: 0.2
sleep 1
end
A Sonic Pi live loop that plays a steady bass drum beat, demonstrating real-time modification during performance.
2
Layered Live Loop Melody and Drums
live_loop :drums do
sample :bd_haus
sleep 0.5
end
live_loop :melody do
use_synth :prophet
play choose([60, 62, 64, 67, 72]), release: 0.5
sleep 0.5
end
Two live loops layered together: one for drums, one for a melody. Both can be modified live while running.
3
Arpeggio Pattern
live_loop :arpeggio do
use_synth :piano
play_pattern_timed chord(:C4, :major), 0.25
sleep 1
end
A live loop creating a simple arpeggio pattern with a synth.
4
Random Melody
live_loop :random_melody do
use_synth :saw
play scale(:E3, :minor_pentatonic).choose, release: 0.3
sleep 0.25
end
Plays random notes from a scale in a live loop.
5
Drum Fill
live_loop :drum_fill do
sample :drum_snare_soft
sleep 0.25
sample :drum_cymbal_closed
sleep 0.25
end
Plays a simple drum fill repeatedly.
6
Bass Line Groove
live_loop :bass do
use_synth :tb303
play :C2, release: 0.5
sleep 0.5
play :E2, release: 0.5
sleep 0.5
end
A live loop that plays a bass groove pattern.
7
Chord Progression
live_loop :chords do
use_synth :fm
play chord(:C4, :major), release: 1
sleep 1
play chord(:F4, :major), release: 1
sleep 1
play chord(:G4, :major), release: 1
sleep 1
end
Plays a sequence of chords in a loop.
8
Echo Effect Loop
live_loop :echo_melody do
echo 0.3, phase: 0.5 do
use_synth :prophet
play choose([60, 64, 67, 72]), release: 0.5
sleep 0.5
end
end
Applies an echo effect to a live loop melody.
9
Reverb Drum Loop
live_loop :reverb_drums do
reverb 0.8 do
sample :bd_haus
sleep 1
sample :sn_generic
sleep 1
end
end
Plays a drum loop with a reverb effect applied.
10
Step Sequencer Pattern
live_loop :step_seq do
steps = [1, 0, 1, 0, 1, 1, 0, 0]
steps.each do |s|
if s == 1
sample :bd_haus
end
sleep 0.25
end
end
Implements a simple step sequencer with two samples.