# Synthesis

## Contents

# 7.3. Synthesis#

In the first section of this chapter, we saw how a signal \(\blue{x[n]}\) representing a sinusoid at an analysis frequency can be reconstructed from its DFT coefficients \(\darkblue{X[m]}\).
In the second section, we saw (abstractly) that this is true of **any** signal \(\blue{x[n]}\), not just sinusoids.
In this section, we’ll unpack this a bit and look more carefully at some examples to get a better intuition for how this works.

The key idea is that the IDFT can be thought of as an example of **additive synthesis**: the signal \(\blue{x[n]}\) is reconstructed as a combination of pure tones.

## 7.3.1. IDFT as synthesis#

Equation (7.1) tells us how to construct the \(n\)th sample of a signal \(x\) as an average of the following terms:

Remember that each DFT coefficient \(\darkblue{X[m]}\) is a complex number with an amplitude (we’ll call it \(A_m\)) and a phase (\(\phi_m\)):

This means that each term in IDFT summation can be equivalently expressed as

Equivalently, we can use Euler’s formula to express this as waves instead of an exponential:

This says that each term in the summation has a real part (the cosine term) and an imaginary part (the sine term), but they both share the same amplitude \(A_m\), frequency \(m/N\), and phase \(\phi_m\).

As we saw in our warmup example earlier in the chapter, if the DFT has conjugate symmetry (so that \(X[m] = \overline{X[N-m]}\)), then the imaginary term corresponding to \(X[m]\) will cancel with the imaginary term corresponding to \(X[N-m]\) when we sum over all frequencies. This results in an entirely real-valued summation, where each term is produced by a sinusoid in standard form:

Note that this *only* works if the spectrum is conjugate symmetric.
If we don’t have conjugate symmetry, then the reconstructed signal may have complex values.

## 7.3.2. Example: partial reconstruction#

The inverse DFT equation tells us how to reconstruct a signal from its spectrum, but we can also gain an intuition for how this works by looking at what happens when we stop the summation early, including only some \(N' < N\) frequencies.

To visualize this process, we’ll revisit the trumpet example from earlier. To keep the visualization simple, we’ll take only a small fragment of the recording for analysis.

```
# We'll use soundfile to load the signal
import soundfile as sf
# And IPython to play it back in the browser
from IPython.display import Audio, display
# A single note (D#5) played on a trumpet
# https://freesound.org/s/48224/
# License: CC BY-NC 3.0
x, fs = sf.read('48224__slothrop__trumpetf3.wav')
# Slice out 512 samples (approximately 11ms) of audio
x = x[int(0.3 * fs):int(0.3*fs)+512]
```

Plotting the time-domain signal, along with its magnitude spectrum results in Fig. 7.2.

We can see that the signal contains a repeating pattern, but also that it does not closely resemble a sinusoid. The DFT spectrum (Fig. 7.2, right) contains many peaks, indicating that the signal does indeed contain a rich combination of sinusoids. Fig. 7.3 below demonstrates how the signal would be approximated if only part of the DFT spectrum is used in the reconstruction.