As noted in our earlier discussion of additive synthesis and Fourier theory, any complex waveform can be decomposed into a (possibly infinite) sum of sinusoids, each with its own amplitude, frequency, and phase parameters. In general, waveforms with time-domain discontinuities in shape or slope require an infinite number of sinusoids to be perfectly reconstructed. There are a number of periodic signals commonly used in sound synthesis that exhibit such discontinuities, including impulse trains, square, sawtooth, and triangular waveforms. To avoid aliasing in a digital synthesis context, it is necessary to determine bandlimited approximations for such signals such that their spectral content does not exceed half the sample rate. A more theoretical analysis of this topic is found in Alias-Free Digital Synthesis of Classic Analog Waveforms
by Tim Stilson and Julius Smith. Another approach (not discussed here) to this problem is found in Hard Sync Without Aliasing
by Eli Brandt.
A number of signals originally used for analog synthesis, including impulse trains, square, sawtooth, and triangular waveforms as shown in Figs. 6 and 7, are also popular in discrete-time synthesis contexts.
Square and impulse train waveforms, with their associated frequency magnitude responses.
Sawtooth and triangular waveforms, with their associated frequency magnitude responses.
These signals are trivial to synthesize with computers using either an iterative, ``algorithmic'' approach or a wavetable.
For example, a digital sawtooth waveform of fundamental frequency f can be generated from
, where Ts is the sample period.
Given the infinite summations of the Fourier series ``recipes'' above, one should expect there to be aliasing in the associated spectra. However, this is not apparent in Figs. 6 and 7.
It turns out that when the waveform period in samples is an integer, the aliased frequency components ``reflect back'' on top of non-aliased components. The aliasing is happening but it is not obvious in this case.
In a discrete-time synthesis context, the period P (in samples) for a periodic signal can be determined from its frequency (f) as P = fs / f, where fs is the sample rate.
As an example, suppose we have a sawtooth waveform with P = 50 and a sample rate fs = 44100 Hz. The fundamental, or first partial, frequency of the signal would be 882 Hz. The 25th partial frequency would be 22050 Hz and the 26th partial frequency would be 22932 Hz. This last component, being greater than half the sample rate, would alias back to 21168 Hz, which is the frequency of the 24th partial.
The aliasing in this case is not obvious because no new spectral components result, though there is an associated timbral modification.
In most synthesis contexts, P is rarely an integer. In order to compute a signal with the correct frequency, it is then necessary to maintain an accurate ``internal'' time index and truncate/round/interpolate it to determine the waveform output at a given time step.
No matter the computational technique used, when P is not an integer, the aliased spectral components will fall between non-aliased components and be clearly perceived, as shown in Fig. 8 for a sawtooth spectrum.
The frequency magnitude response for a sawtooth waveform with non-integer sample period.
This can also be viewed as the addition of noise to the waveform signal introduced by a pitch-period jitter in the sampling process.
Though we have mainly discussed the use of wavetables to produce sinusoidal signals, in fact, wavetable techniques can be used to produce much more complex, periodic signals.
Wavetable techniques must be used with care to avoid aliasing, particularly if the phase incrment is greater than one. To do this, it is necessary to know the highest frequency component in the table and avoid using values of the phase increment that will cause that component to alias. For example, if a table has a single period of a sinusoid added with another sinusoid that has 4 complete periods, then the phase increment must remain at or below N/8, where N is the table size, to avoid aliasing (you need at least two samples per period of the highest frequency component in the table).
One technique that is used in practice is to use additive techniques to generate multiple sawtooth wavetables an octave apart containing bandlimited harmonics. During synthesis, the necessary wavetables to produce a full, though bandlimited, spectrum are mixed together with appropriate weightings.
Finally, an impulse train can be generated by differentiating the sawtooth, and a square wave can be produced by adding a sawtooth to another inverted, delayed sawtooth.
M is the number of harmonics and is always odd. It cannot exceed the period P in samples.
Equation (2) is a closed-form expression that can be used to generate a bandlimited impulse train in a manner similar to the use of DSFs.
The time and frequency magnitude response of an impulse train waveform (440 Hz fundamental) created using the BLIT sinc function of Stilson & Smith.
Note that similar numerical instabilities will arise with this expression as was found with the DSFs. L'Hopital's rule can be used to evaluate the limit of the function as its denominator approaches a value of zero, resulting in
Several other classic waveforms can be created from impulse train signals.
A sawtooth waveform can be created by integrating the combination of a bandlimited impulse train minus a constant obtained by integrating over one period of the impulse train.
A ``bipolar'' impulse train can be created by adding a time-delayed and inverted BLIT to another BLIT, as shown in Fig. 11.
Interestingly, a ``bipolar'' impulse train can also be created by using an even value of M in the closed-form BLIT algorithm above. In this case, the frequency of the resulting signal is 1/2 that with an odd M, so a frequency scaling is necessary.
A bipolar BLIT created by adding a time-delayed and inverted BLIT to another BLIT.
A square waveform can be created by integrating a bipolar BLIT.
Finally, a triangle waveform can be created by integrating the previously computed square wave.
Integration can be achieved with an IIR filter, though a ``leaky'' integrator should be used to avoid DC offset problems.