Hilbert Transform Simulator Back
Signal Processing Simulator

Hilbert Transform & Analytic Signal — Envelope Detection

Apply a DFT-based Hilbert transform to an AM signal and extract the instantaneous amplitude, phase and frequency from the analytic signal. Change the carrier frequency and modulation index to learn envelope detection and demodulation visually.

Parameters
Carrier frequency f_c
Hz
Modulating frequency f_m
Hz
Modulation index m
Number of samples N

Sampling rate F_s = 1000 Hz is fixed. The Hilbert transform is computed every frame with an FFT, animating in real time how the envelope tracks the AM modulation as the signal scrolls. Moving the sliders updates it instantly.

While paused, move the sliders to update the result instantly.

Results
Carrier frequency f_c
Modulation frequency f_m
Peak envelope amplitude |z|max
Instantaneous frequency f_i
Signal, envelope, instantaneous phase and frequency

Top: original signal x[n] (blue) and ±A[n] (red, envelope). Bottom: instantaneous phase φ[n] (green, after unwrap) and instantaneous frequency f_i[n] (yellow, right axis).

Theory & Key Formulas

The Hilbert transform is a linear transform that extends a real signal to an analytic (complex) signal. In the DFT domain it is implemented by doubling the positive-frequency components, zeroing the negative ones and applying the inverse DFT.

Analytic signal z(t) from the original signal and its Hilbert transform:

$$z(t) = x(t) + j\,\mathcal{H}[x](t)$$

Instantaneous amplitude A(t) (the envelope) and instantaneous phase φ(t):

$$A(t) = |z(t)| = \sqrt{x(t)^2 + \mathcal{H}[x](t)^2}, \qquad \phi(t) = \arg z(t)$$

The instantaneous frequency f_i(t) is the time derivative of the instantaneous phase:

$$f_i(t) = \frac{1}{2\pi}\frac{d\phi(t)}{dt}$$

Applied to the AM signal x(t) = (1 + m·cos(2π f_m t))·cos(2π f_c t), it directly gives the envelope A(t) = 1 + m·cos(2π f_m t), and the instantaneous frequency equals the carrier frequency f_c.

What is the Hilbert Transform Simulator

🙋
I've heard the name "Hilbert transform" but what does it actually do? And how is it different from the Fourier transform?
🎓
Roughly speaking, the Hilbert transform shifts every frequency component of a signal by -90 degrees in phase. Think of cos turning into sin. Combined with the original signal it forms the analytic signal z(t) = x(t) + j H[x](t), a complex signal that opens up a lot of signal-processing tricks. In the simulator above, set the modulation index m to 0.5 and look at the graph: a red envelope sits tightly above and below the blue original signal. That red line is |z(t)|.
🙋
Oh you're right. The "outer shape" of the wiggly signal is pulled out in red. What is this used for?
🎓
The clearest example is AM radio demodulation. An AM signal is "audio waveform times high-frequency carrier" and what you want is the audio — the envelope. Old radios did half-wave rectification with a diode and smoothed it with a low-pass filter, but the Hilbert transform extracts the envelope mathematically and exactly. Think of it as a universal tool for measuring the "outline" of a waveform.
🙋
The yellow line on the lower graph, the "instantaneous frequency", stays around 100 Hz — is that because the carrier frequency f_c is 100 Hz?
🎓
Exactly. Differentiating the phase φ(t) of the analytic signal in time gives the "frequency at this instant". An AM signal doesn't change the carrier frequency itself, so the instantaneous frequency is pinned to f_c. Try pushing the "Carrier frequency" slider to 200 Hz — the yellow line should slide right up to around 200 Hz.
🙋
So for an FM-like signal where the frequency moves, the yellow line would wave around too?
🎓
Yes, that is exactly the principle of FM demodulation. FM puts the audio information on the instantaneous frequency, so differentiating φ(t) of the analytic signal recovers the audio. The I/Q demodulator of a digital radio receiver is essentially a Hilbert-transform based complex signal processor. In practice it is also crucial for mechanical vibration diagnostics — "envelope analysis" of bearing fault impacts is a field standard.

Frequently Asked Questions

The time-average of A(t) = 1 + m·cos(2π f_m t) is 1, but its root-mean-square is √(1 + m²/2). For m = 0.5 this gives √1.125 ≈ 1.061. The gap between linear average and RMS represents signal power, and exactly the same calculation appears in AM broadcast transmitter design as the distinction between "carrier power" and "average total power".
The DFT implementation returns the mathematically exact analytic signal but tends to produce discontinuities at the edges (Gibbs phenomenon) and is not suited to real-time processing. The FIR filter implementation approximates the transform with a finite-length Hilbert transformer (odd taps, antisymmetric coefficients) and allows low-latency streaming, which is why it is used in DSP and digital radio. This tool uses a DFT implementation for educational clarity and excludes the outer 10% from statistics to avoid edge artefacts.
atan2 only returns the principal value in -π to π, so the phase jumps periodically. Since the instantaneous frequency is the time derivative of phase, large spikes appear at every jump. Unwrapping adds ∓2π whenever a sample-to-sample difference exceeds ±π to make the phase continuous, after which the difference gives the correct instantaneous frequency. The phase in the lower panel is already unwrapped, and the green line is close to a straight line going up.
With F_s = 1000 Hz fixed, N = 256 covers a 0.256 s window while N = 1024 covers 1.024 s. A short window contains only 2–3 cycles of the modulating frequency f_m = 10 Hz (period 0.1 s), so the estimate of modulation depth degrades. The compute is much faster though. The direct DFT is O(N²), so N = 2048 takes about 16 times longer. In practice an FFT with O(N log N) cost is standard.

