Digital sound processing Digital sound processing
Convolution Convolution Digital Filters Digital Filters
FFT FFT
Sampling Sampling
Sampling an electrical signal means capturing its value Sampling an electrical signal means capturing its value repeatedly at a constant, very fast rate.
repeatedly at a constant, very fast rate.
Sampling frequency (f Sampling frequency (f
ss) is defined as the number of samples ) is defined as the number of samples captured per second
captured per second
The sampled value is known with finite precision, given by the The sampled value is known with finite precision, given by the
“number of bits” of the analog-to-digital converter, which is
“number of bits” of the analog-to-digital converter, which is limited (typically ranging between 16 and 24 bits)
limited (typically ranging between 16 and 24 bits)
Of consequence, in a time-amplitude chart, the Of consequence, in a time-amplitude chart, the analog waveform is approximated by a sequence analog waveform is approximated by a sequence
of points, which lye in the knots of a lattice, as of points, which lye in the knots of a lattice, as
both time and amplitude are integer multiplies of both time and amplitude are integer multiplies of
small “sampling units” of time and amplitude
small “sampling units” of time and amplitude
Time/frequency discretization Time/frequency discretization
VV
Analog signal (true) Analog signal (true) Digital signal (sampled) Digital signal (sampled)
Fidelity of sampled signals Fidelity of sampled signals
Can a sampled digital signal represent faithfully the original analog one?
YES, but only if the following “Shannon theorem” is true:
“Sampling frequency must be at least twice of the largest frequency in the signal being sampled”
A frequency equal to half the sampling frequency is named the “Nyquist frequency”– for avoiding the presence of signals at frequencies higher than the Nyquist’s one, an
analog low-pass filter is inserted before the sampler.
It is called an “anti Aliasing” filter.
Common cases Common cases
CD audio – fCD audio – fss = 44.1 kHz – discretization = 16 bit = 44.1 kHz – discretization = 16 bit
Nyquist frequency is 22.05 kHz, the anti-aliasing starts at 20 kHz, so that at Nyquist frequency is 22.05 kHz, the anti-aliasing starts at 20 kHz, so that at 22.05 kHz the signal is already attenuated by at least 80 dB. Hence the filter 22.05 kHz the signal is already attenuated by at least 80 dB. Hence the filter is very steep, causing a lot of artifacts in time domain (ringing, etc.)
is very steep, causing a lot of artifacts in time domain (ringing, etc.)
DAT recorder – fs = 48 kHz – discretization = 16 bitDAT recorder – fs = 48 kHz – discretization = 16 bit
Nyquist frequency is 24 kHz, the anti-aliasing starts at 20 kHz, so that at 24 Nyquist frequency is 24 kHz, the anti-aliasing starts at 20 kHz, so that at 24 kHz the signal is already attenuated by at least 80 dB. Now the filter is less kHz the signal is already attenuated by at least 80 dB. Now the filter is less steep, and the time-domain artifacts are almost gone.
steep, and the time-domain artifacts are almost gone.
DVD Audio – fDVD Audio – fss = 96 kHz – discretization = 24 bit = 96 kHz – discretization = 24 bit
Nyquist frequency is 48 kHz, but the anti-aliasing starts around 24 kHz, with Nyquist frequency is 48 kHz, but the anti-aliasing starts around 24 kHz, with a very gentle slope, so that at 48 kHz the signal is attenuated by more than a very gentle slope, so that at 48 kHz the signal is attenuated by more than
120 dB.
120 dB.
Such a gentle filter is very “short” in time domain, hence there are virtually no Such a gentle filter is very “short” in time domain, hence there are virtually no time-domain artifacts.
time-domain artifacts.
Impulse Response Impulse Response
System System under test under test Time of flight
Time of flight Direct sound Direct sound
Early reflections Early reflections Reverberant tail Reverberant tail
A simple linear system A simple linear system
CD player
CD player AmplifierAmplifier LoudspeakerLoudspeaker MicrophoneMicrophone Real-world system (one input, one output) Real-world system (one input, one output)
Block diagram Block diagram
x(x()) h(h()) y(y())
Input signal
Input signal System’s Impulse System’s Impulse RResponse esponse (Transfer function)
(Transfer function) Output signalOutput signal
“SYSTEM”“SYSTEM”
Analyzer Analyzer
FIR Filtering (Finite Impulse Response) FIR Filtering (Finite Impulse Response)
) i
( x )
(
x h ( ) h ( i ) y ( ) y ( i )
The effect of the linear system h on the signal x passing through it is The effect of the linear system h on the signal x passing through it is described by the mathematical operation called “convolution”, defined by:
described by the mathematical operation called “convolution”, defined by:
i j h j
x )
i ( y
1 N
0 j
This “sum of products” is also called FIR filtering, and models This “sum of products” is also called FIR filtering, and models
accurately any kind of linear systems.
accurately any kind of linear systems.
This is usually written, in compact notation, as:
This is usually written, in compact notation, as:
i h j
x )
i (
y
IIR Filtering (Infinite Impulse Response) IIR Filtering (Infinite Impulse Response)
) i
( x )
(
x y ( ) y ( i )
Alternatively, the filtering caused by a linear system can also be described Alternatively, the filtering caused by a linear system can also be described
by the following recursive formula:
by the following recursive formula:
i j a j y i j b j
x )
i (
y N 1
1 j 1
N 0 j
• In practice, the filter is computed not only from the input samples x, but also as a In practice, the filter is computed not only from the input samples x, but also as a function of the output samples y, obtained at the previous time steps.
function of the output samples y, obtained at the previous time steps.
• In many cases, this method allows for representinging faithfully the behaviour of the In many cases, this method allows for representinging faithfully the behaviour of the system with a much smaller number of coefficients than when employing FIR
system with a much smaller number of coefficients than when employing FIR filtering.
filtering.
) j ( b
)
j
(
a
The FFT Algorithm The FFT Algorithm
The Fast Fourier Transform (FFT) is often employed in Acoustics, with The Fast Fourier Transform (FFT) is often employed in Acoustics, with two goals:
two goals:
►Performing spectral analysis with constant bandwidth
►Fast FIR filtering
FFT transforms a segment of time-domain data in the corresponding FFT transforms a segment of time-domain data in the corresponding spectrum, with constant frequency resolution, starting at 0 Hz (DC) up to spectrum, with constant frequency resolution, starting at 0 Hz (DC) up to Nyquist frequency (which is half of the sampling frequency)
Nyquist frequency (which is half of the sampling frequency)
The longer the time segment, the narrower will be the frequency The longer the time segment, the narrower will be the frequency resolution:
resolution:
[N sampled points in time] =
[N sampled points in time] =
> >
[N/2+1 frequency bands] [N/2+1 frequency bands](the +1 represents the band at frequency 0 Hz, that is the DC component (the +1 represents the band at frequency 0 Hz, that is the DC component – but in acoustics, this is always with zero energy…)
– but in acoustics, this is always with zero energy…)