My Independent Study Project
Concept
Coding small functions and putting them together to incorporate into the development of music beats and rhythm and pitch which are then used to create music compositions and patterns, through the use of the languages C++ , Ruby, Qt , on the platform Sonic PI!
Motivation
My team and I were fascinated with the idea of combining our two interests, computer science and music. We wanted to learn how to make musical sounds from creating segments of code to eventually make our own song. Through this process, we learned about music composition and theory as well as new coding languages and a new technology. Creating and modifying beats through code motivated us to keep going, and eventually creating a music score. This project was something my team and I never dwelved into before, so learning and creating through this process was an amazing and beneficial takeaway to apply to future computer science works.
Code Segments
chord(:e, :major),
chord(:e, :major), chord(:g, :major),
chord(:d, :major),
chord(:f, :major),
chord(:c, :major),
chord(:d, :minor),
chord(:e, :minor))
second_ring = (ring chord(:f, :major),
chord(:c, :major),
chord(:e, :major7),
chord(:a :minor),
chord(:f, :major),
chord(:c, :major),
chord(:d, :minor),
chord(:e, :major),
We wanted to use ring arrays to arrange our chords in the order it is in now, so that the function instructs Sonic Pi to keep looping around the same notes in the list each time. We named our first ring array: beg_ring (beginner ring) and our second chord progression ring array: second_ring. This will be useful later when it is called in our other functions, so we don’t have to write our chords multiple times.
play beg_ring.tick.tick, attack: 1, sustain: 1, release: 1.50
sleep 2
end
live_loop :opening_deep do
play beg_ring.tick.tick, attack: 0.5, release: 1
sleep 2
We used the live_loop function so that we could update the code whilst it is playing and click ‘Play’ again without stopping the current song to hear the changes. The ‘play’ function allowed us to play the beg_ring chord progression, and added the .tick to be used as a counter (like a beat tracker) to “tick through the rings” and give us control over when a beat occurs. We utilized the sustain and release utilities to help add depth and character to mature the musical compositions tone value.
use_synth :hollow
with_fx: flanger do
with_fx: gverb do
play beg_ring.tick, amp: 0.6, attack: 1, sustain: 5, release: 3
sleep 4
end
end
end
We used the use_synth :hollow function which changes the synthesiser for the notes played in that block (beg_ring chord). It gives it a more “hollow” sound as the name implies. We used the fx flanger and gverb as well. Giving it a more robust and dramatic effect. We changed the amplitude to be quieter from the previous chord progressions.
if one_in(5)
with_fx :octaver do
sample :glitch_bass_g, amp: 2.25, rate: rrand(-7, -8.9), release: 6
end
end
sleep 5
end
We used a simple one_in function to optionally execute this line of code, so a probability of 1 in 5 in different intervals. We used fx :octaver to give the sample a more techno sound We used the rrand function to randomize the rate value (speed) of the note from a max of -7 to -0.9)
if one_in(9)
sample :ambi_choir, amp: 1.5, rate: rrand(0.8, 0.9), release: 6
end
sleep 3
end
live_loop :octave do
if one_in(3)
with_fx :octaver do
sample :glitch_bass_g, amp: 2.45, rate: rrand(-0.2, -0.6), release: 6
end
end
sleep 6
end
We basically used around the same functions as the previous block. We used the sample ambi_choir and amplified it louder because we wanted a more gospel sound in the function called “shout” We also amplified the sample glitch_bass_g to be louder to give it a richer sound at times. The sleep functions are different numbers and we used randomization to give the song more dynamic.
with_fx :octaver do
sample :glitch_bass_g, amp: 2.40, rate: rrand(-0.2, -0.6), release: 6
end
sleep 6
end
live_loop :melody do
use_synth :hollow
with_fx :gverb do
with_fx: flanger do
play second_ring.tck, amp: 3, attack: 1, sustain: 3, release: 0
sleep 3
end
end
end
We changed the amplitude of the sample :glitch_bass_g and hollow to be amplified differently from the previous ones and to have different attack and release times to create a more cohesive and harmonic sound when put together.
if one_in(8)
sample :ambi_choir, amp: 6, rate: 0.9, decay: 8
end
sleep 10
end
This is our last piece of code, where we took the sample : ambi_choir and tweaked its amplitude, rate, and decay to add a different dynamic to the song but with cohesion and rhythm.
Conclusions