# Lesson 7 # Rhythm Lesson - Part 2. In this lesson, we # will use variables and percussion sounds # to program rhythm patterns, and meters with # a "metronome." # General Instructions: # # This lesson contains three examples and # three exercises (A, B, C). # # 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. # # Note Values. We can use variables to assign # numbers and fractions to beat values to make # our rhythm code easier to read and understand. # Example 1: Some standard rhythm note values: comment do whole = 1 half_dot = 0.75 half = 0.5 quarter_dot = 0.375 quarter = 0.25 eighth = 0.125 sixteenth = 0.0625 play :C5 sleep half play :E5 sleep quarter play :G5 sleep quarter play :B4 sleep quarter_dot play :C5 sleep sixteenth play :D5 sleep sixteenth play :C5 end # Exercise A: Add the following rhythm-value # variables with appropriate value assignments # to Example 1: # 1) eighth_dot # 2) triplet 8th (1/3 of a quarter note) # 3) triplet quarter (1/3 of a half note) # Example 2: Creating Pie Rhythms. In this # example, a Pie is a half note, Apple is # two quarter notes, etc. comment do use_bpm 45 half = 0.5 quarter = 0.25 eighth = 0.125 # Pie play :C play :G sleep half # Apple 2.times do play :C play :G sleep quarter end # Pie play :C play :G sleep half # Blackberry play :C play :G sleep quarter 2.times do play :C play :G sleep eighth end #Huckleberry 4.times do play :C play :G sleep eighth end # Apple 2.times do play :C play :G sleep quarter end # Pie play :C play :G sleep half end # Exercise B # Change the beat values / names in Example 2: # 1) Pie is a quarter note. # 2) Apple is two 8th notes. # 3) Huckleberry is four 16th notes. # 4) Blackberry is an 8th note followed by # two 16th notes. # 5) Create a Butterscotch rhythm (two 16th # notes followed by an 8th note) to # replace the last Apple rhythm. # Example 3: Metronome. Note: the "loop" command # causes the following block of code to repeat # "forever." Click "Stop" at the top of the # Sonic Pi editor to break the loop. comment do use_bpm 120 # This example represents 4/4 meter loop do sample :drum_heavy_kick sleep 1 sample :perc_snap sleep 1 sample :bd_fat sleep 1 sample :perc_snap sleep 1 end end # Exercise C # Change Example 3: # 1) experiment with different bpms # 2) Change the loop so that it plays different # metrical patterns (experiment with different # drum or percussion sounds) # a) 3/4 (one strong beat) # b) 5/4 (2 + 3) # c) 5/4 (3 + 2) # d) 7/8