Learn Sonic-pi-live - 10 Code Examples & CST Typing Practice Test
Sonic Pi is a live coding environment designed for creating music through code. It allows users to write Ruby-based scripts that generate real-time audio, enabling both learning and performance in music programming.
Learn SONIC-PI-LIVE with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
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.
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.
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.
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.
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.
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.
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.
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.
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.
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.
Frequently Asked Questions about Sonic-pi-live
What is Sonic-pi-live?
Sonic Pi is a live coding environment designed for creating music through code. It allows users to write Ruby-based scripts that generate real-time audio, enabling both learning and performance in music programming.
What are the primary use cases for Sonic-pi-live?
Teaching programming through music. Algorithmic and generative composition. Live music performance and improvisation. Interactive sound installations. Exploring synthesis, effects, and audio experimentation
What are the strengths of Sonic-pi-live?
Immediate feedback encourages experimentation. Educationally powerful for learning coding and music together. Supports creative, algorithmic composition. Live coding performance ready. Highly extensible with samples, MIDI, and effects
What are the limitations of Sonic-pi-live?
Not a full-featured DAW for commercial music production. Learning curve for non-programmers. Timing-sensitive code may require precision. Limited built-in instruments compared to professional DAWs. Dependent on computer performance for real-time audio
How can I practice Sonic-pi-live typing speed?
CodeSpeedTest offers 10+ real Sonic-pi-live code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.