Chapter 9. Objects and classes: making your own ChucK power tools

 

This chapter covers

  • Data encapsulation and access, member variables
  • Behavior of objects, functions, and methods
  • Public vs. private classes
  • Inheritance, overloading, and polymorphism
  • Musical applications of objects and classes

As you keep adding to your bag of ChucK tricks and tools, you’re able to be more expressive in your compositions, more succinct and efficient with your code, and generally more awesome as programmers and composers. In chapter 5, you learned how to make your own functions, opening up new capabilities for your programming, because you could reuse code and get a lot more work accomplished by calling functions with different arguments. In the previous chapter, you learned how to run programs and functions in parallel, again adding to your programming power and musical expressiveness. In this chapter, you’ll learn how to make your own objects and classes, which can be viewed as super-functions but even more powerful. When you’re through, you’ll have even more ways to organize, use, and reuse your ChucK code. And your music and art will be even better.

9.1. Object-oriented programming: objects and classes

9.2. Writing your own classes

9.3. Overloading: different functions can share the same name

9.4. Public vs. private classes

9.5. Initialize.ck: an architecture for organizing your code

9.6. Conducting a drum pattern using a time-varying BPM

9.7. Making new classes from existing classes

9.8. Example: building a smart mandolin player

9.9. Summary