The Fast Fourier Transform - FFT Sound Design and Interactive Music - - PowerPoint PPT Presentation
The Fast Fourier Transform - FFT Sound Design and Interactive Music - - PowerPoint PPT Presentation
The Fast Fourier Transform - FFT Sound Design and Interactive Music - FFT Learning Objectives Understand the relationship between the Time and Frequency Domain. The Fast Fourier Transform - FFT is a method for switching between these two
Sound Design and Interactive Music - FFT
Learning Objectives
- Understand the relationship between the Time and Frequency Domain.
- The Fast Fourier Transform - FFT is a method for switching between these two
domains.
- Understanding of the FFT to use it in Pure Data.
Structure
- Basic Concepts
- Fourier Transform
- Fast Fourier Transform - overview
- Practical information of using FFT in Pure Data
Sound Design and Interactive Music - FFT
Basics
- Every signal can be represented by a sum sine waves which have a frequency, amplitude
and phase.
- Simple examples:
Square Wave Sawtooth Wave
Produced by adding all harmonics of a sine wave at decreasing amplitude 1/h - where h = harmonic
- 4 harmonics
- 12 harmonics
Produced by adding all odd harmonics of a sine wave at decreasing amplitude 1/h - where h = harmonic
- 4 harmonics
- 12 harmonics
Summing sine waves to make signals - exactly the same as when preforming additive synthesis.
Sound Design and Interactive Music - FFT
Fourier Transform
- The Fourier Transform - Transforms a Signal from the Time Domain
representation into its Frequency Domain representation. This is also know as Analysis frequency components of the signal are worked out.
- Inverse Fourier Transform - transforms a Signal from the Frequency
Domain representation back into the Time Domain representation. Also know as re-synthesis as the signal is re-constructed or re-synthesised. Square wave Sawtooth wave
taken from http://www.informit.com/articles/article.aspx?p=1374896&seqNum=7 taken from http://en.wikipedia.org/wiki/File:Sawtooth-td_and_fd.png
Sound Design and Interactive Music - FFT
Fourier Transform cont.
- When representing a signal in both the Time and Frequency Domains there is an
important point to conceder. A signal that is limited in one domain
cannot be limited in the other.
- A signal that is limited in Time - e.g. delta function (impulse) - cannot be
limited in the Frequency. That is to say an impulse (limited in time) contains an infinite number (or all) of frequencies.
- A signal limited in Frequency - e.g. a sine wave - cannot be limited in
- Time. That is to say a sine wave of a single frequency must continue on for an infinite
amount of time.
This is important because in the real world nothing is infinite. And this means that possible problems will arise when practically applying the Fourier Transform in the real world. 1) problems when sampling - a band limited signal is required. 2) Impossible to have a signal continue/play forever - analysis will also take forever.
Sound Design and Interactive Music - FFT
Impulse Example
- An Ideal impulse has infinite amplitude a time t = 0 and 0 amplitude at all other times.
- Frequency plot is completely Flat across all frequencies.
- Plotting an Ideal impulse is impossible.
- Shown here is the time and frequency plot of a impulse of sample length 2
Sound Design and Interactive Music - FFT
Sine Wave Example
- Time Domain Plot of a 200Hz Sine Wave (top) - note signal is present all times -
snapshot of 1 second is shown.
- Frequency Domain Plot (bottom) - note only frequency is present at 200Hz.
This was made with a matlab script that can be provided.
Sound Design and Interactive Music - FFT
In the Real World
- Because the real signals are limited in both domains the Fourier analysis cannot be
perfect.
- Example is here with the sine wave frequency plot - ideally this should be a single line
but due to errors introduced because the signal is not of infinite time frequencies around 200Hz are plotted with small amplitudes.
Sound Design and Interactive Music - FFT
Sampling/Nyquist Theorem
- Sampling Theorem is what enables an analogue signal to be reconstructed from its
digital representation.
- It allows for conversion of an analogue signal to a digital signal and back again.
- Switching from a continuous signal to a discrete signal.
- Sampling takes the value of the analogue signal every T seconds - called the sampling interval
- The number of samples per second is called the sampling rate - (fs)
- This gives the sampling rate equation as:
fs = 1 T
- For perfect reconstruction the signal is required to be band-limited - that is the
signal has a finite set of frequencies it can contain.
- The range of these frequencies contained within the signal - the signal’s bandwidth -
needs to be equal to or smaller than: fs / 2 - Also known as the Nyquist Frequency
Sound Design and Interactive Music - FFT
Fast Fourier Transform - FFT
- Computationally efficient way of carrying out the Fourier Transform in the
Digital Domain (aka Discrete Fourier Transform - DFT)
- Understanding of the maths that specifies what the FFT is doing and how it is
doing it is not needed in order to use the FFT and preform Fourier analysis and re-synthesis.
- FFT objects in Pure Data:
- These are [fft~] to preform analysis and [ifft~] to preform re-synthesis these
produce real and imaginary components of the frequency spectrum.
- [rfft~] and [rifft~] do the same thing but only use real values of the frequency
spectrum.
I’ll come back to the real and imaginary parts - these are from the maths behind the fourier transform - as sine waves can be represented as a complex number consisting of amplitude and phase or real and imaginary
- parts. Basically a number that carries 2 bits of information.
Sound Design and Interactive Music - FFT
FFT - in Pure Data
- The FFT divides the frequency spectrum up into parts of equal size.
- The amplitude and phase for each of these parts is then
determined
- The parts of the frequency spectrum are called bins
- The size of each frequency bin is determined by the block size
- Within Pure Data all tasks a processed in blocks. Blocks are groups of
samples
- Default block size in Pure Data is 64 - (can be changed in a subpatch)
- Can use [print~] to see snapshot of amplitudes within one DSP block.
- With default block size a spectrum is divided by 64. Example:
44100 / 64 = 689Hz
- Each bin therefore has a size of 689Hz
- The larger the block size the better the frequency resolution -
but this also makes the process more computationally demanding.
- Using Blocks lightens the processing load
- each block contains 64 values.
- Show Pd demo of this
Sound Design and Interactive Music - FFT
FFT - Analysing Signals
- Each bin corresponds to a certain frequency within the spectrum. With block
size of 64 and bin size of 689Hz analysing a signal containing only frequency of 689Hz (or a multiple of it) is fine and can be represented by a amplitude value in a single bin.
- Signals that are not of frequency 689Hz are divided among several multiple
bins.
- Each time the analysis is carried out the phase of the corresponding
frequency values will change. - THIS IS A PROBLEM!
- To solve this problem use overlapping windows.
Show Pd demo of the bins with all the crazy values.
Sound Design and Interactive Music - FFT
FFT - Hanning Window
- The common window used is called a Hanning window
- Made in Pure Data in the following way:
- This stops the amplitudes being so spread out.
- Windows need to overlap. Easily done by using [block~ 64 4] - but this
means the FFT analysis needs to be in a subpatch
To the right of the slide is demonstration of how to make a Hanning window in Pd Stops the spread of amplitudes - smearing in the frequency domain.
Sound Design and Interactive Music - FFT
FFT - Re-synthesis
- Re-synthesis of the signal is done by passing the outputted values from the
[fft~] or [rfft~] into the corresponding inverse abstraction ( [ifft~] or [rifft~] )
- By altering the values obtained from the analysis before re-synthesis will alter
how the original signal sounds.
- Things that you can do with FFT include:
- Filter effects
- Convolution
- Compression
- Spectral Delay
- As well as using the analysis to create control information and create things
like:
- Tuners
- Octave Doublers
- Pitch Followers
Fiddle~ - FFT implementation
Sound Design and Interactive Music - FFT
Further sources of Information
- http://www.pd-tutorial.com/english/ch03s08.html
- http://footils.org/2007/02/20/beginners-guide-fft-objects-pd/
- http://academicearth.org/courses/the-fourier-transform-and-its-applications
- http://www.dsprelated.com/dspbooks/mdft/