# Miller Puckette’s “The Theory and Technique of Electronic Music”, Ch. 1 Exercises

## “The Theory and Technique of Electronic Music” – Miller Puckette, Chapter 1

Hey folks! I recently came across the phenomenal book, available for free online, “The Theory and Technique of Electronic Music” by Miller Puckette, renowned designer of Pure Data the open-source cousin Cycling ’74’s famous Max/MSP environment. It’s a fascinating subject and I highly recommend checking it out here! I wont lie, a lot of this book has the tendency to go straight over my head in a lot of places if I don’t read and reread sections of it, so I’m doing the exercises here, publicly, so that I can hopefully make sense of what Mr. Puckette is saying and to maybe elicit feedback and correct the places where I’m not understanding some of the mathematics and relationships being presented, since there’s no answer key given. I’ll attempt to work through the answers in as long a form as possible to break it down to the simplest level and explain/show all of my work along the way.

Though the book appears to be geared more toward using the concepts in the context of PD or Max, I’m more interested in more wholly understanding digital audio, so just for the heads up: somewhere down the line, I may skip a PD-centric question or two 🙂

## Ladies and Gentlemen, what you’ve all been waiting for: Tons of math!

1. A sinusoid has initial phase $\phi = 0$ and angular frequency $\omega = \frac{\pi}{10}$. What is its period in samples? What is the phase at sample number n=10

The first thing to identify in this question is that we’re talking about a sinusoid, which always has a period (in samples) of $\frac{2\pi}{\omega }$. If the angular frequency is $\frac{\pi}{10}$, then the period in samples, whose formula is given in the book as period $\tau$ is equal to $\tau = \frac{2\pi}{\omega}$, is filled in with the variables given as: $\tau=\frac{2\pi}{\frac{\pi}{10}}$. Solving this fraction the old fashioned way then becomes pretty simple:

$\tau=\frac{2\pi}{\frac{\pi}{10}} \rightarrow \tau=\frac{2\pi}{1} \cdot \frac{10}{\pi} \rightarrow \tau=\frac{20\pi}{1\pi} \rightarrow \tau=20\textrm{ samples}$

The second part of the question means understanding that a sinusoid is a repeating sine wave (measured in radians) and completing its cycle over the course of it’s period – which, in this case, has been determined to be twenty samples. Ten samples into its cycle is halfway through it, so the phase is $180^{\circ}$ from it’s initial phase. In practice, at least for the case of sinusoids, this puts that particular sample directly on the zero crossing between positive and negative amplitude ranges.

2. Two sinusoids have periods of 20 and 30 samples, respectively. What is the period of the sum of the two?

I’m possibly going out on a limb here but this is quite simple: The period of the sum of these two sinusoids is simply the least common multiple of the two periods, which in this case would be 60 samples.

As pointed out by a commenter, indeed, the period of the sum of two sinusoids is simply the period of the larger wave. The answer is 30 samples.

3. If 0 dB corresponds to an amplitude of 1, how many dB corresponds to amplitudes of 1.5, 2, 3, and 5?

In the book, decibels are set up so that $d=20 log_{10}(\frac{a}{a_{0}})$ where $d$ is decibels, $a$ is the amplitude while $a_{o}$ is a reference amplitude to which the first is being measured. The book notes that an “increase in amplitude by a factor of two corresponds to an increase of about 6.02 decibels.” We can already surmise that if our reference amplitude ($a_{o}$) is 1, which corresponds to zero dB, then we should see the math resulting in 6.02dB when the amplitude is 2.

Simple calculation of the formula plugging in the data results in the following formulae and results:

$d = 20 log_{10}(\frac{1}{1}) = 0dB$ $d = 20 log_{10}(\frac{1.5}{1}) = 3.52 dB$ $d = 20 log_{10}(\frac{2}{1}) = 6.02 dB$ $d = 20 log_{10}(\frac{3}{1}) = 9.54dB$ $d = 20 log_{10}(\frac{5}{1}) =13.98dB$

which falls in line with the given supposition.

