Learn Sonic-pi - 10 Code Examples & CST Typing Practice Test
Sonic Pi is a live coding environment designed for creating music using code. It allows users to compose, perform, and experiment with sounds in real-time, blending programming with musical creativity.
Learn SONIC-PI with Real Code Examples
Updated Nov 26, 2025
Code Sample Descriptions
Hello World Tune in Sonic Pi
play 60
sleep 0.5
play 62
sleep 0.5
play 64
sleep 0.5
play 67
sleep 1
play 72
A simple Sonic Pi script that plays a short 'Hello World' melody.
Simple Drum Beat
sample :bd_haus
sleep 0.5
sample :sn_dub
sleep 0.5
sample :bd_haus
sleep 0.5
sample :sn_dub
sleep 0.5
Plays a basic drum pattern using Sonic Pi samples.
Ascending Scale
play 60
sleep 0.25
play 62
sleep 0.25
play 64
sleep 0.25
play 65
sleep 0.25
play 67
sleep 0.25
play 69
sleep 0.25
play 71
sleep 0.25
play 72
Plays a C major ascending scale.
Arpeggio Example
play 60
sleep 0.25
play 64
sleep 0.25
play 67
sleep 0.25
play 72
sleep 0.25
Plays a simple arpeggio of a C major chord.
Simple Bassline
use_synth :fm
play 36
sleep 0.5
play 38
sleep 0.5
play 40
sleep 0.5
play 41
sleep 0.5
Plays a repeating bassline pattern.
Random Notes
8.times do
play choose([60,62,64,65,67,69,71,72])
sleep 0.25
end
Plays 8 random notes within an octave.
Melody with Reverb
with_fx :reverb, mix: 0.5 do
play 60
sleep 0.5
play 64
sleep 0.5
play 67
sleep 0.5
end
Plays a simple melody with a reverb effect.
Simple Drum Roll
16.times do
sample :sn_dub
sleep 0.125
end
Plays a drum roll using the snare sample.
Chord Progression
play_chord [:c4, :e4, :g4]
sleep 1
play_chord [:f4, :a4, :c5]
sleep 1
play_chord [:g4, :b4, :d5]
sleep 1
play_chord [:c4, :e4, :g4]
sleep 1
Plays a basic C major chord progression.
Simple Ambient Loop
use_synth :hollow
loop do
play 60
sleep 1
play 65
sleep 1.5
play 69
sleep 0.75
end
Creates a looping ambient soundscape using synths and sleep timings.
Frequently Asked Questions about Sonic-pi
What is Sonic-pi?
Sonic Pi is a live coding environment designed for creating music using code. It allows users to compose, perform, and experiment with sounds in real-time, blending programming with musical creativity.
What are the primary use cases for Sonic-pi?
Teaching coding through music in schools and workshops. Live coding performances and concerts. Composing experimental electronic music. Creating interactive sound installations. Learning synthesis, loops, and algorithmic composition
What are the strengths of Sonic-pi?
Instant feedback via live audio output. Bridges programming and music education. Highly interactive and creative environment. Strong community and extensive tutorials. Flexible for algorithmic and experimental music
What are the limitations of Sonic-pi?
Not a full-featured DAW (Digital Audio Workstation). Limited GUI tools for traditional music production. Requires familiarity with coding concepts. Complex compositions may become hard to manage. Dependent on computer performance for low-latency audio
How can I practice Sonic-pi typing speed?
CodeSpeedTest offers 10+ real Sonic-pi code examples for typing practice. You can measure your WPM, track accuracy, and improve your coding speed with guided exercises.