# Frequency Domain

## The Discrete Fourier Transform¶

The frequency-domain representation gives insight into the composition of time series and hence of musical signals. In the digital domain we are formemost interested in discrete signals and will thus introduce the Discrete Fourier Transform (DFT). This section does not aim at a full introduction of the DFT, but illustrates a few aspects which help to understand the basics of computer music and sound synthesis.

The DFT $X[n]$ of a discrete signal $x$ with the length $N$ and the sampling frequency $f_s$ is calculated as follows. For every *frequency bin* $n$ of the output, the correlation of the signal with a complex oscillation with the frequency $n \frac{N}{f_s}$ is calculated:

### DFT of a Sine Wave¶

The following example is based on a 2048 sample sine wave with a frequency of $f_0 = 1000\ \mathrm{Hz}$ at a sampling rate of $f_s = 16\ \mathrm{kHz}$:

For calculating the DFT of sinusoidal signals, it makes sense to express them in the complex notation through Euler's formula:

$$ \sin(2 \pi \frac{f_0}{fs} n) = \frac{1}{2j} \left( e^{-j 2 \pi \frac{f_0}{fs} n} -e^{-j2 \pi \frac{f_0}{fs} n} \right) \\ $$The DFT of the sine wave thus extends to:

$$ X[n] = \sum\limits_{i=1}^{N} \frac{1}{2j} \left( e^{-j 2 \pi \frac{f_0}{fs} n} -e^{-j2 \pi \frac{f_0}{fs} n} \right) e^{-j 2 \pi n \frac{N}{f_s} i} $$#### Complex Result¶

The full DFT results in a complex spectrum with a real part and an imaginary part.

#### Absolute Representation¶

In many cases, the absolute values of DFT spectra will be shown only for the positive frequencies. This representation is used in most examples in the following sections. The sine wave becomes a single peak at its frequency: