This HTML version of is provided for convenience, but it is not the best format for the book. In particular, some of the symbols are not rendered correctly.
You might prefer to read the PDF version.
Chapter 0 Preface
Signal processing is one of my favorite topics. It is useful in many areas of science and engineering, and if you understand the fundamental ideas, it provides insight into many things we see in the world, and especially the things we hear.
But unless you studied electrical or mechanical engineering, you probably haven’t had a chance to learn about signal processing. The problem is that most books (and the classes that use them) present the material bottom-up, starting with mathematical abstractions like phasors. And they tend to be theoretical, with few applications and little apparent relevance.
The premise of this book is that if you know how to program, you can use that skill to learn other things, and have fun doing it.
With a programming-based approach, I can present the most important ideas right away. By the end of the first chapter, you can analyze sound recordings and other signals, and generate new sounds. Each chapter introduces a new technique and an application you can apply to real signals. At each step you learn how to use a technique first, and then how it works.
This approach is more practical and, I hope you’ll agree, more fun.
0.1 Who is this book for?
The examples and supporting code for this book are in Python. You should know core Python and you should be familiar with object-oriented features, at least using objects if not defining your own.
If you are not already familiar with Python, you might want to start with my other book, Think Python, which is an introduction to Python for people who have never programmed, or Mark Lutz’s Learning Python, which might be better for people with programming experience.
I use NumPy and SciPy extensively. If you are familiar with them already, that’s great, but I will also explain the functions and data structures I use.
I assume that the reader knows basic mathematics, including complex numbers. You don’t need much calculus; if you understand the concepts of integration and differentiation, that will do. I use some linear algebra, but I will explain it as we go along.
0.2 Using the code
The code and sound samples used in this book are available from https://github.com/AllenDowney/ThinkDSP. Git is a version control system that allows you to keep track of the files that make up a project. A collection of files under Git’s control is called a “repository”. GitHub is a hosting service that provides storage for Git repositories and a convenient web interface.
The GitHub homepage for my repository provides several ways to work with the code:
I developed this book using Anaconda from Continuum Analytics, which is a free Python distribution that includes all the packages you’ll need to run the code (and lots more). I found Anaconda easy to install. By default it does a user-level installation, not system-level, so you don’t need administrative privileges. And it supports both Python 2 and Python 3. You can download Anaconda from http://continuum.io/downloads.
If you don’t want to use Anaconda, you will need the following packages:
Although these are commonly used packages, they are not included with all Python installations, and they can be hard to install in some environments. If you have trouble installing them, I recommend using Anaconda or one of the other Python distributions that include these packages.
Most exercises use Python scripts, but some also use Jupyter notebooks. If you have not used Jupyter before, you can read about it at http://jupyter.org.
There are three ways you can work with the Jupyter notebooks:
Good luck, and have fun!
If you include at least part of the sentence the error appears in, that makes it easy for me to search. Page and section numbers are fine, too, but not as easy to work with. Thanks!
Other people who found typos and errors include Silas Gyger and Abe Raher.
Special thanks to the technical reviewers, Eric Peters, Bruce Levens, and John Vincent, for many helpful suggestions, clarifications, and corrections.
Also thanks to Freesound, which is the source of many of the sound samples I use in this book, and to the Freesound users who contributed those samples. I include some of their wave files in the GitHub repository for this book, using the original file names, so it should be easy to find their sources.
Unfortunately, most Freesound users don’t make their real names available, so I can only thank them by their user names. Samples used in this book were contributed by Freesound users: iluppai, wcfl10, thirsk, docquesting, kleeb, landup, zippi1, themusicalnomad, bcjordan, rockwehrmann, marcgascon7, jcveliz. Thank you all!
Are you using one of our books in a class?We'd like to know about it. Please consider filling out this short survey.