I have these three equations and have a noisy voice signal. I have to design a low pass filter of length N=1000 using hamming window technique. I have selected its cutoff frequecny 0.25 (normalized). \begin{eqnarray} h_{id}[n] &=& \frac{\sin{(2\pi f_c (n - \frac{N-1}{2}))}}{\pi (n - \frac{N-1}{2})},\ 0\le n \le N-1 \\ w[n] &=& 0.54-0.46\cos{(\frac{2\pi n}{N})} ,\ 0\le n \le N \\ h_F[n] &=& h_{id}[n]\cdot w[n] \\ \end{eqnarray} Now the problems that I am facing are: if I follow the equations, the dimensions of both $h_{id}[n]$ and $w[n]$ becomes unequal and I cannot multiply them to get the finite length impulse responce of sinc function; also as I am a newbie I really do not know how to apply this filter to the voice signal.
Note: According to the instructions from the Professor, I can not use any built-in function or commands except the "filter" command
Any help would be appreciated.
The Matlab code:
clc; clear all; close all
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
N = 1000;
n = 0:N-1;
new_n = 0:N;
fc = 0.3;
temp_N = (N-1)/2;
h_id = sin(2*pi*fc *(n - temp_N))./(pi *(n - temp_N));
figure('Name','Voice Signal in Time Domain','NumberTitle','off');
subplot(2,1,1)
plot(n,h_id)
title('Continous Time Plot (not true: as we have a DT signal, it is just for understandings)')
xlabel('Time \rightarrow')
ylabel('Magnitude \rightarrow')
axis([450 550 -0.2 0.7])
subplot(2,1,2)
stem(n,h_id)
title('Discrete Time Plot')
xlabel('Samples \rightarrow')
ylabel('Magnitude \rightarrow')
axis([450 550 -0.2 0.7])
w = 0.54 - 0.46*cos((2*pi*new_n)/N);
h_F = h_id .* w;
freqz(h_F)
fileName = 'D:\Studies\Semester#6\Digital Signal Processing\Assignments\Assignment 2\VOICE.wav';
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
[y, fs] = audioread(fileName);
N_FFT = length(y);
time = (1/fs) * N_FFT;
t = linspace(0, time, N_FFT);
figure('Name','Voice Signal in Time Domain','NumberTitle','off');
plot(t,y);
title('Time Domain plot of the Voice Signal')
xlabel('Time \rightarrow')
ylabel('Magnitude \rightarrow')
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
playerObj = audioplayer(y, fs);
play(playerObj);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
signalFFT = fft(y);
figure('Name','Voice Signal in Frequency Domain','NumberTitle','off');
subplot(2,1,1)
xaxis = (0:N_FFT-1)/N_FFT;
plot(xaxis, abs(signalFFT));
title('Frequency Domain Plot of the Voice signal (without shifting[fftshift])')
xlabel('Normalized Frequency \rightarrow')
ylabel('Magnitude \rightarrow')
subplot(2,1,2)
plot(xaxis, fftshift(abs(signalFFT)));
title('Frequency Domain Plot of the Voice signal (with shifting[fftshift])')
xlabel('Normalized Frequency \rightarrow')
ylabel('Magnitude \rightarrow')