# Lesson 2 # Rhythm Lesson. In this lesson, learn to # convert numerical values into meaningful # musical rhythms. # General Instructions: # # This lesson contains four examples and two # exercises (A, B). # # To listen to an example, change "comment" # to "uncomment" on the "comment do" line, # then click the "Run" menu command at the # top of the Sonic Pi editor window. # When you are done with the example, turn # it off by changing "uncomment" back to # "comment," and move on to the next section # of the lesson. # # The Sleep Command. Sonic Pi will play all # notes at once unless the play commands are # separated by a sleep command. The sleep # command is the key to creating different # rhythm patterns. # Example 1: Three notes play at once (no # sleep command): comment do play 60 play 64 play 68 end # Example 2: Use the sleep command to insert # one beat between each note: comment do play 60 sleep 1 play 64 sleep 1 play 68 end # Beat: In Sonic Pi a beat = 1. By default, a # beat lasts for one second, because Sonic Pi # automatically sets the beats-per-minute value # to 60. This is the same as setting a metronome # to 60. (60 beats / minute = 1 beat / second). # You can change the beat-per-minute value # with "use_bpm." # Example 3: comment do use_bpm 120 play :C sleep 1 play :D sleep 1 play :E end # The code in Example 3 sets the beats-per-minute # to 120, so the beat rate is twice as fast as # 60 bpm: 120 beats / minute = 2 beats / second # Exercise A # Change the bpm value in Example 1 to: # 1) 100 beats per minute # 2) 1 beat every 2 seconds # (hint: bpm number < 60!) # 3) 3 beats per second # (hint: bpm number > 120!) # Rhythm Variety. # In simple meters like 4/4 and 3/4, we usually # say "the quarter note gets the beat." # So, for example # 1 = quarter note # 2 = half note # 3 = half note dot # 4 = whole note # We can also use fractions and decimals: # 1.0/2.0 = 8th note # 1.0/4.0 = 16th note # 0.5 = 8th note # 0.25 = 16th note # [NOTE: in Sonic Pi, fractions smaller than 1 # should use decimal numerators and denominators # instead of whole numbers. Otherwise the fraction # will be read as 0. # # Correct: # 1.0 / 2.0 # 2.0 / 3.0 # 1.0 / 4.0 # 1.0 / 8.0 # # Incorrect (will be read as 0): # 1 / 2 # 2 / 3 # 1 / 4 # 1 / 8 # # Example 4: Run the sample code below to hear # a familiar tune. Giving the sleep command # different beat values changes the rhythm. comment do use_bpm 100 play 60 sleep 1 play 60 sleep 1 play 67 sleep 1 play 67 sleep 1 play 69 sleep 1 play 69 sleep 1 play 67 sleep 2 play 65 sleep 1 play 65 sleep 1 play 64 sleep 1 play 64 sleep 1 play 62 sleep 1 play 62 sleep 1 play 60 sleep 2 end # Exercise B # 1) Change the bpm value in Example 4 so # that the tune plays twice as fast. # 2) Keep the new bpm value from 1), but # change the values of the beats in Example # 4 so that the tune plays twice as slowly; # the tune should play at the same speed # as the original tempo, even though the # bpm is twice as fast. # TIP: Instead of changing each beat value # directly, you can multiply each beat # value by a constant factor. For example, # if you wanted to make each beat three # times as long: # sleep 1 * 3