Max Tutorial #4: A Simple Drum Machine

In this tutorial we will use the sequencing techniques covered in previous tutorials to build a simple drum machine. The first difference in this tutorial is that instead of using an oscillator as a sound source, we will use a noise generator called [noise~]. We can connect [noise~] to an envelope generator in exactly the same manner as an oscillator, as illustrated in the video.

Next, we will use the [multislider] in order to customize the drum sound on each step. We will use a resonant low-pass filter to shape the noise sound. This type of filter has two parameters we can control: cutoff frequency and resonance. Accordingly, we will use two [multislider] objects so that we can control these two parameters independently. We will set up the first [multislider] (on the top) to control the cutoff frequency in exactly the same manner as in the previous tutorial (using MIDI note numbers).

The second [multislider], on the bottom, will control the resonance. The resonance parameter ranges from 0-1, so in addition to using eight sliders for our steps, we have to adjust the properties in the Inspector so that the range is from 0 to 1 (the Sliders Output Values remains floating-point since we want to use the decimal values between 0 and 1). Once we have created these two [multislider] objects, we can connect them to a [metro] and [counter 1 8] as before, using the “fetch $1” message.

Now it’s time to add the filter. The filter object is called [lores~]. From left to right, its inputs are audio in, cutoff frequency, and resonance. Therefore we connect the [noise~] source to the left inlet, the output of the [multislider] labeled “frequency” to the middle inlet (via [mtof], as before), and the output of the [multislider] labeled “resonance” to the right inlet. (Add labels or comments by pressing "c" when the patch is unlocked.)

Remember to use the right outlet of the [multislider] each time. You can straighten out the connecting wires by clicking on a wire and pressing command+Y (or going to Arrange -> Auto-Align).

We can connect several objects to the [function] object to trigger the envelope generator. In this case, I’ve connected the [counter] directly to the button, but the output of [metro]—or the right outlet of either [multislider], as before—would also work. Once we make these last connections, we can lock the patch, turn on the audio, and start to customize the drum pattern by changing the position of the sliders in the [multislider] objects and shaping the envelope in [function].