Part 2
********* Matlab Code for the other parts ************ %%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%% %%%%
echo filters and effects on ausio signals clear; load splat.mat;
% loading the audio files x=y; % x = input Ts = 1/Fs; % sampling period t = 0:Ts:(length(x)/Fs)-Ts; %
time vector z = tf('z',Ts); H = 1 + (0.1*z^(-7373)) + (0.15*z^(-11470)) + (0.25*z^(-14746));
% filter transfer function y = lsim(H,x);
% filter output
% Time domain plots
% subplot(2,1,1) plot(t,x); xlabel('Time (s)'); ylabel('X'); title('Time domain plots of the original signal
and with the echo');
subplot(2,1,2) plot(t,y); xlabel('Time (s)'); ylabel('Y');
%Freq domain plots
Y1 = fft(x); L = length(x);
% Compute the two-sided spectrum P2.
% Then compute the single-sided spectrum P1 based on P2 and the even-valued signal length L. P2 =
abs(Y1/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1);
% Define the frequency domain f and plot the single-sided amplitude spectrum P1. f = Fs*(0:(L/2))/L;
figure; subplot(2,1,1) plot(f,P1) title('Single-Sided Amplitude Spectrum of X(t) and Y(t)') xlabel('f (Hz)')
ylabel('|Y1(f)|') Y2 = fft(y); L = length(y);
% Compute the two-sided spectrum P2.
% Then compute the single-sided spectrum P1 based on P2 and the even-valued signal length L. P2 =
abs(Y2/L); P1 = P2(1:L/2+1); P1(2:end-1) = 2*P1(2:end-1);
% Define the frequency domain f and plot the single-sided amplitude spectrum P1. f = Fs*(0:(L/2))/L;
subplot(2,1,2) plot(f,P1) xlabel('f (Hz)') ylabel('|Y2(f)|')
% Hearing the sounds before and after the echo effect
% sound(x,Fs); pause(3); sound(y,Fs);
******* End of Code *********