NOISE GENERATORS, FILTERS, AND SUBTRACTIVE SYNTHESIS
3.1 SOUND SOURCES FOR SUBTRACTIVE SYNTHESIS
PREREQUISITES FOR THE CHAPTER
As you learned in Section 3.1T, the purpose of a filter is to modify the spectrum of a signal in some manner. In this section, before introducing filtering in Max/MSP, we will introduce an object that you can use to display a spectrum: the spectroscope~ object. This graphical object can be found near the end of the palette, in the vicinity of the scope~ object (as shown in Figure 3.1). As usual, if you can’t find it in the palette, create an object box and type the name “spectroscope~” into it.
Fig. 3.1 The spectroscope~ object
Open the file 03_01_spectroscope.maxpat (shown in Figure 3.2).
Fig. 3.2 The file 03_01_spectroscope.maxpat
In this patch, we have connected a selector~ object to the spectroscope so that we can switch between three oscillators, one generating a sine wave (cycle~), one generating a non-band-limited sawtooth wave (phasor~), and one generating a band-limited sawtooth wave (saw~). The three message boxes connected to the left input of the selector~ object are used to pick one of the three oscillators; by setting the frequency in the float number box and then moving between the three oscillators, you can compare their spectra. Observe that the sine wave has only one component, while the phasor~, being a non-band-limited object, has a much richer spectrum.
Make sure to try several frequencies for all of the waveforms, while watching the image being produced by the spectroscope. As stated, the spectrum of the sound being input is what is being displayed: the components of the sound are distributed from left to right across a frequency band that ranges from 0 to 22,050 Hz by default. These two values, the minimum and maximum frequencies that the spectroscope can display, can be modified in the Inspector, using the “Lo and Hi Domain Display Value” attribute in the Value tab. Try adding a spectroscope~ object to a patch that you have already created, so to familiarize yourself with the relationship between sound and its spectral content. You might add the object to the patches found in previous chapters. In 01_14_audiofile.maxpat, for example, you might try connecting the spectroscope to the left outlet of the sfplay~ object, or in IA_06_random_walk.maxpat, you might try connecting it to the outlet of [p monosynth]. (In this last patch, are you able to see the relationship between the frequency of the sound and the shape of the spectrum? Try preset number 5.) Let’s move on to a discussion about ways to produce various types of noise in Max/MSP. The first, white noise, is generated using the noise~ object (as shown in Figure 3.3).
Fig. 3.3 The white noise generator
In the figure (which we encourage you to recreate on your own) we have connected the noise generator to a spectroscope~ object, through which we can see that the spectrum of white noise contains energy at all frequencies. Unlike the sound generators that we have already encountered, the white noise generator doesn’t need any parameters; its function is to generate a signal at the sampling rate consisting of a stream of random values between -1 and 1 (as we discussed in Section 3.1T). The second type of noise generator that is available in Max/MSP is the pink~ object, which, unsurprisingly, generates pink noise (as seen in Figure 3.4).
Fig. 3.4 Pink noise
Note that the spectrum of pink noise, unlike white noise, is gradually attenuated as frequencies get higher, and that this attenuation (as we know from Section 3.1T) is 3 dB per octave.
In Figure 3.5, we see these two waveforms side-by-side.
Fig. 3.5 Waveforms of white noise and pink noise
Without bogging down in technical details, you can see that while white noise is basically a stream of random values, pink noise is generated using a more complex algorithm in which a sample, although randomly generated, cannot stray too far from the value of its predecessor. This results in the “serpentine” waveform that we see in the figure. The behavior of the two waveforms demonstrates their spectral content: when the difference between one sample and the next is larger, the energy of the higher frequencies in the signal is greater.  As you know, white noise has more energy at higher frequencies than pink noise.
Another interesting generator is rand~, which generates random samples at a selectable frequency and connects these values using line segments (as shown in Figure 3.6). Unlike noise~ and pink~, which each generate random samples on every tick of the DSP “engine” (producing a quantity of samples in one second that is equal to the sampling rate), with rand~ it is possible to choose the frequency at which random samples are generated, and to make the transition between one sample value and the next gradual, thanks to linear interpolation.
Fig. 3.6 The rand~ object
Obviously, this generator produces a spectrum that varies according to the frequency setting; it shows a primary band of frequencies that range from 0 Hz up to the frequency setting, followed by additional bands that are gradually attenuated and whose width are also equal to the frequency setting. Figure 3.7 shows this interesting spectrum.
Fig. 3.7 The spectrum generated by the rand~ object
In the example, we can see that the frequency of the rand~ object is 5,512.5 Hz (a quarter of the maximum frequency visible in the spectroscope in the figure), and the first band goes from 0 to 5,512.5 Hz. After this come secondary bands, progressively attenuated, all 5,512.5 Hz wide. Changing the frequency of rand~ changes the width of the bands as well as their number. If you double the frequency to 11,025 Hz, for example, you will see precisely two wide bands, both 11,025 Hz wide.
Another noise generator is vs.rand0~  (the last character before the tilde is a zero), which generates random samples at a given frequency like rand~, but that doesn’t interpolate. Instead, it maintains the value of each sample until a new sample is generated, producing stepped changes in value. The spectrum of this object is divided into bands in the same way as that of rand~ was in Figure 3.7, but as you can see in Figure 3.8, the attenuation of the secondary bands is much less because of the abrupt changes between sample values.
Fig. 3.8 The vs.rand0~ object
In the Virtual Sound Macros library, we also have provided a noise generator that uses cubic interpolation called vs.rand3~ (as shown in Figure 3.9).
Fig. 3.9 The vs.rand3~ object
Thanks to the polynomial interpolation in this object, the transitions between one sample and the next appear smooth, as you can see on the oscilloscope. The transitions form a curve rather than a series of connected line segments, and the resulting effect is a strong attenuation of the secondary bands. Recreate the patches found in figures 3.6 to 3.9 in order to experiment with various noise generators.
“Classic” oscillators – those that produce sawtooth waves, square waves, and triangle waves – are another source of sounds that are rich in components, which makes them effective for use with filters. In Section 1.2, we examined three band-limited oscillators that generate these waves: saw~, rect~, and tri~. We will use these oscillators frequently in the course of this chapter. In Section 3.1T, we also learned about the possibility of filtering sampled sounds. For this reason, we will also give examples in this chapter of filtering sampled sounds, using the sfplay~ object (first introduced in Section 1.5P).
 See Section 1.2. top
 The spectroscope~ object uses an algorithm for spectral analysis called the Fast Fourier Transform. We already mentioned the Fourier theorem at the end of Chapter 2T, and we will return to a much more detailed discussion of it in Chapter 12. top
 We explained this attribute in Section 1.2P. top
 To understand this assertion, notice that the waveform of a high sound oscillates quickly, while that of a low sound oscillates slowly. At equal amplitudes, the difference between succeeding samples for the high frequency case will be larger, on average, than for the low frequency case. top
 You should know from preceding chapters that the “vs” at the beginning of this object’s name means that it a part of the Virtual Sound Macros library. top
3.3 THE Q FACTOR
3.4 FILTER ORDER AND CONNECTION IN SERIES
The umenu object
Higher order filters: in-series connections
3.5 SUBTRACTIVE SYNTHESIS
”Wireless” communications: the pvar object
Multiple choices: the radiogroup object
Anatomy of a subtractive synthesizer
3.6 EQUATIONS FOR DIGITAL FILTERS
Non-recursive, or fir, filters
Recursive, or iir, filters
3.7 FILTERS CONNECTED IN PARALLEL, AND GRAPHIC EQUALIZATION
Using a parallel filterbank
3.8 OTHER APPLICATIONS OF CONNECTION IN SERIES: PARAMETRIC EQ AND SHELVING FILTERS
3.9 OTHER SOURCES FOR SUBTRACTIVE SYNTHESIS: IMPULSES AND RESONANT BODIES
from “Electronic Music and Sound Design” Vol. 1 by Alessandro Cipriani and Maurizio Giri