Wednesday, January 7, 2015

Think DSP Chapter 2: Harmonics

A few days ago I posted the first chapter from Think DSP, a new book taking a computational approach to Digital Signal Processing.  Over the next few weeks I'll post additional chapters and related blog articles.

Chapter 1 elicited some discussion on the discussion group Comp.DSP, where the focus of the conversation is the correct plural of "spectrum".  The most commonly used plural is "spectra", based on the sort-of-rule that words from Latin should use Latin plurals.  But this rule doesn't hold up very well to scrutiny, as in this video explaining why the plural of octopus would be octopodes.

So I decided to explore a radical version of an alternative rule, which is to pluralize English words using standard English endings, regardless of their etymological roots.  In Think DSP I use "spectrums";  I suspect that my former Latin teachers do not approve.

Moving on to less important matters, Chapter 2 is about the harmonic structure of certain periodic signals, and about aliasing.

Harmonics

Here's the spectrum of a triangle signal at 200 Hz.
The biggest peak is at 200 Hz, right where we expect it, but there are additional peaks at all the odd multiples of 200 Hz.  And the amplitude of those peaks is proportional to the inverse of frequency squared.

A square wave also contains odd harmonics, but they drop off more slowly, inversely proportional to frequency (not frequency squared).  A sawtooth wave contains both even and odd harmonics, and they are inversely proportional to frequency.

So that raises a question I posed in one of the exercises:  Is there a simple waveform that has even and odd harmonics that drop off like  1/ 2?

Aliasing

The figure below shows a cosine signal at 4500 Hz sampled at 10,000 frames a second.
The figure above shows a cosine signal at 5500 Hz sampled at 10,000 frames a second.

If you compare the two figures, you'll notice the problem: at this framerate, the two signals are indistinguishable.  This result is an example of aliasing, where a signal at one frequency masquerades as another frequency.

Chapter 2 explains more about how all this works.  You can see the code and examples in

And if you want to read the rest of the book, the current draft is here:


Think DSP is a Free Book. It is available under the Creative Commons Attribution-NonCommercial 3.0 Unported License, which means that you are free to copy, distribute, and modify it, as long as you attribute the work and don't use it for commercial purposes.

In particular, I welcome comments and suggestions from readers.  You can add a comment to this blog, or send me email.  If I make a change based on your suggestion, I will add you to the book's contributor list (unless you ask me not to).

Finally, be sure to tell me what you think the plural of "spectrum" should be.  Maybe "spectropodes"?

  

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.