[sdiy] Digital oscillators [was: Active VCO temp compensation]

Antti Huovilainen ajhuovil at cc.hut.fi
Tue Dec 23 03:23:18 CET 2008


On Mon, 22 Dec 2008, Seb Francis wrote:

> I'm curious, what approach are you using to get 'alias free' oscillators? 
> Simply using a much higher internal sampling rate and then a low pass FIR 
> filter?  Or something more sophisticated than this.

Since this question gets asked a lot, I'll list some of the common 
methods. Roughly from easy to hard. Oversampling here means proper 
oversampling with high quality lowpass filtering before decimating to 
target samplerate. Simply averaging N samples will not work.

1) Trivial saw with oversampling
Pros: Easy, can do any waveshape, allows simple sync and FM
Cons: Requires massive (64..256x) oversampling to sound good

2) Sum of sines
Sum nyquist/freq number of sines to produce exactly bandlimited sawtooth.
Pros: No aliasing
Cons: Too slow to be of use in practise.

3a) Differentiated parabole wave
Synthesize parabole (diff(phase^2)*1/freq for -1 <= phase < 1). Aliasing 
falls at 12dB/oct (compared to 6dB/oct for trivial saw).

Pros: Almost as easy as trivial saw. 1/freq can be derived from 
interpolated table lookup (store 1/freq for each note)
Cons: diff(phase^2) can get very small for low frequencies requiring 24 or 
32 bit resolution. Requires 1.5-2x oversampling to avoid annoying warble 
between 10-20 kHz.

3b) Slewrate limited saw
Use a trivial saw-tri pwm oscillator with the pulse width set to exactly 
one sample. Can be shown to be equivalent to 2a.

Pros: Doesn't require frequency dependent scaling or high resolution 
computations.
Cons: Same as 3a

3c) Other waveshaping methods
Several other methods can be used to sample a smooth function and then 
warp the spectrum to resemble saw. Generally slower and more complicated 
than 2a or 2b.

4) Mipmapped wavetables
Precalculate a version (mipmap) for each octave (or half octave) with 
exact number of harmonics. Select nearest mipmap and interpolate the 
stored waveform on playback.

Pros: Good quality with higher order interpolator or oversampling mipmaps. 
Can do arbitrary waveforms. Easy FM. Easy phase distortion.
Cons: Needs lots of memory. Number of harmonics limited for low notes. 
Requires oversampling the mipmaps (using longer table than strictly 
required by the number of stored harmonics) or using high order (FIR) 
interpolator. Requires oversampling or more mipmaps (half or quarter 
octave) to avoid missing frequencies between 15-20 kHz.

5a) BandLimited Impulse Trains (BLIT)
Synthesize bandlimited impulse train and integrate that to produce saw.

Pros: Good quality. No oversampling required.
Cons: Complicated, slow, has numerical issues. Difficult to do FM, PWM or 
sync.

5b) BandLimited StEps (BLEP)
For each oscillator reset, sum a bandlimited step with the trivial saw. 
The steps are precalculated and stored in a table (can be quite short when 
interpolation is used between two phases.

Pros: Very good quality. No oversampling required. Can do bandlimited FM, 
PWM and sync. Probably the only method that can do audio rate PWM and 
sync.
Cons: Requires a divide per cycle. Can be complicated: calculating 
required table entry is not trivial when using sync or pwm.

Antti

"No boom today. Boom tomorrow. There's always a boom tomorrow"
   -- Lt. Cmdr. Ivanova



More information about the Synth-diy mailing list