The **Fourier transform** named after Joseph Fourier, is a mathematical transformation employed to transform signals between time (or spatial) domain and frequency domain, which has many applications in physics and engineering. Examples include speech recognition and music classification.

After transformation of an audio signal (time domain) into the frequency domain, we can observe the active frequencies. For example, if you ever used an Audio program such as Audacity you may have seen the time spectrum (top picture). In the time spectrum we can see the volume on the y-axis but not the current active frequencies. After applying a Fourier transform to the original signal, we get the Fourier representation of that signal. (signal below). The signal represented shows a peak at 440Hz, it originates from a tuning fork.

The python code below records a sound signal from the microphone, applies a Fourier transform to it and displays it visually.

import pylab import numpy as np import pyaudio chunk = 1000 p = pyaudio.PyAudio() stream = p.open(format=pyaudio.paUInt8, channels=1, rate=chunk, input=True, frames_per_buffer=chunk) print("* recording ") data = stream.read(chunk) print("* recording stop") print(str(type(data))) data_array = np.fft.fft(pylab.array(np.fromstring(data, dtype='uint8'))) pylab.plot(data_array/2) pylab.show() stream.stop_stream() stream.close() p.terminate()