🎵 Why oscillator design matters

The oscillator is the heart of any synthesizer—the raw sound source that everything else shapes, filters, and modulates. In analog hardware, you get bandlimited waveforms "for free" because physical components naturally low-pass the signal. But in digital synthesis, sampling theory imposes a hard limit: any frequency content above half the sample rate (the Nyquist frequency) will alias—fold back into the audible range as inharmonic, metallic artifacts.

For a typical 44.1 kHz sample rate, Nyquist sits at 22.05 kHz. A perfect sawtooth wave mathematically contains infinite harmonics, extending far beyond human hearing. When you try to synthesize that digitally without care, every harmonic above 22.05 kHz wraps back down into the audible spectrum. The result? Harsh, glassy high end, pitch instability during modulation, and the distinctive "digital" harshness that gives early soft synths a bad reputation.

This article walks through practical techniques that software and hardware designers use to build oscillators that stay clean across the keyboard, respond musically to FM and sync, and maintain stable timbre under aggressive modulation. These patterns—PolyBLEP, minBLEP, phase continuity, and modulation-aware design—are the difference between a synth that sounds like a cheap toy and one that holds its own in professional production.

Why naïve waveforms fall short

A raw saw or square computed from immediate discontinuities aliases as soon as the harmonic count exceeds Nyquist. You hear this as glassy, unstable top-end and zipper noise during modulation. The musical fix is bandlimiting at the discontinuity, keeping phase continuous and ensuring derivatives remain bounded where possible.

When you generate a sawtooth as 2 * phase - 1, the discontinuity at phase wraparound creates infinite harmonics. At 44.1 kHz sample rate, any fundamental above ~1.3 kHz will alias, folding high harmonics back into the audible range as harsh, metallic artifacts. The same problem hits square waves, pulse width modulation, and hard sync—anywhere you have instantaneous jumps in amplitude.

🔧 Practical bandlimiting: BLEP, PolyBLEP, minBLEP

BLEP (Bandlimited Step) techniques add a compensating step response—a bandlimited impulse—at the moment of discontinuity. This removes energy above Nyquist while preserving the clean, sharp waveform character below. PolyBLEP is a lightweight variant that evaluates a polynomial correction inside the current sample interval, requiring no lookup tables and minimal CPU overhead. Valimaki and Huovilainen's paper "Antialiasing Oscillators in Subtractive Synthesis" provides the mathematical foundation.

For a sawtooth, check if the phase increment will cause a wrap in the next sample. If so, compute the fractional distance to the wraparound point t = (1.0 - phase) / phaseInc, then apply a correction polynomial. A second-order PolyBLEP uses t*t - 2*t + 1 for t < 1, giving you a smooth correction that scales with the step size. The beauty is simplicity: no tables, just a few floating-point ops per discontinuity. Many open-source implementations demonstrate this technique effectively.

MinBLEP (minimum-phase BLEP) tables offer more flexibility. Precompute a bandlimited step at high resolution, then insert it at the exact fractional crossing time via interpolation. This handles hard sync, pulse-width modulation, and variable waveshapes elegantly. The tradeoff is memory and slightly more complex code, but the sonic quality is exceptional—especially when sync or FM push harmonics high.

PolyBLEP for saw & square

Low Cost

Apply a small polynomial correction when the phase wraps. This removes the step while preserving phase continuity. Works great for basic waveforms and extends to PWM with careful handling of both edges.

minBLEP tables

Flexible

Precomputed bandlimited step inserted at the exact crossing time via fractional delay. Handles hard sync, variable waveshapes, and extreme modulation scenarios with grace.

Phase continuity matters

Modulation

Under FM or audio-rate PWM, keep phase continuous and avoid sudden frequency jumps. Smooth parameter changes with one-pole filters (1–5 ms time constant) to remain musical and prevent zippering.

🎛️ Waveshaping without aliasing

Start with bandlimited base oscillators, then apply waveshapers whose transfer functions avoid sharp corners. Tanh saturators, polynomial soft clippers, and smooth foldback functions stay musical because their derivatives are continuous. Avoid hard clipping min(max(x, -1), 1) on audio-rate signals—it reintroduces the aliasing you just removed. Julius O. Smith's Physical Audio Signal Processing book covers waveshaping and virtual analog techniques in depth.

For aggressive waveshaping and wavefolding, embrace 2× or 4× oversampling. Upsample with a good interpolator (polyphase FIR), apply your transfer function, then downsample with a matching anti-alias filter. The extra CPU cost is worth it for clean, aggressive timbres. Many modern VSTs use this approach for distortion and wavefolder circuits.

📈 FM that stays in tune

Frequency modulation can destabilize pitch tracking if not handled carefully. Prefer phase modulation (PM) over true FM—it's mathematically equivalent for sine carriers but keeps the base frequency stable. Clamp modulation indices per note to prevent the sidebands from running away at high pitches: scale index inversely with frequency so bass notes get rich FM and treble stays focused.

Compensate for keyboard scaling by applying a gentle curve: index *= 1.0 / sqrt(frequency / 440.0) is a good starting point. This keeps harmonic density musically consistent across octaves. Always low-pass filter your modulation sources to prevent aliasing from the modulator—treat the modulator signal path as carefully as the carrier.

🧪 Test strategy

Measure with spectrograms during long sweeps (10 seconds, 20 Hz to 10 kHz) and watch for aliasing artifacts folding back. Compare against a 10× oversampled offline reference render—compute the residual and check that it stays below -80 dB. Sweep modulation rates from sub-audio to 1 kHz and verify timbre remains stationary.

Listen critically: play chords across the keyboard, let envelopes decay to silence, and patch aggressive modulation. If you hear brightness shift unnaturally with pitch or noise in the decay tail, you've found aliasing or a parameter smoothing issue. Fix it before moving on—these artifacts compound in a full mix and are much harder to diagnose later.