This chapter covers
- Storing sound in computers
- Loading and playing sound files in ChucK using SndBuf
- Working with stereo files
- Modulo, a cool new, musically useful, arithmetic operator
- Making your own drum machine using samples
So far you’ve used only oscillators and noise to make your sounds and compositions. But there’s much more to music composition and production than just these sounds. There are countless types of sounds in the world and in music. In this chapter, we’ll show you how to use sound files in ChucK. Sound files, such as .wav, .aif, or other files you have on your computer or have seen on the internet, are sometimes called samples, for reasons you’ll see soon. Samples are a quick and effective way to build sonic and musical elements with lots of variety and realism. By using samples, you can draw from the huge collection of existing sounds that people have recorded and synthesized over the years.
In later chapters you’ll learn to synthesize your own sounds from scratch. But in this chapter, you’ll use samples to get to the point where you can build your own beat-rockin’ techno drum machine with many new programming skills. First, we’ll take a quick look at how sound is turned from waveforms in the air into digital numbers for computer storage and transmission, called sampling. Then we’ll dig into using samples in ChucK. We’ll also look at new ways to use arrays and also introduce a new math operator called modulo.