4. Two uncorrelated signals of RMS amplitude 3 and 4 are added; what’s the RMS amplitude of the sum?

Puckette, on the matter of adding together signals, states that the power of the sum of the Root Mean Squares of two signals is the sum of the powers. Does that sound familiar to anything you’ve ever learned before…? The answer can be defined as $a^{2}+b^{2}=c^{2}$…More specifically, on the issue of correlation between signals, they can be thought of as being related by the Pythagorean relationship: “uncorrelated signals can be thought of as vectors at right angles to each other; positively correlated ones as having an acute angle between them, and negatively correlated as having an obtuse angle between them.” So how do we solve for the amplitude of the sum?

$3^{2}+4^{2}={A_{RMS}}^{2}$, or….$A_{RMS}=5$

As an aside, Puckette only briefly touches on how correlation can change relationship between RMS of the original signals and the sum. We know from high school math that the Pythagorean Theorem only works on right triangles, my curiosity wants to ask what if they were positively or negatively correlated signals? How does this change the math involved? Hopefully Puckette (or anyone reading this!) answers this down the road. He invokes a specific formula on page 11, but it goes way over my head, so I just listen, smile, and nod along to it.

5. How many uncorrelated signals, all of equal amplitude, would you have to add to get a signal that is 9 dB greater in amplitude?

This had me stumped for a while until I saw someone else’s method for solving this posted online, but I thought to simplify it and explain it in more detail. Even he seems unsure but I trust the answer after following my own intuition and what I already know about audio from practice.

Earlier we used the equation set up to calculate decibels as $d=20 log_{10}(\frac{a}{a_{0}})$, using amplitude and now we can reverse the process. We know we want to reach a decibel level of 9 against an arbitrary reference level so we need to find $9=20 log_{10}(a)$. In this case, the math breaks down like this:

$9=20 log_{10}(a)$ $\frac{9}{20}= log_{10}(a)$ $10^{\frac{9}{20}}=a$

So we now know than an amplitude of $10^{\frac{9}{20}}$ will give us an increase of 9dB.

We also know that uncorrelated signals follow a Pythagorean relationship. So for 2 uncorrelated signals of equal amplitude the amplification multiplier is sqrt(2).  Though Puckette never says as much, it’s not unreasonable to assume that for 3 uncorrelated signals of equal amplitude, the amplification multiplier of $10^{\frac{9}{20}}$, is sqrt(3). Following that train of thought, all we need to do is find out when $\sqrt{x} = 10^{\frac{9}{20}}$. Let’s knock it out:

$\sqrt{x}=10^{\frac{9}{20}}$ $x=\left ( 10^{\frac{9}{20}} \right )^{2}$ $x=10^{\frac{9}{10}}$ $x=7.94\textup{ signals}$

So the correct answer is (hopefully – remember, there’s no damn answer key here) $\approx 8\textup{ signals}$.
Does that look right…?

6. What is the angular frequency of middle C at 44100 samples per second?

The book gave away the real-time frequency of Middle-C at 261.626 Hz, but let’s pretend I didn’t read that and use the MIDI to Frequency conversion formula that Puckette provides, which is $f = 440 \cdot 2^{\frac{m-69}{12}}$, where $m$ is the MIDI number we want to convert, (which in this case, is 60). Filling in the variables, frequency is equal to

$f=440\cdot2^{\frac{60-69}{12}}\rightarrow f=440\cdot2^{\frac{-9}{12}}\rightarrow f=440\cdot0.595\rightarrow f=261.626\textup{Hz}$

Cool. So now that we’ve got the frequency of the note we need to convert this to the angular frequency of the note. A sinusoidal signal with an angular frequency of $\omega$ and sample rate of $R$ has a real-time frequency equivalent to:

$f=\frac{\omega R}{2\pi}\rightarrow 262.626\textup{Hz}=\frac{\omega \cdot 44100}{2\pi}$ $262.626 \cdot 2\pi = \frac{\omega \cdot 44100}{2\pi}\cdot 2\pi$ $1650.13 = 44100\cdot\omega$ $\frac{1650.13}{44100}=\omega$ $\omega = 0.037\textup{ radians per sample}$.

