Você está na página 1de 6

E.

ECHO FILTER

The following FIR filter can be interpreted as an echo filter.

y1[n] = x1[n] + r x1[n P]

You have an audio signal sampled at fs= 8000 Hz and you would like to add a delayed version of
the signal to simulate an echo. The time delay of the echo should be 0.2 seconds, and the strength
of the echo should be 90% percent of the original. Determine the values of r and P; make P an
integer.Use the function filter( ) to implement the FIR filter on your created input signal x[n].
Listen and observe the input and output waveforms. Describe the sound that you hear and use the
impulse response to explain why it sounds that way

The relationship of x(t) and x[n] is

t = nTs

so,
x[n P] = x((n P) t=Ts)

= x(nTs PTs)

= x(t PTs)

Therefore, PTs = 0.2


P = 1600

Then, assume the strength of the original signal is A=1, so, r =0.9

For a causal discrete-time FIR filter of order N, each value of the output sequence is a weighted
sum of the most recent input values:

where:

x[n] is the input signal,

y[n] is the output signal,

N is the filter order; an Nth-order filter has (N+1) terms on the right-hand side

bi is the value of the impulse response at the i'th instant for 0 < i < N of an Nth-order FIR
filter. If the filter is a direct form FIR filter then bi is also a coefficient of the filter.
This computation is also known as discrete convolution.
The x[n-i] in these terms are commonly referred to as taps, based on the structure of a tapped
delay line that in many implementations or block diagrams provides the delayed inputs to the
multiplication operations. One may speak of a 5th order/6-tap filter, for instance.
The impulse response of the filter as defined is nonzero over a finite duration. Including
zeros, the impulse response is the infinite sequence:

If an FIR filter is non-causal, the range of nonzero values in its impulse response can start
before n = 0, with the defining formula appropriately generalized.

F. REVERBERATION
G. RESTORATION FILTER

The following FIR filter;

It can be use to undo the effects of the FIR filter in the previous section (see the block diagram in
Fig. 3). It performs restoration, but it only does this approximately. Use the following steps to
show how well it works when r = 0.9 and M = 22.
1. Process the signal w[n] from (3) with FILTER-2 to obtain the output signal y[n].
2. Make stem plots of w[n] and y[n] using a time-index axis n that is the same for both signals.
Put the stem plots in the same window for comparisonusing a two-panel subplot.
3. Since the objective of the restoration filter is to produce a y[n] that is almost identical

Figure 3: Cascading two FIR filters: the second filter attempts to deconvolve the distortion
introduced by the first.

Filtering Process:
Now we use the signal vector x1 as the input to an FIR filter:
For the warm-up, we will do the filtering with a 5-point averager. The filter coefficient vector for
the 5-point averager is defined via:
bb = 1/5*ones(1,5);

Then we use firfilt to process x1 and determine how long are the input and output signals.
After that, we must make a plot of the input signal and output signal together to illustrate the
filtering action of the 5-point averager. Since x1[n] and y1[n] are discrete-time signals, a stem
plot is needed. One way to put the plots together is to use subplot(2,1,*) to make a two-panel
display:
nn = first:last;
subplot(2,1,1);
stem(nn,x1(nn))
subplot(2,1,2);
stem(nn,y1(nn),filled) %--Make black dots
xlabel(Time Index (n))
This code assumes that the output from firfilt is called y1. Try the plot with first equal to the
beginning index of the input signal, and last chosen to be the last index of the input. In other
words, the plotting range for both signals will be equal to the length of the input signal, even
though the output signal is longer.

This is an example of filtering that is Removing Unwanted Spectral Content from a Signal
Filters are commonly used to remove unwanted spectral content from a signal. We can choose a
lowpass filter when you want to remove high frequency content, or a highpass filter when you
want to remove low frequency content. You can also choose a bandpass filter to remove low and
high frequency content while leaving an intermediate band of frequencies intact. Lastly, we can
choose a bandstop filter when you want to remove frequencies over a given band.

This is a design of a lowpass filter with passband frequency of 1 kHz, and stopband frequency of
1.4 kHz.
Fp = 1e3; % Passband frequency in Hz
Fst = 1.4e3; % Stopband frequency in Hz
Ap = 1; % Passband ripple in dB
Ast = 95; % Stopband attenuation in dB

% Design the filter


df = designfilt('lowpassfir','PassbandFrequency',Fp,...
'StopbandFrequency',Fst,'PassbandRipple',Ap,...
'StopbandAttenuation',Ast,'SampleRate',Fs);

% Analyze the filter response


hfvt = fvtool(df,'Fs',Fs,'FrequencyScale','log',...
'FrequencyRange','Specify freq. vector','FrequencyVector',F);
% Filter the data and compensate for delay
D = mean(grpdelay(df)); % filter delay
ylp = filter(df,[y; zeros(D,1)]);
ylp = ylp(D+1:end);

close(hfvt)

[Plp,Flp] = pwelch(ylp,ones(8192,1),8192/2,8192,Fs,'power');
helperFilterIntroductionPlot1(F,P,Flp,Plp,...
{'Original signal','Lowpass filtered signal'})

Look at the spectrum of the lowpass filtered signal. We will see how the frequency content above
1400 Hz has been removed.
From the power spectrum plot above, we can see that the maximum non-negligible frequency
content of the lowpass filtered signal is at 1400 Hz. By the sampling theorem, a sample
frequency of 2*1400 = 2800 Hz would suffice to represent the signal correctly, we also using a
sample rate of 44100 Hz which is a waste since it will need to process more samples than those
necessary. we can downsample the signal to reduce the sample rate and reduce the computational
load by reducing the number of samples that we need to process. A lower sample rate will also
allow us to design a sharper and narrower bandstop filter, needed to remove the 60 Hz noise,
with a smaller filter order.

Conclusions
Through the example, we have learned how to apply filters to remove unwanted frequency
components from a signal, and how to downsample a signal after limiting its bandwidth with a
lowpass filter to restore the original signal.

Reference
McClellan, Schafer, and Yoder, Signal Processing First, ISBN 0-13-065562-7.
Prentice Hall, Upper Saddle River, NJ 07458. c
2003 Pearson Education, Inc.

Você também pode gostar