Chapter 3. Arrays: arranging and accessing your compositional data

 

This chapter covers

  • Declaring and initializing arrays
  • Retrieving and modifying data in arrays
  • Storing different types of data in arrays
  • Using arrays to control musical parameters for a song

Now that you’ve been introduced to the power of the Standard library and Math utilities, you’re going to learn one more important thing in order to make the coding of your melodies and compositions much easier and more expressive and to allow you to create longer songs without excessive typing. This chapter covers arrays, which are super-powerful mechanisms that allow you to make collections of data that you can use for all sorts of things. Arrays are fundamental to how almost all computer programs work. They’re how email, pictures, sound/music files, and everything else get stored and accessed inside computers, smartphones, tablets, and on the web.

An array is a collection of data stored in memory. For composer-programmers, one use for arrays is to store lists of musical parameters that you want to use to control your songs over time, such as musical pitches (or MIDI note numbers), volumes, times, and/or durations. Another use for arrays is to store lists of character strings such as song lyrics. Arrays can store any type of data, and you can even make arrays of unit generators like SinOsc or Noise, which you’ll do in the next chapter.

3.1. Declaring and storing data in arrays

3.2. Reading and modifying array data

3.3. Using array data to play a melody

3.4. Storing other types of data in arrays

3.5. Example: a song with melody, harmony, and lyrics!

3.6. Summary

sitemap