How to Create Pulse-Width Modulation by Combining Opposite-Polarity Saw Waves
To create pulse-width modulation (PWM), mix two matching sawtooth waves at equal levels, invert the polarity of one, and vary their relative phase. Their opposing ramps cancel between resets, leaving a pulse waveform whose width follows the spacing between those resets. New Systems Instruments explicitly documents this technique for its phase-controlled sawtooth oscillator. Triphase Oscillator
This guide is for synthesizer users who want to build that sound from oscillator and mixing functions. Start with a fixed pulse, confirm that the cancellation works, then introduce movement. The practical choice is whether to control the phase directly or let two slightly different frequencies move it continuously.
What Must Match for Two Saw Waves to Produce a Pulse?
You need two sawtooth signals with the same basic shape, equal amplitudes, opposite polarities, and an adjustable phase relationship. For an exact static pulse, they must also have the same frequency. One signal rises between resets while the other falls; their slopes cancel when summed.
A useful setup consists of a sawtooth source with independently adjustable phase outputs, a mixer that can subtract one signal from another, and a low-frequency oscillator (LFO) for modulation. Alternatively, use two oscillator sources and a separate polarity inverter. The Triphase Oscillator is one documented hardware implementation: it provides same-pitch saw outputs with independent phase controls and a bipolar mixer. Triphase Oscillator
Polarity inversion and phase offset are separate operations. Inversion multiplies every sample or voltage by −1. A phase offset moves the waveform within its cycle. A half-cycle shift of a sawtooth does not itself reverse its slope. Puckette’s waveform analysis shows that subtracting half-cycle-separated saws produces a square wave, while adding them produces a saw at twice the frequency. Sawtooth waves and symmetry
Consequently, a synth’s starting-phase control is useful only if it establishes the relationship you need. Continuous PWM requires a parameter that changes relative phase while the note sounds, or a frequency difference that makes that phase drift.
Why Does Subtracting Saw Waves Change Pulse Width?
Imagine two identical rising saws separated by part of a cycle. Subtract one from the other. Between their resets, both rise at the same rate, so their difference stays constant. When either resets, the difference jumps to another level. The spacing between the two resets determines how long the output occupies each level. This is the delayed-saw subtraction method described in Steffan Diedrichsen’s synthesis note. Pulsewidth modulation
Here is an explicit mathematical convention for predicting the result. Let p be the current phase from 0 up to, but excluding, 1. Define a normalized rising saw as r(p) = 2 × frac(p) − 1, where frac wraps its argument into that interval. For a desired positive-pulse duty cycle D, between 0 and 1, construct y = r(p − D) − r(p).
Under this convention, the output is 2(1 − D) during the first D portion of the cycle and −2D during the remainder. Thus, the positive portion lasts exactly D of each cycle. The following values are an illustrative calculation for ideal saws ranging from −1 to +1, rather than measurements of a particular instrument.
| Positive duty cycle | Relative delay | High level | Low level |
|---|---|---|---|
| 25% | One-quarter cycle, or 90° | +1.5 | −0.5 |
| 50% | One-half cycle, or 180° | +1.0 | −1.0 |
| 75% | Three-quarter cycle, or 270° | +0.5 | −1.5 |
The unequal positive and negative levels at 25% and 75% are expected: each waveform has a zero average in this construction. I checked these three cases numerically over 1,000 evenly spaced phases. Reversing the subtraction reverses the output polarity, so a device’s displayed phase direction may give the complementary positive duty cycle.
At zero relative offset, the identical opposite-polarity waves cancel completely. This endpoint is useful for calibration, but it does not provide a sustained pulse tone.
How Do You Patch a Stable Pulse Before Adding Modulation?
Use the following procedure when your instrument provides matching saw outputs with adjustable relative phase. New Systems Instruments’ manual documents the same core routing: one positive mixer contribution, one negative contribution, and phase adjustment to set pulse width. Triphase Oscillator — User’s Manual, revision 1.01
- Choose two matching saw signals. Use a shared oscillator core or a software oscillator structure that maintains their frequency relationship.
- Remove modulation temporarily. Disable phase randomization and additional voices so you can assess one waveform pair.
- Route both signals to a summing mixer. Keep their paths linear while setting up the cancellation.
- Invert one contribution. Use negative mixer gain or a dedicated inverter. Keep the other contribution positive.
- Match their amplitudes at zero phase offset. Adjust the levels until the summed output approaches silence.
- Move the relative phase to half a cycle. The ideal result is a square wave with equal high and low durations.
- Move toward a quarter-cycle separation. Confirm that one portion becomes shorter while the other becomes longer.
If available, inspect the sum on an oscilloscope. At a fixed offset, look for two approximately horizontal sections separated by transitions. This gives you a concrete check before judging the sound through filters or effects.
Equal knob positions do not necessarily mean equal signal amplitudes. The zero-offset cancellation test checks the complete paths, including oscillator output levels and mixer gains. Once that test works, leave those gains fixed and use phase to set the width.
How Do You Turn a Fixed Pulse Into Controlled PWM?
Apply an LFO to the relative-phase control. As an illustrative starting point, center the relationship around half a cycle and use a slow modulation rate, such as 0.3 Hz. Increase the depth gradually until the pulse changes from broad to narrow without reaching complete cancellation. These are starting settings to adjust by ear, not product specifications.
For a defined modulation range, the earlier convention can be written as D(t) = 0.5 + 0.2 × sin(2π × 0.3 × t), with time t in seconds. This sweeps the positive duty cycle between 30% and 70%, completing one modulation cycle in approximately 3.33 seconds. Translate that range into your instrument’s phase units; do not assume every phase input uses the same voltage scaling.
Moving only one saw’s phase also moves one pulse edge relative to the other. If that produces more pitch movement than you want, try moving both phases equally in opposite directions. The Triphase manual specifically recommends applying the same control signal to both phase inputs with opposite attenuverter settings for less change in the fundamental’s pitch. Triphase Oscillator — User’s Manual
Set the width range before adding further sound shaping. This makes it easier to decide whether a fading tone comes from approaching cancellation or from a later stage in the patch.
Can Slightly Detuned Oscillators Produce the Same Movement?
Yes. Two opposite-polarity saws at slightly different frequencies continually change their relative phase. Puckette’s PWM example uses precisely this approach. It is useful when a synth offers oscillator tuning and polarity inversion but no continuous phase control. Combining sawtooth waves
The phase relationship advances by one complete cycle for every cycle of frequency difference. For example, illustrative frequencies of 100 Hz and 100.2 Hz differ by 0.2 Hz, so their relative phase repeats every 1 ÷ 0.2 = 5 seconds. A fixed frequency difference therefore provides a predictable sweep period.
There is a small mathematical distinction from the equal-frequency construction. For normalized saws, the slopes are proportional to frequency. Subtracting saws at different frequencies leaves a residual slope between transitions; the result approaches a flat-topped pulse as the difference becomes small. This follows directly from differentiating the ramp portions of the saw formula.
Detuning also sweeps through the full relative-phase cycle, including near-cancellation. Direct phase modulation lets you choose a center and limit the excursion. Choose detuning for a continuous rotating relationship; choose phase control when you need a repeatable width range.
What If Your Oscillator Has No Adjustable Phase Output?
Check whether your system can derive a shifted saw from an existing one. Doepfer documents an algebraic method: compare the incoming saw with a control voltage, then add the resulting rectangular signal back at the correct level to obtain a shifted saw. The control voltage sets the effective shift. A-137-2 Wave Multiplier II
If a suitable processor exposes that shifted saw separately, you can combine it with an opposite-polarity original using the method above. Confirm the available outputs first. Doepfer’s A-137-2 description distinguishes its summed output from individual signals available internally; the front-panel sum should not be assumed to be a separately accessible shifted saw. A-137-2 Wave Multiplier II
This gives a practical equipment decision: use independent phase outputs when available, detune two oscillators when a full sweep is acceptable, or use a documented saw-shifting processor with accessible individual signals. The required function is a controllable relationship between matching ramps.
How Do You Diagnose an Unexpected Result?
Work backward from the simplest static patch. The following checks follow from the cancellation model and help separate routing errors from intentional modulation.
| What you observe | What to check | Next action |
|---|---|---|
| A strong saw remains at zero offset | Polarity and amplitude matching | Confirm one negative contribution, then trim levels for cancellation |
| Sloping sections at a fixed width | Frequency, gain, and waveform matching | Remove detuning and compare the two source signals |
| Width changes only at note onset | Starting-phase behavior | Find continuous phase modulation or use slight detuning |
| The sound nearly disappears periodically | Modulation reaches aligned phases | Reduce depth or move the phase center |
| Adding the second saw raises the apparent pitch | Both mixer contributions may have the same polarity | Recheck inversion before adjusting phase |
For digital implementations, also distinguish waveform construction from audio rendering quality. A mathematically direct saw contains discontinuities. SciPy explicitly states that its sawtooth function is not band-limited and that its harmonics alias; sampling two such ramps and subtracting them does not supply an anti-aliasing method. SciPy sawtooth documentation
For an audio-rate software implementation, use a suitable band-limited oscillator method or an oversampled structure with filtering before downsampling. Puckette documents both oversampling and transition-splicing approaches for saw generation. Check the result across the intended note and modulation ranges, rather than relying only on a low-note waveform inspection. Strategies for bandlimiting sawtooth waves
Build the sound in three stages: confirm cancellation at zero offset, establish a square wave at half-cycle separation, and then animate the relative phase. That sequence gives you a dependable reference at each step and makes the final PWM patch easier to control.
Sources
- Triphase Oscillator — New Systems Instruments
- Triphase Oscillator — User’s Manual, revision 1.01
- Sawtooth waves and symmetry — Miller Puckette
- Pulsewidth modulation — Musicdsp.org, Steffan Diedrichsen
- Combining sawtooth waves — Miller Puckette
- A-137-2 Wave Multiplier II — Doepfer
- sawtooth — SciPy documentation
- Strategies for bandlimiting sawtooth waves — Miller Puckette
