Create a gist now

Instantly share code, notes, and snippets.

@uncompiled /hello.rb
Last active Mar 20, 2017

What would you like to do?
Hello by Adele written for Sonic Pi
# Hello... World
use_bpm 75
use_synth :fm
in_thread do
loop do
cue :tick
sleep 1
end
end
in_thread do
# We need a beat!
160.times do
sync :tick
sample :drum_heavy_kick
end
end
in_thread(name: :chord_progression) do
20.times do
# Two measure chord progression.
play_chord (chord :F, :minor), release: 4
sleep 1.5
play_chord (chord :Af, :major), release: 4
sleep 2.5
play_chord (chord :Ef, :major), release: 4
sleep 1.5
play_chord (chord :Df, :major), release: 4
sleep 2.5
end
end
def play_note(note, duration)
play note, release: duration + 0.5
sleep duration
end
in_thread(name: :melody) do
# Intro
sleep 4
sleep 3.75
verse_1
verse_2
2.times do
chorus
end
end
define :verse_1 do
use_synth :blade
# He-
play_note :Bf3, 0.25
# llo...
play_note :C4, 3
# It's me...
play_note :Bf3, 0.5
play_chord [:G3, :Bf3], release: 3.5, amp: 2
sleep 3.25
# I was...
play_note :Af3, 0.5
play_note :C4, 0.25
# Wondering
play_chord [:Af3, :C4], release: 1.5, amp: 2
sleep 0.75
play_note :C4, 0.25
play_note :C4, 0.75
# If after all
play_note :C4, 0.25
play_note :C4, 0.75
play_note :Bf3, 0.25
play_note :Bf3, 0.75
# These years
play_note :Af3, 0.25
play_chord [:G3, :Bf3], release: 1.5, amp: 2
sleep 0.75
# You'd like to meet.
play_note :C4, 0.25
play_note :Bf3, 0.75
play_note :F3, 0.25
play_note :Af3, 1.25
# To go...
play_note :Af3, 0.25
play_note :C4, 0.50
# o-o-ver...
play_chord [:Af3, :C4], release: 1.5, amp: 2
sleep 0.75
play_note :Bf3, 0.25
play_note :Af3, 2.25
# ev-ery-
play_note :Bf3, 0.25
play_note :Bf3, 0.50
# thing...
play_chord [:G3, :Bf3], release: 3.5, amp: 2
sleep 2.75
# They say that time's
play_note :C4, 0.5
play_note :C4, 0.5
play_note :C4, 0.25
play_note :C4, 0.75
# supposed to heal
play_note :C4, 0.25
play_note :C4, 0.75
play_note :C4, 0.25
play_note :C4, 0.75
# ya,
play_note :Bf3, 0.25
# but I ain't
play_note :Af3, 0.25
play_note :Af3, 0.25
play_note :Bf3, 0.25
# done much
play_note(:Bf3, 0.75)
play_note(:Bf3, 0.75)
# heal-ing...
play_note :Af3, 0.75
play_note :Af3, 1
# <pause>
sleep 1.25
end
define :verse_2 do
use_synth :blade
# He-
play_note :Bf4, 0.25
# llo...
play_chord [:Af4, :C5], release: 3.5, amp: 2
sleep 3
# can you hear me?
play_note :Bf4, 0.25
play_note :Bf4, 0.25
play_chord [:G4, :Bf4], release: 1, amp: 2
sleep 0.50
play_note :C5, 2.75
# I'm in California
play_note :Af4, 0.5
play_note :C5, 0.25
play_note :C5, 0.75
play_note :C5, 0.25
play_note :C5, 0.75
play_note :C5, 0.25
# Dreaming
play_chord [:Af4, :C5], release: 1.5, amp: 2
sleep 0.75
play_note :Bf4, 0.25
# About who we used to be.
play_note :Bf4, 0.75
play_note :Af4, 0.25
play_chord [:G4, :Bf4], release: 1.5, amp: 2
sleep 0.75
play_note :C5, 0.25
play_note :Bf4, 0.75
play_note :F4, 0.25
play_note :Af4, 1
# When we were...
play_note :Af4, 0.25
play_note :Af4, 0.25
play_note :C5, 0.50
# young-er-rr
play_note :C5, 0.75
play_note :Bf4, 0.25
play_note :Af4, 2.50
# And free...
play_note :Bf4, 0.50
play_chord [:G4, :Bf4], release: 4, amp: 2
sleep 3.25
# I've forgotten.
play_note :Af4, 0.50
play_note :C5, 0.25
play_note :C5, 0.75
play_note :C5, 0.25
# How it felt
play_note :C5, 0.75
play_note :C5, 0.25
play_note :C5, 0.75
# before
play_note :Bf4, 0.25
play_note :Bf4, 0.75
# the world fell at our feet,
play_note :Af4, 0.25
play_note :Bf4, 0.75
play_note :C5, 0.25
play_note :Bf4, 0.75
play_note :F4, 0.25
play_note :Af4, 0.75
# There's such a difference.
play_note :Af4, 0.50
play_note :Af4, 0.50
play_note :C5, 0.50
play_note :C5, 1
play_note :Bf4, 0.25
play_note :Af4, 1.75
sleep 0.50
# Between us
play_note :Ef5, 0.25
play_note :Ef5, 1.25
play_note :C5, 0.50
play_note :Df5, 0.25
play_note :C5, 0.25
play_note :Bf4, 0.25
play_note :Af4, 0.75
# And a
play_note :Af4, 0.50
play_note :C5, 0.50
# Million
play_note :C5, 1
play_note :Bf4, 0.50
play_note :Bf4, 1.0
play_note :Af4, 0.50
# Miles
play_note :Af4, 5
end
define :chorus do
sync :tick
use_synth :blade
use_synth_defaults amp: 2
# Hello from the other
play_chord [:F3, :C3], release: 1.5
sleep 0.50
play_note :F3, 0.50
play_note :Af3, 0.50
play_chord [:Df3, :F3, :Af3], release: 1, amp: 3
sleep 0.50
play_chord [:Df3, :F3, :Bf3], release: 1, amp: 3
sleep 0.50
play_chord [:Df3, :F3, :Bf3], release: 1, amp: 3
sleep 0.50
# si-i-ide
play_chord [:F3, :Bf3], release: 2.5, amp: 3
sleep 2.5
play_chord [:Ef3, :Af3], release: 2, amp: 3
sleep 1
play_note :F3, 1
# I must have called a thousand
play_note :F3, 0.50
play_chord [:C3, :F3], release: 1, amp: 3
sleep 0.50
play_note :F3, 0.50
play_note :Af3, 0.50
play_chord [:C3, :F3, :Af3], release: 1, amp: 3
sleep 0.50
play_note :Bf3, 0.50
play_note :Bf3, 0.50
# t-i-imes...
play_note :Bf3, 1.25
play_note :C4, 0.25
play_note :Bf3, 1
play_note :Af3, 1.25
# To tell you
play_note :Af3, 0.25
play_chord [:Ef4, :Ef5], release: 1, amp: 2
sleep 0.50
play_note :Bf3, 0.25
play_note :Af3, 0.75
# I'm sorry.
play_note :C4, 1
play_note :Af3, 1
play_note :Af3, 0.75
# For everything that I've done,
play_note :Af3, 0.25
play_note :Af3, 0.25
play_note :Af3, 0.25
play_note :Af3, 0.50
play_note :G3, 0.50
play_note :F3, 0.50
play_note :Ef3, 0.75
# But when I call,
play_note :Ef3, 0.25
play_note :Ef3, 0.50
play_note :Ef4, 0.50
play_note :Af3, 1
# You never...
play_note :C4, 1
play_note :Af3, 0.75
play_note :Af3, 0.125
play_note :F3, 0.125
play_note :Ef3, 1.5
# Seem to be home.
play_note :Af3, 0.50
play_note :G3, 0.50
play_note :F3, 0.50
play_note :Ef3, 1.5
# <pause>
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment