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.
Figure 6:
Square and impulse train waveforms, with their associated frequency magnitude responses.
Figure 7:
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 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.
Figure 8:
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.
A relatively simple approach to creating bandlimited versions of the classic analog waveforms previously discussed (or any other complex, periodic waveforms) is to use additive synthesis.
Each waveform can be formed using appropriated weighted sinusoids (as described by their Fourier series) up to, but not including, the Nyquist frequency.
Care must be taken when the fundamental frequency is changing in time ... it would be best to gradually fade out the highest component rather than suddenly have it disappear when it reaches fs / 2.
While additive techniques might seem a bit ``costly'' for this purpose, high-frequency signals will not have that many harmonics less than half the sample rate.
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.
However, wavetable techniques are not guaranteed to be bandlimited when the phase increment is greater than one sample. In such a case, the wavetable operation is equivalent to downsampling which can alias if the frequency content of the wavetable is higher than half the effective downsampled rate.
It is necessary to know the relative frequency content of a complex wavetable so that an upper bound on the phase increment can be enforced.
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.
Discrete-Summation Formulae are based on the closed form expression for the geometric series:
Dodge and Jerse (1985) provide the following formula for the synthesis of a bandlimited impulse train:
(1)
Figure 9 provides a time- and frequency-domain plot demonstrating the use of this formula.
Figure 9:
The time and frequency magnitude response for an impulse train waveform (440 Hz fundamental and 40 partials) created using the DSF of Dodge & Jerse.
Typically, there are numerical problems when the denominator of these formulae get close to values of zero.
Dodge and Jerse (1985) provide the following formula for use when the denominator of Eq. (1) gets close to a value of zero:
Other waveform shapes can be generated from the bandlimited impulse train, as will be described below.
The ideal anti-aliasing filter, applied to a continuous-time signal before sampling, consists of a rectangular window applied in the frequency domain with a cutoff at half the sample rate.
The inverse Fourier transform of this filter is a sinc function with a zero-crossing interval of one sample:
The ideal unit-amplitude impulse train with period T1 seconds is given by
In order to bandlimit the ideal impulse train, we can apply the ideal anti-aliasing filter hs to it as:
where P = T1 / Ts is the period in samples.
Since xf(t) is now bandlimited, it can be sampled without aliasing as
This infinite summation can be reduced to an expression of the form (Stilson and Smith, 1996)
(2)
where the digital sinc function is given by
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 which can be used to generate a bandlimited impulse train in a manner similar to the use of DSFs.
Figure 10:
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. Using l'Hopital's formula, the the following formula is found for use when the denominator of Eq. (2) gets close to a value of zero:
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.
Figure 11:
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.