7. Two sinusoids play at middle C (MIDI 60) and the neighboring C sharp (MIDI 61). What is the difference, in Hertz, between their frequencies?

Let’s hit up that same equation I used in the last example to convert midi to frequency for both of these MIDI notes:

$f = 440 \cdot 2^{\frac{60-69}{12}} \rightarrow f = 261.626\textup{ Hz}$ $f = 440 \cdot 2^{\frac{61-69}{12}} \rightarrow f = 277.183\textup{ Hz}$

Then just subtract the two for the answer:

$277.183 - 261.626 = 15.557\textup{ Hz}$

It don’t get quicker than that!

8. How many cents is the interval between the seventh and the eighth harmonic of a periodic signal?

So, this took a lot more time than I thought it would. The problem that we’re faced here is that the original signal is of a completely arbitrary frequency. Surely, every signal with a different frequency will have different overtones at different frequencies…But if we look a bit closer to the question, Puckette is asking about cents. It always takes 100 hundred cents to create a half-step between any two notes. It doesn’t matter what two notes you’re measuring the interval between, a half step is always 100 cents, even if the frequencies are dozens of hertz apart, like at the top register of the piano or high-pitched piccolo flute. So how many cents are between the seventh and eighth harmonic? Let’s remember that the overtone series (the harmonic series) is represented by a series of extremely simple ratios: 2:1, 3:2, 4:3, 5:4, 6:5, 7:6, 8:7 (!), and so on.

At this point I became stuck again, honestly. I knew I needed to somehow coax the number of cents between 8:7 but I couldn’t quite seem to figure it out. It was time to google and after much (re?)learning about the Twelfth Root of Two, a formula useful for finding the difference between half-steps. It’s most often used to calculate the frequencies of notes relative to one another (ie: if you’re trying to find the frequency of a note five half-steps above, say, A-440 – which is a D, you would use the twelfth root of two as so: $f=440\cdot2^{\frac{5}{12}}$ which equates to $576.33\textup{ cents}$. Cool, but we’re not looking for frequency…we are however looking for the amount of half-steps it takes to create the fraction $\frac{8}{7}$.

So….

$\frac{8}{7}=2^{\frac{x}{12}}$ $log_{2}{\frac{8}{7}}=\frac{x}{12}$ $12log_{2}{\frac{8}{7}}=x$ $x = 2.31\textup{ half-steps}$ $231\textup{ cents}$

Literally the only reason I can safely say that this is correct is because the book gives the amount of cents above a given fundamental for various parts of the overtone sequence and subtracting the seventh from the eighth gave the same number. I feel icky right now after this one.

9. If an audio signal x[n],n = 0,…,N −1 has peak amplitude 1, what is the minimum possible RMS amplitude? What is the maximum possible?

This is a completely theoretical question. It’s sort of given away in the reading but let’s talk for a second: The Root Mean Square amplitude of a signal may equal the peak amplitude of a given window of samples, but never exceed it, and it may be as little as $\frac{1}{\sqrt{N}}$ but never be less than that. So that’s our answer. If the peak amplitude is 1 in the given sample range, then the maximum possible RMS amplitude is 1. Likewise, the minimum is constant: $\frac{1}{\sqrt{N}}$ where $N$ is the size of the given range of samples in the signal.

…I can’t believe this was only chapter one. It might have to be a minute before I can work up the nerve to tackle whatever Chapter 2 has in store. (But seriously, I learned a ton here about working with frequencies so I really can’t wait to get into Chapter 2.)

## One Reply to “Miller Puckette’s “The Theory and Technique of Electronic Music”, Ch. 1 Exercises”

1. Vishal Menon says:

Answer 2: I believe is 30 samples, not 60.

If you refer to 1.7 Periodic Signals; on page 12 and the diagram on page 13 – it shows the summed wave having the same period as the wave with the largest period.

Thanks for making this post!
🙂