Chapter 2. Libraries: ChucK’s built-in tools

 

This chapter covers

  • Library functions (methods)
  • The ChucK Standard library, conversion of units
  • Standard library type conversion
  • The ChucK Math library
  • Math library random number generation and sine function
  • Using library functions to make your music more expressive

Now that you have your feet wet and have learned the basics of how to use ChucK, and you’ve created your first set of compositions, it’s time to learn how to make even more expressive music and sound. You’ll also be learning how to make your programming easier as well as your programs more readable. In this chapter we introduce libraries, which are sets of tools built into ChucK that will help you accomplish these goals.

In almost all programming languages there are general sets of utility functions that come in the form of libraries. These libraries handle basic functions that programmers have to use at one point or another. You can look at these functions as tools, and those tools are kept in toolboxes (each library) according to their type.

The individual tools are sometimes called methods or functions, which you’ll learn more about in chapter 4.

2.1. The Standard library: tools for pitch, loudness, and more

2.2. The ChucK Math library

2.3. Stereo and panning

2.4. Example: random music with two voices and panning

2.5. Summary