1
$\begingroup$

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')
$\endgroup$
  • 1
    $\begingroup$ Why are you using n=0..N-1 for h[n] and 0..N for w[n]? Both should be the same, I'll leave you to figure it out which one'sthe good range. Also, is the sinc() argument for frequency correct? I can't tell. $\endgroup$ – a concerned citizen Jun 20 '18 at 6:37
  • $\begingroup$ There is an article about this (with C++ sample code) here liquidsdr.org/blog/basic-fir-filter-design $\endgroup$ – firdes Jun 21 '18 at 9:06
0
$\begingroup$

If you can’t make the lengths of your Sinc kernel and window function the same, you can zero-pad the shorter of the two before you multiply them together.

$\endgroup$
  • $\begingroup$ Is this correct? Surely you'd want the window function and sinc to remain centered in the buffer. Zero padding at the end of the buffer would lead to a time offset. The functions are component-wise multiplied, not a convolution. $\endgroup$ – firdes Jun 21 '18 at 9:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.