Sonic Pi is a powerful live coding environment that allows you to create music using code. In this tutorial, we'll explore a simple piece of music using Sonic Pi and explain how to modify it to create your own unique sounds.
Before we begin, make sure you have Sonic Pi installed on your system. You can download it from the official website: Sonic Pi.
Here's the Ruby code i wrote:
use_bpm 95
live_loop :bass do
use_synth :fm
play :a2, release: 0.5
sleep 1
play :c3, release: 0.5
sleep 1
play :e3, release: 0.5
sleep 1
play :a3, release: 0.5
sleep 1
play :g2, release: 0.5
sleep 1
play :b2, release: 0.5
sleep 1
play :d3, release: 0.5
sleep 1
play :g3, release: 0.5
sleep 1
end
live_loop :ethereal_keys do
use_synth :prophet
play_chord [:a3, :c4, :e4], release: 2
sleep 4
play_chord [:g3, :b3, :d4], release: 2
sleep 4
end
live_loop :drums do
sample :bd_haus, amp: 2
sleep 1
sample :sn_dolf, amp: 1.5
sleep 1
end
Let's break down the code:
Setting the BPM: use_bpm 95 sets the tempo of our music to 95 beats per minute.
Bass Loop:
:fm synth (frequency modulation) to create a bass sound.play commands specify the notes (e.g., :a2, :c3) and their release times.sleep commands introduce pauses between notes.Ethereal Keys Loop:
:prophet synth to create ethereal keys.play_chord commands play chords (e.g., [:a3, :c4, :e4]) with a longer release time.Drums Loop:
:bd_haus for bass drum and :sn_dolf for snare) to create a basic drum pattern.Now that you understand the code, feel free to experiment:
:piano, :pluck, or others).You've just scratched the surface of what Sonic Pi can do! Keep exploring, and soon you'll be creating your own mesmerizing tunes. 🎵
For inspiration, check out this YouTube video featuring Sonic Pi in action: Sonic Pi Live Coding.
Happy coding! 🎧🎶