PROCESSING SOUNDS. CMPS1371 Introduction to Computing for Engineers. The Physics Of Sound. Why do we hear what we hear? Sound is made when something vibrates. The vibration disturbs the air around it. This makes changes in air pressure.
Why do we hear what we hear?
Sound is made when something vibrates.
The vibration disturbs the air around it.
This makes changes in air pressure.
These changes in air pressure move through the air as sound waves.
The louder a sound, the more energy it has. This means loud sounds have a large amplitude.
Think about what an amplifier does: it makes sounds louder. It is the amplitude that relates to how loud sound is.
All sound is made by things vibrating. The faster things vibrate, the higher the pitch of the sound produced.
The vibrations being more frequent mean the frequency of the wave increases.
Methods to store and reproduce sound is a continual process for high quality
Before we actually start making music, let's revise a few AC waveform basics. Consider the sine wave shown in the figure below:
Sound waves are created when a waveform is used to vibrate molecules in a material medium at audio frequencies (300 Hz <= f <= 3 kHz).
the MATLAB code to create a sine wave of amplitude A = 1, at audio frequency of 466.16 Hz (corresponds to A#) would be:
>> v = sin(2*pi*466.16*[0:0.00125:1.0]);
Now, we can either plot this sine wave; or we can hear it!!!
To plot, simply type:
Now, we can "play" this wav file called asharp.wav using any multimedia player.
wavfunction returns 3 variables:
Number of bits
>> [y, Fs, bits] = wavread('asharp.wav');
>> sound(y, Fs)
Now that we can make a single note, we can put notes together and make music!!!
Let's look at the following piece of music:
A AE E F# F# E E
D DC#C# B B A A
E E D D C# C# B B (repeat once)
(repeat first two lines once)
The American Standard Pitch for each of these notes is:
A: 440.00 Hz
B: 493.88 Hz
C#: 554.37 Hz
D: 587.33 Hz
E: 659.26 Hz
F#: 739.99 Hz
One dimensional function of changing air-pressure in time
If the function is periodic, we perceive it as sound with a certain frequency (else it’s noise).
The frequency defines the pitch.
The SHAPE of the curve defines the sound character
Listening to an orchestra, you can distinguish between different instruments, although the sound is a
SINGLE FUNCTION !
If the sound produced by an orchestra is the sum of different instruments, could it be possible that there are BASIC SOUNDS, that can be combined to produce every single sound ?
The answer (Charles Fourier, 1822):
Any function that periodically repeats itself can be expressed as the sum of sines/cosines of different frequencies, each multiplied by a different coefficient
…A function…can be expressed as the sum of sines/cosines…
What happens if we add sine and cosine ?
a * sin(ωt) + b * cos(ωt)
= A * sin(ωt + φ)
Adding sine and cosine of the same frequency yields just another sine function with different phase and amplitude, but same frequency.
Any function that periodically repeats itself…
To change the shape of the function, we must add sine-like functions with different frequencies.
As a formula:
f(x)= a0/2 + Σk=1..n akcos(kx) + bksin(kx)
f(x) = ½ - 1/π * Σn 1/n *sin (n*π*x)
Given an arbitrary but periodically one dimensional function (e.g. a sound), can you tell the FOURIER COEFFICIENTS to construct it ?
The answer (Charles Fourier):
MATLAB - function fft:
Input: A vector, representing the discrete function
Output: The Fourier Coefficients as vector of scaled imaginary numbers
We can analyze the frequency content of sound using the Fast Fourier Transform (fft)