Music 220b: Winter 2001
Fernando Lopez-Lezcano, instructor
Christopher Burns, teaching assistant
Tamara Smyth, teaching assistant

Week 3: arrays

Lisp's preferred data structure is the list. However, Common Lisp does provide a variety of other data structures which we can use, including arrays. Arrays are often useful inside the run loop of a CLM instrument; when the run loop is compiled to C, an array can be accessed much more efficiently than an equivalent list.

Arrays are a bit like a row of mailboxes: a series of slots where you can store data. (In this case, "data" can mean almost anything: in CLM we might want to have arrays of soundfiles, or arrays of filters, or arrays of microtonal scales). Each slot has its own number, and you can move data in and out of that slot by referring to the associated number. Arrays can also be multidimensional: think of the mailboxes in the CCRMA lobby as a two-dimensional array.

So how do arrays work? Well, as with unit generators, and most other Lisp structures, we create them first, and then we use them afterwards.

Course resources main page
220b main page