# Lesson 11 # Arrays Lesson. In this lesson, you # will learn about arrays (ordered # lists). # 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. # # Arrays are ordered collections (lists) # of values or objects. An object or value # in an array is referenced by an # index indicating it's position in the array. # In Sonic Pi, the first value in an array has # an index = 0. # Example 1: Array. comment do major_scale_array = [:C4, :D4, :E4, :F4, :G4, :A4, :B4, :C5] count = major_scale_array.length index = 0 count.times do note = major_scale_array[index] play note sleep 1 index += 1 end end # Exercise A # Change the name and contents of the # major_scale_array in Example 1 # to the following: # 1) minor_scale_array (natural minor) # 2) major_triad_array (root, 3rd, 5th); # use a # comment symbol to comment out # the sleep 1 command. What happens? # 3) chromatic_scale_array (from :C4 to :G4)