ThinkDSP
This notebook contains code examples from Chapter 3: Non-periodic signals
Copyright 2015 Allen Downey
Chirp
Make a linear chirp from A3 to A5.
Here's what the waveform looks like near the beginning.
And near the end.
Here's an exponential chirp with the same frequency range and duration.
Leakage
Spectral leakage is when some of the energy at one frequency appears at another frequency (usually nearby).
Let's look at the effect of leakage on a sine signal (which only contains one frequency component).
If the duration is an integer multiple of the period, the beginning and end of the segment line up, and we get minimal leakage.
If the duration is not a multiple of a period, the leakage is pretty bad.
Windowing helps (but notice that it reduces the total energy).
Spectrogram
If you blindly compute the DFT of a non-periodic segment, you get "motion blur".
A spectrogram is a visualization of a short-time DFT that lets you see how the spectrum varies over time.
If you increase the segment length, you get better frequency resolution, worse time resolution.
If you decrease the segment length, you get better time resolution, worse frequency resolution.
Spectrum of a chirp
The following interaction lets you customize the Eye of Sauron as you vary the start and end frequency of the chirp.