Created
June 25, 2019 16:56
-
-
Save bytezen/34d916588bcc5eb67093ae8c5f651eb1 to your computer and use it in GitHub Desktop.
ncgs part1 making a drum pattern
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
##| part1-ncgs-drums.rb | |
##| Let's set the energy of the tune by designing a drum pattern | |
##| choose a tempo for your song | |
##| the default tempo is 60 beats per minute | |
use_bpm 60 | |
##| 1) Kick | |
##| Choose a sound for your kick drum | |
##| Use the 'sample command' and explore | |
##| the samples that you could use for | |
##| the kick sound. | |
##| For this sound choose your lowest sound | |
##| ----------------------------------------- | |
##| Uncomment the line below | |
comment do | |
sample | |
end | |
##| 2) Back beat | |
##| Choose a sound for your back beat | |
##| Use the 'sample command' and explore | |
##| the samples that you could use for | |
##| the Snare. | |
##| For this sound try to choose something punchy and | |
##| a little brighter than the kick | |
##| ----------------------------------------- | |
##| Uncomment the line below | |
comment do | |
sample | |
end | |
##| 3) Hi-hats | |
##| Let's inject some energy into the whole drum line | |
##| with hi-hats. Same thing here, choose a sound for the | |
##| hi-hats. You want something bright and crisp | |
##| ----------------------------------------- | |
##| Uncomment the line below | |
comment do | |
sample | |
end | |
##| 4) Building a Drum Pattern | |
##| Now we are going to put the sounds together to create a drum pattern | |
##| Below are some sample patters that we will discuss in the workshop | |
##| ----------------------------------------- | |
##| in this pattern each number represents a beat | |
##| For this song we will say that 4 beats is a bar and that each beat is a quarter note. | |
##| As an example, in the following list of numbers each number represents 1 beat. | |
##| Playing this pattern would represent playing one bar of music. | |
pattern1 = 1,0,1,0 | |
##| here is a long way to play this pattern. We will do it the long way to understand | |
##| the shortcut that we will use to do it the "real" way. | |
comment do | |
# beat1 = 1 so play the sample | |
sample :bass_hit_c | |
sleep 1 | |
#beat2 = 0 so do not play anything | |
sleep 1 | |
#beat3 = 1 so play the sample | |
sample :bass_hit_c | |
sleep 1 | |
#beat4 = 0 so do not play anything | |
sleep 1 | |
end | |
##| If you run that then you will have played 1 bar of the pattern. | |
##| Now patterns repeat, right? Let's repeat this pattern 4 times so that | |
##| we are symmetrical (a 1/4 note = 1 beat; there are 4 beats in 1 bar; and now we have | |
##| 4 bars as another unit of organization) | |
comment do | |
use_bpm 120 | |
4.times do # can you figure out what this means? | |
# beat1 = 1 so play the sample | |
sample :bass_hit_c | |
sleep 1 | |
#beat2 = 0 so do not play anything | |
sleep 1 | |
#beat3 = 1 so play the sample | |
sample :bass_hit_c | |
sleep 1 | |
#beat4 = 0 so do not play anything | |
sleep 1 | |
end | |
end | |
##| Congratulations! You have your first rhythm pattern! | |
##| OK. Now. A couple more basic concepts before we get to | |
##| kickin' it. I am going to introduce a couple of language | |
##| concepts that will make it easier to jam. | |
##| Instead of 1's and 0's lets make 1's = true and 0's = false | |
##| whenever the computer reads 'true' it will do an action for us | |
##| (play the sample) and when it reads false it won't | |
##| If you run the following code you will see that pattern1 prints out: | |
##| (ring true, false, true, false) - ignore the ring part. But now you see that our | |
##| pattern has been converted into what are called boolean values | |
comment do | |
pattern1 = bools 1,0,1,0 | |
print 'your pattern is: ' | |
print pattern1 | |
end | |
##| Alright how does this make our life easier? | |
##| Uncomment the following code and have a play | |
##| with changing the 1's and 0's in the pattern. | |
##| If you want to hear the change you have to press 'run' | |
comment do | |
use_bpm 120 | |
pattern = bools 1,0,0,1 | |
live_loop :test_pattern do | |
x = tick # make our metronome tick and make x equal to it | |
on pattern[ x ] do # see if the value for this metronome tick is true or false | |
sample :bass_hit_c # if it is true then we will play the sample otherwise not | |
end | |
sleep 1 # Always sleep for some time; here we are sleeping 1 beat | |
end | |
end | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment