# Lesson 20 # Counterpoint Lesson. In this lesson, # we will look at ways to create # counterpoint using Sonic Pi code. # General Instructions: # # This lesson contains one example and # one exercise (A). # # 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. # # Example 1: Bach Invention No. 8. # Notice the new commands "cue" and # "sync." These allow you to synchronize # the timing of separate threads. comment do define :subject do | tonic | subject_a = [4, 7, 12] subject_b = [11, 9, 7, 9, 7, 5, 4, 5, 4, 2, 0] subject_c = [4, 7, 4, 12, 7] seq_a = [4, 7, 5, 7] seq_b = [0, 4, 2, 4] index = 0 amplitude = 0.6 3.times do play tonic, release: 0.25 sleep 0.5 play tonic + subject_a[index], release: 0.25, amp: amplitude index += 1 amplitude += 0.2 sleep 0.5 end index = 0 cue :start 11.times do play tonic + subject_b[index], release: 0.4 index += 1 sleep 0.25 end index = 0 sleep 0.25 5.times do play tonic + subject_c[index], release: 0.25 index += 1 sleep 0.5 end 3.times do index = 0 amplitude = 1.2 4.times do play tonic + 12 + seq_a[index], release: 0.4, amp: amplitude index += 1 sleep 0.25 end end 3.times do index = 0 amplitude = 0.7 4.times do play tonic + 12 + seq_b[index], release: 0.4, amp: amplitude index += 1 sleep 0.25 end end end in_thread do subject :F4 end in_thread do sync :start subject :F3 end end # Exercise A: # Example 1 plays the Invention No. 8 # through measure 6 (partially). Try to # complete the code to play to the # beginning of measure 12. Try # restructuring the code so that # repetitive musical patterns can be # re-used. #