Lesson 18 of 30 intermediate 4 min read

Before this:Mixing & downconversion

Demodulation in code

Key takeaways Demodulation recovers the message riding on a carrier. With I/Q samples it’s arithmetic: AM is the sample’s magnitude, FM is the rate its phase rotates between samples, and phase demodulation reads the angle directly. The digital voice GopherTrunk decodes — like C4FM — is FM demodulation followed by deciding which symbol level each moment lands on.

You’ve isolated a channel at baseband. Now recover what’s written on it. This lesson turns the modulation types from the RF path into the actual math a decoder runs.

Modulation, in reverse

Recall that a transmitter encodes information by varying a carrier’s amplitude, frequency, or phase. Demodulation undoes each one — and because a baseband sample is a complex I/Q value (an arrow with length and angle), each is a small calculation:

Modulation Information is in Demodulate by
AM amplitude taking each sample’s magnitude (arrow length)
FM / FSK frequency measuring phase change between samples
PM / PSK phase reading each sample’s angle

FM demodulation: the phase-change trick

FM (and its digital cousin FSK) is the workhorse for voice and much digital radio, so it’s worth seeing concretely. Frequency is the rate phase changes. Since each I/Q sample’s angle is its phase, the recovered signal is simply how much the angle turned since the last sample:

sample n-1:  angle = 30 deg
sample n:    angle = 55 deg
-> phase advanced 25 deg -> proportional to instantaneous frequency

Do that every sample and the sequence of angle-changes is the demodulated FM — a few multiplies and an arctangent per sample. This block is often called a discriminator.

From FM to digital symbols

Digital voice like C4FM (used by P25 Phase 1) is FM with a twist: instead of a continuously varying voice tone, the transmitter shifts the frequency to one of four discrete levels, 4800 times a second, each level carrying two bits. So the decoder:

  1. FM-demodulates to get the instantaneous frequency (as above).
  2. Watches it settle near one of four levels each symbol period.
  3. Decides which level — that’s two bits recovered.
+3+1-1-3
C4FM demodulated: the frequency steps between four levels; the decoder decides which level each symbol period holds, recovering two bits each.

But there’s a catch: to read “each symbol period,” the decoder has to know where each symbol begins — and it has no shared clock with the transmitter. Finding those symbol boundaries is the next lesson, clock & symbol recovery. The RF path’s demodulation pipeline walks the same chain from the radio side.

Quick check: to FM-demodulate an I/Q stream, you measure…

Recap

  • Demodulation undoes modulation: AM = magnitude, FM = phase-change rate, PM = angle.
  • On I/Q samples each is a few operations — FM demod is a discriminator.
  • Digital voice like C4FM is FM demod plus deciding which of four symbol levels each period holds.
  • Reading symbols needs their boundaries — the job of clock recovery, next.

Next up: finding where each symbol begins without a shared clock.

Frequently asked questions

How do you demodulate FM from I/Q samples?

FM carries information in the rate the phase changes. With complex I/Q samples the phase is the angle of each sample, so FM demodulation is measuring how much the angle rotates from one sample to the next — the change in angle per sample is proportional to the instantaneous frequency, which is the recovered signal. It’s a few operations per sample.

What is C4FM?

C4FM (compatible four-level FM) is the four-level frequency-shift modulation used by P25 Phase 1 and related systems. The transmitter shifts the frequency to one of four levels, each representing two bits, 4800 times a second. Demodulating it is FM demodulation followed by deciding which of the four levels each symbol landed on.