Skip to content
Techniques & Technology

Pulse Width Modulation

Shaping square waves

Pulse width modulation varied the duty cycle of square waves, transforming simple bleeps into rich, evolving tones that defined the sound of chip music.

C64NESAmiga audiochiptunesynthesis 1980–present

Overview

A square wave at 50% duty cycle sounds hollow and thin. Change that ratio—make the high portion wider or narrower—and the harmonic content shifts dramatically. The SID chip could sweep through duty cycles in real-time, creating dynamic, living sounds from simple waveforms.

Understanding duty cycle

Duty cycleSound character
12.5%Thin, nasal, clarinet-like
25%Hollow, woody
50%Pure square, hollow
75%Same as 25% (inverted)

The duty cycle determines which harmonics are present:

  • 50%: Only odd harmonics (1, 3, 5, 7…)
  • Other ratios: Mix of odd and even

SID implementation

Register layout

RegisterFunction
$D402/03Voice 1 pulse width (12-bit)
$D409/0AVoice 2 pulse width
$D410/11Voice 3 pulse width

Setting pulse width

    lda #$00
    sta $d402        ; Low byte
    lda #$08         ; 50% duty cycle ($800 = 2048)
    sta $d403        ; High byte

Sweeping (PWM)

pulse_sweep:
    lda pulse_lo
    clc
    adc #$10         ; Increment
    sta pulse_lo
    sta $d402
    lda pulse_hi
    adc #$00
    and #$0f         ; Keep in range
    sta pulse_hi
    sta $d403
    rts

Musical applications

Brass sounds

Fast PWM sweep creates brassy attack:

Attack:  Sweep 12% → 50% quickly
Sustain: Hold at 50% or slow sweep

String pads

Slow, subtle PWM creates warmth:

Continuous slow sweep: 25% ↔ 50% over 2-4 seconds

Lead sounds

Moderate PWM adds movement and interest to melodic lines.

NES pulse channels

The NES has fixed duty cycle options:

SettingDuty cycle
012.5%
125%
250%
375%

No continuous sweep—must switch between presets.

Tracker notation

In SID trackers:

Pulse width command: Pxy
x = direction (0=down, 1=up)
y = speed

Combining with other effects

PWM layers beautifully with:

CombinationResult
PWM + Filter sweepRich, evolving pads
PWM + VibratoOrganic lead sounds
PWM + ArpeggioShimmering chords

The “SID sound”

PWM is central to the distinctive SID character:

  • Rob Hubbard’s brass stabs
  • Martin Galway’s warm pads
  • Tim Follin’s aggressive leads

See also