📻 Coding Familiar Songs | myBetabox

📻 Coding Familiar Songs

Keyboard Guide

Let’s Code Simple Songs We Know

Musical Notes (with Octaves)

Sheet music will show notes on clefs like this. The top is the treble clef and the bottom is the bass clef, which is where you will find the lower-sounding notes. This image also shows us the octave these particular notes are in as indicated by the the small numbers.

Octave Chart

Want a bigger variety? On the left we have the bass clef octaves and on the right are the treble clef octaves. This chart can help you identify which notes fall under which octaves.

Note Symbols

Did you know an A sharp (A#) and a B flat (B♭) are the same note? Sharp notes are a half-step higher and flat notes are a half-step lower than the natural note. In the image below, you’ll see that both A# and B♭ are indeed the same key.

Source: blog.flat.io

Jingles You May Know

Looking at this music sheet, we can code these notes into digital tones! A dotted note has a length of itself plus half. For example, the very last note is an eighth note but has a dot next to it. If eighth notes last for 0.50 beats, then a dotted eighth (de) last for 0.50 + 1/2(0.50) = 0.75 beats!

Copy & Paste This Code in Sonic Pi

#VARIABLES
e = 0.5 #eighth note
s = 0.25 #sixteenth note
de = 0.75 #dotted eighth note (e + 1/2e)

#TEMPO
use_bpm 100

play_pattern_timed [:Eb4, :F4, :G4, :C5, :Bb4, :G4, :F4, :Eb4, :Eb4], [e, e, e, s, e, e, e, s, de]

Another Example

Now that we know how to code notes, octaves, and can recognize notation, can you fill in the missing bars of this song? I’ve filled in the first two bars for you!

Copy & Paste this Code in Sonic Pi

#Blinding Lights
#Key Eb major

#VARIABLES
w = 4 #whole note
h = 2 #half note
q = 1 #quarter note
dq = 1.5 #dotted quarter note
sq = 4.5 #sustained quarter note (for this song)
e = 0.5 #eighth note
de = 0.75 #dotted eighth note
se = 1 #sustained eighth note (for this song)
s = 0.25 #sixteenth note
ds = 0.375 #dotted sixteenth note

#TEMPO
use_bpm 168

#CODE
play_pattern_timed [:F5, :F5, :Eb5], [h, dq, e]
play_pattern_timed [:F5, :G5, :C5, :Eb5], [e, q, se, dq]
play_pattern_timed [],[]
play_pattern_timed [],[]
play_pattern_timed [],[]
play_pattern_timed [],[]

Notes That Sound Good Together

Want to create your own sound? Using the notes in these chords will create a wonderful, melodious tune. Try different combinations!

Copy & Paste This Code into Sonic Pi

# What song is this? Do you recognize it?

play :F
sleep 0.16
play :G
sleep 0.16
play :As
sleep 0.16
play :G
sleep 0.16
play :D5
sleep 0.5
play :D5
sleep 0.5
play :C5
sleep 1

play :F
sleep 0.16
play :G
sleep 0.16
play :As
sleep 0.16
play :G
sleep 0.16
play :C5
sleep 0.5
play :C5
sleep 0.5
play :As
sleep 0.16
play :A
sleep 0.16
play :G
sleep 0.8

play :F
sleep 0.16
play :G
sleep 0.16
play :As
sleep 0.16
play :G
sleep 0.16
play :Bb4
sleep 0.7
play :C5
sleep 0.4
play :A
sleep 0.16
play :G
sleep 0.16
play :F
sleep 0.5
play :F
sleep 0.16
play :C5
sleep 0.5
play :As
sleep 1

play :F
sleep 0.16
play :G 
sleep 0.16
play :As 
sleep 0.16
play :G 
sleep 0.16
play :D5 
sleep 0.5
play :D5 
sleep 0.5
play :C5 
sleep 1

play :F 
sleep 0.16
play :G 
sleep 0.16
play :As 
sleep 0.16
play :G
sleep 0.16
play :F5 
sleep 0.6
play :A 
sleep 0.5
play :As 
sleep 0.16
play :A 
sleep 0.16
play :G 
sleep 0.8

play :F 
sleep 0.16
play :G 
sleep 0.16
play :As 
sleep 0.16
play :G 
sleep 0.16
play :As 
sleep 0.5
play :C5 
sleep 0.5
play :A 
sleep 0.16
play :G 
sleep 0.16
play :F
sleep 0.8
play :F 
sleep 0.2
play :C5 
sleep 0.4
play :As

Now It’s Your Turn!

Using what we know so far, code a few lines of a fun song. Google can help you find the notes you’re looking for. Use the charts above to figure out which octaves your notes are in!

Sonic Pi online keyboard