Return Home How was this site made?

Welcome to the Computer Science Pi Party!

Learn about Sonic Pi before making your own music and raving!

What's this exhibition about?

Our exhibition is revolved around a night club so have fun and enjoy your time here! The focus in this exhibition is around Sonic Pi, a music platform used to teach programming with the use of music.

How does it work?

Sonic Pi uses a programming language called Ruby. In Ruby, we use simple instructions to play certain notes and also samples!

Below, we'll go over some basics of Sonic Pi but if you're interested, come make your own music with us!

Sonic Pi Interface

Notes and Sleeps

The first step of Sonic Pi is making sound. Below is a sample of code that produces a note and waits to play another note!


play :C4 # C on a piano!
sleep 2 # wait for two seconds!
play :C4 # Plays C again on the piano!
                    

0:00

0:00

Listen to what this plays!

Live Loops and Loops

If you need to play a note repeatedly, you can utilize loops to repeat them more efficiently!


5.times do # play everything in this 5 times
    play :C4 # C on a piano!
    sleep 2 # wait for two seconds!
end # once 5 times finish, then we are done!
                    

0:00

0:00

Listen to the loop!

If you want to play something forever, you can use a live loop instead!


live_loop :play_c4ever do # play everything in this forever
    play :C4 # C on a piano!
    sleep 2 # wait for two seconds!
end
                    
This is the same as the first loop instead it loops forever

Functions and Parameters

Instead of having to repeat instructions when we use it throughout our song, we can define it and call it when we need to!


define :play_C4 do # define the name of our function
    play :C4 # C on a piano!
    sleep 2 # wait for two seconds!
end # finish when we play C and wait 2!

play_C4 # call the function so it's used!
                    

0:00

0:00

Listen to the function be played!

Let's say that we wanted to just play another note rather :C4. We can utilize a parameter to get to play what we want!


define :play_a_note do | note_we_want | # define the name of our function and a parameter we need
    play note_we_want # plays the note that we want on the piano
    sleep 2 # wait for two seconds!
end # finish when we play the note and wait 2!

play_a_note :D4 # we want to play the note :D4
                    

0:00

0:00

Listen to the parmeter function!

That's the gist of Sonic Pi and an introduction to get you started!

Listen to some songs first!

Before you go make your own music, listen to a few songs and check the code of each song to see if you can understand how it plays!

Have fun!

Thanks for stopping by and make some beats!

Made by Web Dev team with love and care
Discover Music