In the next few classes we will look at the fundamentals of synthesis. In class we will actually build more extensive patches than are covered here. In this class we will look at synthesis of classic waveforms, sine, sawtooth (aka ramp), square (also pulse, aka rectangle), and triangle. These waveforms are often used in synthesis not only because they are simple to create with analog circuitry, but also because they share characteristics with acoustic instruments. All waveforms have harmonics with decaying amplitude as you go up the harmonic series, similar to most acoustic instruments. The square and triangle waves have only odd partials, similar to a pipe with one end closed. The sawtooth wave has all partials, similar to a pipe with both ends open, or a string. The sine wave has only one partial, so can easily be used to create complex tones by aggregation (additive synthesis). All of these patches can be downloaded here.
1) Basic Waveforms
All of these waveforms are available in Max as internal objects. The following simple patch shows all of them (saw~, tri~, rect~ and cycle~). Each has a frequency input and a sync (phase reset input). rect~ and tri~ have duty cycle inputs, that reshape the waveform by moving the center of the wave shape. Listen to the combination of these waveforms by clicking on the toggle buttons.
2) Duty cycle modulation
This next patch shows the effect of changing the duty cycle in the rect~ (pulse/square wave) and tri~ objects. You will notice that the tone gets brighter when the duty cycle moves away from .5 and toward either 0 or 1.0. A pulse wave with a very small duty cycle (either almost 0.0 or almost 1.0) will have nearly a flat spectrum with little rolloff. Both the pulse wave and triangle wave cancel all even partials when the duty cycle is 0.5. You can see the odd partials diminish by moving from .55 to .50. Modulating the duty cycle with a slow sine wave is a good way to give the sound timbral variation.
3) Detuning, more specifically – SUPERSAW!!
Another way to get timbral modulation is to group several oscillators of the same type and detune them slightly. This will cause the oscillators to go in and out of tune at the rate of the difference between the two frequencies. That is, if the oscillators are separated by 1 Hz, you will hear them go in and out of tune once a second. If you use waveforms which have no odd harmonics (sine, square and triangle), you will have a moment when all harmonics cancel. For this reason, detuning is usually done with sawtooth waveforms or more than 2 of the other waveforms. In this example, I am using 3 sawtooth waveforms. The pow functions are calculating the detuning. This patch is also known as a supersaw, and adding more detuned sawtooth oscillators can make it more complex.
4) Hard Sync – phase resetting.
All of the oscillators in Max have “sync” inputs which reset the phase to the beginning of the cycle. If you use the sync input and the frequency input, the waveform will be reshaped by having a frequency higher than the sync frequency. That is, a frequency of 1.5 Hz will complete 1.5 cycles per second, and a sync frequency of 1 Hz will cause the waveform to repeat every second. The resultant waveform is 1.5 cycles of the normal waveform repeated every second. This interrupted waveform will have a sharp discontinuity and many more high harmonics. This synthesis technique is called hard sync. One interesting aspect of this is that whenever the frequency input is an integer multiple of the sync frequency, you will get a harmonic of the sync frequency.
A couple of notes on this patch. The upper display represents the phase of the oscillator, the middle display is the resultant waveform and the bottom display is a sonogram. There is a bit of ugly logic in the middle of the patch to cause the sawtooth to “wrap” or to keep an amplified phasor~ within the range of 0.0 to 1.0. Max doesn’t have a wrap~ object like pd, so I rescaled the input and output to phasewrap~ to get the same behavior. An experienced Max programmer is welcome to tell me of a better way to do this :).
5) Additive synthesis
Additive synthesis is the technique of adding multiple waveforms which are at the harmonic frequencies of a fundamental frequency. The partials are typically sine waves (which have no harmonics themselves). The harmonic ratios can be easily manipulated, as can the amplitude of each partial. All of these numbers can and usually do change over the duration of a note. This amount of detail allows one to specify an exact timbre, but also requires a large amount of data (typically a separate amplitude and pitch trajectory for 32 or more partials. For this reason, additive synthesis is not often used, as it takes a lot of exacting work to get a good sounding result. Current common uses of additive synthesis are pitch shifting and autotune.
5a) The tone wheel organ. One common example of additive synthesis is the tone wheel organ. The amplitude of each partial is controlled by drawbars. Here is a patch which simulates the drawbar settings for a simple tone wheel organ. Only 8 sine wave oscillators are used, and an ADSR envelope generation object is used to shape the note. This patch is designed to be played by a MIDI keyboard, but the note can be set (the number box above sig~) and a 50ms note played with the bang above delay 50. cycle~ 4 provides a little vibrato. The amplitude is not normalized in this patch, so the output volume needs to be turned down to avoid distortion.
5b) Going down the rabbit hole. This patch demonstrates simple additive synthesis, but also demonstrates the need for more detail. However, creating many oscillators and amplitude controls can be tedious. In this next example I am using the poly~ object to create any number of harmonics. poly~ uses an abstraction (a separate patch) and creates many copies of it. Each copied patch can find out which copy it is from the object thispoly~. For additive synthesis, that number is used for the partial number and is multiplied by the fundamental frequency. There is also a amplitude adjustment which mutes the voice when the frequency is above 20000 Hz. This is a crude method to stop aliasing.
On the right side of the abstraction is a sel object which computes the amplitude for each harmonic. In this example, I am creating various simple waveforms. From left to right: sine, pulse-train, sawtooth and square. You can see under each sel output is logic which determines the amplitude of each partial based on the thispoly~ number. These amplitudes are sent out the out~ 2 outlet to be summed to an overall amplitude.
The external patch is simple in comparison. poly~ creates 64 patches for partials, a radio button selects the waveform, and the left output of poly (the summed sine waves) is divided by the summed partial amplitudes so that the resultant waveform has an amplitude of 1.0.
oscbank~ can alternatively be used for additive synthesis, but independent control of each partial is more difficult.