DSP LAB EXPERIMENT - 4
1. FFT: Implement the radix-2 FFT algorithm to compute the N-point DFT 𝑋[𝑘]
of a sequence 𝑥[𝑛] of length 𝑁. Assume 𝑁 = 2 𝑚. Make ‘𝑁’ a variable. Modify to
compute the 𝑁 -point IDFT 𝑥[𝑛] of 𝑋[𝑘].
RESULT :
DFT
IDFT
DISCUSSION
The Discrete Fourier Transform (DFT) and the Inverse Discrete Fourier
Transform (IDFT) are mathematical transformations used in signal processing
to analyze and synthesize signals in the frequency domain. Here's a brief
overview of each:
1. Discrete Fourier Transform (DFT):
● The DFT is a transformation that converts a sequence of complex
numbers (time-domain signal) into another sequence of complex
numbers (frequency-domain representation).
● It is defined by the formula:
Where:
➢ X[k] is the complex amplitude at frequency index \(k\).
➢ x[n] is the input sequence in the time domain.
➢ N is the number of samples in the sequence.
2. Inverse Discrete Fourier Transform (IDFT):
● The IDFT is the inverse operation of the DFT. It transforms a sequence
of complex numbers in the frequency domain back to the time domain.
● It is defined by the formula:
Where:
➢ x[n] is the reconstructed sequence in the time domain.
➢ X[k] is the complex amplitude at frequency index \(k\) in the frequency
domain.
➢ N is the number of samples in the sequence.
3. Radix-2 FFT Algorithm:
● The radix-2 FFT algorithm is a fast algorithm for computing the DFT
efficiently when the size of the sequence is a power of 2.
● It divides the DFT computation into smaller DFTs recursively, exploiting
the periodicity and symmetry properties of the complex exponentials.
In the provided MATLAB code, the `radix_dft` function implements a radix-2
DFT algorithm, and the `radix_idft` function implements a radix-2 IDFT
algorithm. These functions are applied to an input sequence, and the results
are visualized by plotting the original signal, its Fourier Transform, and the
reconstructed signal after performing the IDFT.
2. Test the FFT program in (1) by computing DFT for
a. A rectangular signal
b. sinusoidal signal
c. Unit impulse.
Try to reconstruct the signals back from the spectrum using your IDFT
program. Observe the effect of zero padding using different number of
samples, while plotting the spectrum.
RESULT:
a) Rectangular Signal
b) Sinusoidal Signal
c) Unit Impulse
DISCUSSION:
1. For Rectangular Pulse :
● When applying the FFT to a rectangular signal, we observe the
expected sinc function in the frequency domain.
● Zero-padding increases the frequency resolution in the spectrum,
resulting in narrower sinc lobes.
● Reconstructing the signal using the inverse FFT (IDFT) from the
spectrum with and without zero-padding produces similar results
for the original signal.
2. For Sinusoidal :
● For a sinusoidal signal, the FFT produces a sharp peak at the
frequency of the sinusoid.
● Zero-padding increases the frequency resolution, providing a
more accurate estimation of the sinusoidal frequency.
● Reconstructing the sinusoidal signal from the spectrum using
IDFT accurately reproduces the original signal, and zero-padding
can improve the reconstruction quality.
3. Unit Impulse:
● The FFT of a unit impulse results in a constant spectrum across all
frequencies.
● Zero-padding does not significantly affect the spectrum in this case
since the impulse is already localized in the time domain.
● Reconstructing the unit impulse from the spectrum using IDFT yields
the original impulse signal.
4. Effect of Zero Padding:
● Zero-padding enhances the frequency resolution in the spectrum,
especially for signals with distinct frequency components.
● The choice of zero-padding size influences the trade-off between
frequency accuracy and computational efficiency.
● Larger zero-padding sizes provide finer frequency details but require
more computational resources.
3. Fast linear convolution using FFT
a. Use audioread, read the sample audio waveform ‘acoustic.wav’ and the
impulse response of a cathedral impulse ‘athederal.wav (the impulse
response models the reverberation that you typically observe in a cathedral).
Perform convolution (Use the code you have written in Experiment 1!)
between the audio signal and the impulse response. Find the time required to
perform the convolution.
RESULT:
DISCUSSION:
● The convolution of the audio signal with the cathedral impulse response
results in a new waveform, effectively combining the original audio with
simulated reverberation characteristic of a cathedral environment.
● This introduces a reverberation effect, simulating sound reflections and
delays inherent to cathedral spaces. Peaks and troughs in the
waveform correspond to echoes and reflections within the simulated
environment, contributing to a more immersive auditory experience.
● The time complexity of the convolution process is influenced by the
length of the input signals, with longer signals demanding increased
computation time due to additional multiplications and additions.
● Recognizing the computational intensity of convolution, potential
enhancements through fast algorithms or parallel processing can be
explored to improve overall efficiency, crucial considerations for
real-world applications balancing realism and computational resources.
RESULT:
DISCUSSION:
● The FFT approach to convolution offers a more efficient alternative to
direct convolution, especially for lengthy signals, with the choice of
zero-padding influencing the quality of the convolution results. The
trade-off between initial preprocessing steps and the speed of
convolution favours the FFT approach in scenarios where
computational efficiency is paramount.
c. Real time implementation: Audio signals are typically quite long (though in
our example, this is not the case). Hence, for real time implementation,
processing should happen in segments.
Two such approaches are: Overlap-add and Overlap-save. Implement either
overlap-add or overlap-save method for performing convolution. Modify the
algorithm to use the FFT based filtering as in (b) to perform convolution.
Compare the execution time for the different approaches as a function of block
size (a parameter in overlap-add/overlap-save method)
RESULT:
DISCUSSION:
● Here we have written a code for the overlap add method and asking the
user to give the input , down we have attached for L=5 , the key factor
length will be decided by the user .
● For real-time processing of long audio signals, efficient convolution is
achieved by segmenting the input signals using methods such as
overlap-add or overlap-save.
● In the overlap-add approach, the input signal is partitioned into blocks,
each convolved independently.
○ Overlapping segments are then added to ensure smooth
transitions across blocks, potentially enhancing convolution
quality. The computational cost is dependent on the chosen
degree of overlap, where increased overlap incurs more additions
but may contribute to improved overall convolution quality.
● These strategies enable incremental convolution, making them valuable
techniques for real-time applications where seamless audio processing
is essential.
● FFT is applied to both the input blocks and the filter, reducing the
convolution operation to a pointwise multiplication in the frequency
domain.
Part – B
1. Write a MATLAB program to compute and display the poles and zeros of a
transfer function.
To do this, first compute and display the factored form of the transfer function.
Then, generate the pole-zero plot of a transfer function, that is as a ratio of
two polynomials in 𝑧 −1 . Using this program, analyse the z-transform of
𝐻(𝑧) = (2 + 5𝑧 −1 + 9𝑧 −2 + 5𝑧 −3 + 3𝑧 −4 )/(5 + 45𝑧 −1 + 2 𝑧 −2 + 𝑧 −3 +𝑧 −4 )
RESULT:
DISCUSSION:
● The positions of zeros and poles in the complex plane affect the
behavior of the transfer function.
● Poles in the right half-plane may lead to instability, while zeros in the
right half-plane contribute to the inverse behavior.
● The spread of poles and zeros provides insights into the system's
frequency response and stability characteristics.
2. From the pole-zero plot generated in Qn (1), determine the possible ROCs.
Can you tell from the pole-zero plot whether or not the DTFT exists? Is the
system stable if it is causal?
DISCUSSION:
● Possible rocs are |z| < 0.2718 and |z| > 8.9576 (assuming the system's
time domain representation is not infinitely long).
● The ROC for left handed sequence is |z|<0.2718, whereas for right
handed sequence, it is |z|>8.9576.
● Both ROCs don’t contain the unit circle in it, therefore DTFT is not
possible.
● Even though the system is causal, there is a pole outside the unit circle,
hence the system is unstable.
RESULTS:
DISCUSSION:
● zp2tf() function is used to convert the zero-pole-gain representation to a
transfer function representation. The basic syntax is:
[num, den] = zp2tf(z, p, k)
● Where:
○ z = zeros of the system
○ p = poles of the system
○ k = system gain
● The function returns the numerator and denominator coefficients of the
transfer function
● The pretty(X) function prints X in a plain-text format that resembles
typeset mathematics.
RESULTS:
DISCUSSION:
· Impz() function gives the impulse response of the digital filter directly.
· Residuez() function decomposes a rational function into a partial fraction.
· The time domain representation h(n) is same in both cases
· Therefore, the inverse Z-transform of a transfer function is impulse response.
RESULTS:
DISCUSSION:
● The H(z) of question 4 and the reconstructed H(z) in question 5 are nearly
the same
RESULTS:
DISCUSSION:
● For a minimum phase system, the poles should be inside the unit circle
● For a maximum phase system, the poles should be outside the unit circle
● For a mixed phase system, the poles can be inside or outside the unit circle
● H1(z) is a minimum phase system
● H2(z) is a maximum phase system