Real-World Applications

AM radio and wireless demodulation: The analytic signal via the Hilbert transform underlies AM demodulation, SSB (single-sideband) modulation and FM demodulation. SSB in particular halves the communication bandwidth by transmitting only one frequency sideband, and is widely used in long-distance amateur radio. The I/Q demodulator of a digital radio receiver is essentially complex signal processing with a built-in Hilbert transformer.

Machine vibration diagnostics (envelope analysis): Bearing faults and gear-mesh problems in rotating machines appear as AM signals — low-frequency repetitive impacts riding on a high-frequency resonance band. Band-passing the resonance, computing the envelope with the Hilbert transform and then taking an FFT reveals the fault repetition frequencies (BPFO, BPFI, BSF, etc.) as peaks. This is a standard technique in any site that handles rotating machinery, from power plants and steel mills to Shinkansen trains.

Seismic, EEG and ECG analysis: The Hilbert transform is widely used for non-stationary physiological and geophysical signals, including group-velocity analysis of seismic waves, instantaneous amplitude tracking of α and β waves in EEG, and envelope detection of QRS complexes in ECG. Combined with Empirical Mode Decomposition, the Hilbert-Huang transform is a powerful method for decomposing nonlinear non-stationary signals into intrinsic mode functions.

Image processing and optical metrology: The 2D extension (Riesz transform) is used in phase-shifting interferometry, fringe analysis and monogenic signal processing, where it can extract a phase distribution from a single fringe image. Applications range from semiconductor inspection and precision interferometry to feature extraction in medical imaging.

Common Misconceptions and Cautions

The most common misconception is to think that "the Hilbert transform is a filter that cuts something out in the frequency domain". In reality, its amplitude response is 1 at every frequency (all-pass) and only the phase changes (by -π/2). Doubling positive frequencies and zeroing negative ones in this tool builds the "analytic signal"; the Hilbert transform itself corresponds to a phase shift that flips the sign between positive and negative frequencies. The right mental picture is "compute the hidden imaginary part of the signal", not "modify the signal".

The next most common error is to assume that the instantaneous amplitude, phase and frequency always have a physical meaning. They are meaningful only when the signal is essentially a single narrowband component (when Bedrosian's theorem applies). Applying the Hilbert transform directly to wideband noise or a mixture of carriers makes the instantaneous frequency go negative or oscillate wildly and lose physical interpretation. Real applications require a band-pass filter or Empirical Mode Decomposition for band separation beforehand.

Finally, remember that the DFT implementation has edge artefacts. The DFT assumes the signal repeats periodically, so unless the first and last samples connect smoothly, the phase jumps strongly at both ends and tens of samples of instantaneous amplitude and frequency become unreliable. This tool computes statistics on the central 80% and discards the outer 10%. In practice, apply a window function (Hann etc.), use an FIR Hilbert transformer, or taper the signal ends.

How to Use

  1. Set carrier frequency (Fc) between 100–10000 Hz using slFcVal slider.
  2. Set modulating frequency (Fm) between 5–500 Hz; Fm must be significantly lower than Fc for proper AM.
  3. Adjust modulation depth (m) from 0 to 1; m=0.5 represents 50% amplitude modulation.
  4. Configure sample count (N) from 256 to 4096 points for DFT resolution; higher N improves spectral clarity.
  5. Click Compute to apply FFT-based Hilbert transform and extract analytic signal components.
  6. View instantaneous amplitude envelope overlaid on the modulated carrier in the time-domain plot.
  7. Inspect instantaneous frequency (median) and modulation depth statistics in the output panel.

Worked Example

Consider an AM signal with Fc=200 Hz, Fm=10 Hz, m=0.6, N=1024 samples at the fixed 1000 Hz sampling rate. The Hilbert transform generates the analytic signal z(t)=x(t)+iH[x(t)]. Instantaneous amplitude A(t)=|z(t)|≈1+0.6·cos(2π·10t), yielding time-average ⟨A⟩≈1.0 and RMS≈√(1+0.6²/2)≈1.086. Instantaneous frequency f_inst(t)=(1/2π)·d[arg(z(t))]/dt stabilizes near a 200 Hz median with small ripple from the modulation. Envelope detection visually confirms the 10 Hz modulating waveform extracted from the 200 Hz carrier.

Practical Notes

  1. Ensure Fm<0.2·Fc to avoid sideband overlap and ambiguous envelope; FM=100 Hz with Fc=500 Hz violates this rule.
  2. Use N≥1024 for accurate instantaneous frequency estimation; N=256 introduces aliasing artifacts in the analytic signal derivative.
  3. Modulation depth m>0.9 causes nonlinear distortion in envelope; industrial AM broadcast uses m≤0.95 to prevent over-modulation.
  4. RMS of instantaneous amplitude directly measures envelope fidelity; compare against theoretical RMS=√(1+m²/2) for validation.
  5. Instantaneous frequency median should match Fc within ±1%; deviations indicate insufficient FFT resolution or window leakage.