***Your Name***
***Institution***
Abstract 3
Introduction 4
Problem 1 4
Problem 2 6
Problem 3 7
Problem 4 9
Problem 5 12
Discussion 13
Conclusion 14
References 15
Appendix 17
Abstract
Noisy audio signals are relatively common and unavoidable. An important task of digital signal processing is to tackle this problem, so as to produce an almost, if not noiseless audio signal. One way of doing this is to use Finite Impulse Response (FIR) filters. Here we present our findings on different FIR filters, and their effects on an audio signal provided in the form of a sampled speech waveform. Some FIR filters studied here include the 3-point averager, 15-point averager, first difference filter, and two user-defined filters. The user-defined filters have pre-determined “b” coefficients, and knowing these is sufficient to characterize each of the user-defined FIR filter. MATLAB will be used as the software to process the audio, and operate on the filters.
Introduction
For an FIR filter, the output is a weighted sum of the current, and a finite number of previous values of the input. The operation is described by the following equation, which defines the output sequence y[n] in terms of its input sequence xn:
yn=b0xn+b1xn-1++bNxn-N
= i=0Nbix[n-i] ----- (1)
Here we will be using two files: Data_Lab1.mat and firfilt.m available in the “Lab 1” folder on Blackboard. The file Data_Lab1.mat is loaded to the workspace. The file contains three variables: x, filter1, and filter2. The variable x stores a sampled speech waveform. Two sets of filter coefficients are stored in filter1 and filter2. These coefficients correspond to the “bis” associated with Equation (1), and are different for each filter. The function firfilt.m implements an FIR filter in MATLAB. The filters have been tested on the speech signal.
Problem 1
a.
The input and output signals have been plotted in Figure 1.1.
Figure 1.1: Input and output signals using filter1.
b.
The waveform of the original signal x has several spikes in amplitude. This corresponds to when the speaker starts to utter a syllable. There are several sections in the waveform where the amplitude is relatively low. This corresponds to when the speaker is in silence.
The waveform of the filtered signal from filter1 is observed to be smoother and lack high-frequency noise (lacking rapidly changing part of the signal x) compared to the waveform of the original signal x. In fact, during the period where the speaker is not speaking but merely noise, for example from sample about 0.5e+04 to 0.6e+04, and from 1.5e+04 to 1.6e+04, filter1 has dramatically reduced the noise from signal x to produce the filtered signal. This suggests that the filtered signal will convey the audio message from the speaker in a clearer manner, and more audible than the original signal x. The amplitude for both the filtered signal and x is about the same. Thus, we expect the speaker will be speaking with about the same volume when we listen to the filtered signal or the original signal x.
c.
The order of the filter is (length of filter1 vector) = 45. We produced Figure 1.2 showing the frequency response of filter1 using the Matlab function “freqz” (Mathworks, n.d.). It can be seen that filter1 is a low-pass filter. The normalized frequency in Figure 1.2 has a range from 0 to 1, and is defined to be the frequency in Hz divided by half of the sampling frequency (Newbold, 2012). In Figure 1.2, the magnitude is quoted in decibel. The decibel is defined to be 20 log(A/A0), where A and A0 is the output and input amplitude for a given frequency (Gaydecki, 2004, p. 227). A low-pass filter is a filter whereby low frequencies are allowed to pass but those of higher frequencies are attenuated (Lyons, 1997). The attenuations are shaped as ripples (Lyons, 1997) as can be seen in Figure 1.2.
Figure 1.2: Frequency response of filter1
Problem 2
a.
Figiure 2.1 shows the input and output signals using filter2.
Figure 2.1: Input and output signals using filter2
b.
The filtered signal from filter2 seems to be as noisy as the original signal x. The waveform of the filtered signal from filter2 is not smoother and contains high-frequency noise (contains the rapidly changing part of the signal x) compared to the waveform of the original signal x. In fact, during the period where the speaker is not speaking but merely noise, for example from sample about 0.5e+04 to 0.6e+04, and from 1.5e+04 to 1.6e+04, filter2 did not reduce the noise from signal x to produce the filtered signal. This suggests that the filtered signal will convey the audio message from the speaker in a less clear manner, and less audible than the original signal x. The amplitude of the filtered signal is generally smaller compared to the original signal x. This strengthens our claim that filter2 contains an ample amount of noise but relatively less amplitude pertaining to the audio message from the speaker.
c.
Using Matlab function “freqz”, we produced Figure 2.2 showing the frequency response of filter2. It can be seen that filter2 is a high-pass filter. A high-pass filter is a filter whereby high frequencies are allowed to pass but the low-frequency content is attenuated (Lyons, 1997). In other words, the rapidly changing part of the signal x is allowed to pass through. The attenuations are shaped as ripples (Lyons, 1997) as can be seen in Figure 1.2. The passband is about 70% of the entire normalized frequency range, and the stopband is about 21% of the entire normalized frequency range.
Figure 2.2: Frequency response of filter2
Problem 3
a.
The speaker spoke: “Oak is strong, and also give shade”. The sound coming out from the filter1-filtered signal is in a lower frequency than the original signal x. The sound coming out from the filter2-filtered signal is in a higher frequency and smaller volume than the original signal x.
b.
Since filter1 + filter2 gives an FIR filter which produces an output of the following form (using Matlab):
yn=x[n-22] , and
y12 = (filter1 + filter2)(x) = filter1(x) + filter2(x) = y1 + y2, (by linearity of FIR)
the sound signal we expect to hear is the same as the original signal x including the amplitudes, but the whole new sound signal is delayed by 22 samples compared to the original. Note that, FIR has linearity as its property (Smith, J.O., 2007), and has been utilized to obtain the relationship above. Our expectation on the delay was verified when we hear the sample.
c.
Since filter3 = filter1 + filter2, this is the same filter as (b) above. Therefore, y3 is the same filtered signal sample produced as in (b). Hence, we expect to hear no difference from y3 compared to (b). We have verified that this is the case when we hear the sample y3. In fact, we have computed and plotted a signal with the waveform satisfying: y3 – (y1 + y2) with Matlab, and found that the amplitude of this signal is zero throughout the entire signal, taking into account the rounding errors. The corresponding figure is shown in Figure 3.1.
Figure 3.1: Filtered signal y3 – (y1 + y2).
Problem 4
a.
The vector FPA has the elements: [1/3 1/3 1/3]. This is because the coefficient for x[n] is 1/3, the coefficient for x[n-1] is 1/3, and the coefficient for x[n-2] is 1/3.
b.
Figure 4.1 shows the first 100 samples of x and FPA_filtered signals.
Figure 4.1: The first 100 samples of x and FPA_filtered.
The 3-point averager reduces the high frequency noise from the signal. This can be seen from the smoothing effect of the signal in the filtered signal from the 3-point averager. There are less “jags” and “humps” in the filtered signal compared to the original signal x. This suggests that the filtered signal will be clearer pertaining to the audio message and more audible than the original signal. Additionally, the filtered signal is observed to have less sharp edges compared to the original signal x.
c.
Figure 4.2 shows the first 100 samples of x, FPA_filtered and FIFPA_filtered.
Figure 4.2: The first 100 samples of x, FPA_filtered, and FIFPA_filtered respectively.
N-point averagers filter out high frequency noise, and thus are low-pass filters (Smith, S.W., 1997, p. 277). As N gets higher, more high-frequency noise is removed. This can be verified with their frequency responses as shown in Figure 4.3 and Figure 4.4. From the Figures 4.2 above, we observe that a 15-point averager is a better noise filter than a 3-point averager, i.e. it smoothens more the waveform from signal x. However, we can also observe that the output from a 15-point averager has less sharp edges compared to the output from a 3-point averager. Also, the output from a 3-point averager has less sharp edges compared to the signal x.
However, the N-point averagers are not as effective as the low-pass filter filter1 in Problem 1, as observed from the frequency response. The high frequencies still have a large amplitude for the N-point averagers, and also, for the 15-point averager, some low frequency components are also attenuated. Since the audio message from the speaker is contained in the low frequency part, the attenuation in this part is not desirable.
Figure 4.3: Frequency response of 3-point-averager filter.
Figure 4.4: Frequency response of 15-point-averager filter.
Problem 5
a.
Vector FD = [1 -1]. This is because the coefficient for x[n] is 1, and the coefficient for x[n-1] is -1.
b.
Figure 5.1 shows the first 100 samples of x and FD_filtered.
Figure 5.1 : The first 100 samples of x and FD_filtered.
FD seems to produce a filtered signal which is composed mainly of noise. The noise are those originating high frequency sources as can be observed from the jags, and the “ups” and “downs” in the waveform of the signal x in an otherwise smooth signal. If we examine the frequency response of filter FD as shown in Figure 5.2, we find that FD is a high-pass filter. A first difference filter is indeed a high-pass filter (Christensen, 2001, p.184). This is also consistent with what we have observed and predicted. In fact, FD amplifies the higher frequency content while attenuate the lower frequency content as can be seen from Figure 5.2.
Figure 5.2: Frequency response of filter FD.
Discussion
FIR filter is a linear and time-invariant (LTI) filter (Meyer-Baese, 2007, p. 164). It is time-invariant because its “b” coefficients do not vary with time as can be seen from the constant b values for each Problem. The linearity of the filter has been utilized in solving Problem 3(b) and (c). In this analysis, we found that filter1 is a low-pass filter, and filter2 is a high-pass filter in contrast with filter1. Additionally, filter3 is not really a filter since the output of filter3 is the same as the original signal x. Filter 3 is a superposition of filter 1 and filter 2. When we take the superposition, filter3 has only one non-zero coefficient, i.e. b22 = 1. This indicates that filter1 and filter2 are almost a mirror image of one another.
The 3-point averager and the 15-point averager are found to be low-pass filters. The first difference filter is found to be a high-pass filter, in contrast with the N-point averagers. Our observation is that the N-point averagers are not as effective as low-pass filters compared to filter1. This is because the low-frequency content is also attenuated in the N-point averagers which is undesirable. This does not occur with filter1. We also note that the first difference filter does not have ripples in its frequency response. The said filter also amplifies the high frequency content while attenuating the low-frequency content. In contrast, the high-pass filter, filter2 do not do any amplification, and has ripples in its stopband, which is undesirable. Thus, the first difference filter is a better high-pass filter compared to filter2.
Conclusion
We have analyzed several FIR filters, namely the 3-point averager, 15-point averager, first difference filter, and two user-defined filters. In this report, we have categorized them either as high-pass or low-pass filter, and have used Matlab “soundsc” function to listen to the filtered signal obtained from these filters. Filter1 and N-point averagers are low-pass filters. Filter2 and first difference filters are high-pass filters. The waveform of these filtered signals, and the original signal have been plotted for comparison purposes.
References
Christensen, R. (2001) Advanced Linear Modeling. 2nd ed. New York: Springer Verlag.
Gaydecki, P. (2004) Foundations of Digital Signal Processing. 1st ed. London: The Institution of Engineering and Technology.
Lyons, R.G. 1997. Digital Filter Terminology [Online]. Iowegian International. Available at:
http://www.dspguru.com/dsp/reference/filter-terminology [Accessed: 25 October 201].
Mathworks. 2011. freqz [Online]. Available at:
http://www.mathworks.com/help/signal/ref/freqz.html [Accessed: 25 October 2014].
Meyer-Baese, U. (2007) Digital Signal Processing with Fields Programmable Gate Arrays.
3rd ed. Berlin: Springer-Verlag.
Newbold, R. 2012. Practical Applications in Digital Signal Processing: Review of Digital Frequency [Online]. Pearson. Available at: http://www.informit.com/articles/article.aspx?p=1967020&seqNum=4 [Accessed: 24 October 2014].
Smith, J.O. 2007. Introduction to Digital Filters with Audio Applications: Superposition [Online]. Stanford University. Available at https://ccrma.stanford.edu/~jos/fp/Superposition.html [Accessed: 26 October 2014].
Smith, S.W. 1997. The Scientist and Engineer’s Guide to Digital Signal Processing [Online]. California Technical Publishing. Available at http://www.dspguide.com/pdfbook.htm [Accessed: 24 October 2014].
Appendix
Problem 1
>> y1 = firfilt(filter1,x);
>> plot(x)
>> hold on
>> plot(y1,'k')
>> xlabel('Sample')
>> legend('x','y1')
>>
>> ylabel('Amplitude')
Problem 2
>> y2 = firfilt(filter2,x);
>> plot(x)
>> hold on
>> plot(y2,'k')
>> xlabel('Sample')
>> legend('x','y2')
>> ylabel('Amplitude')
Problem 3
>> soundsc([x;y1;y2],8000);
>> soundsc([x; (y1+y2)],8000);
>> filter3 = filter1 + filter2;
>> y3 = firfilt(filter3, x);
>>y3 – (y1+y2);
>>soundsc([x;y3],8000);
Problem 4
>> FPA = [1/3 1/3 1/3]
FPA =
0.3333 0.3333 0.3333
>> FPA_filtered = firfilt(FPA,x);
>> subplot(1,2,1)
>> plot(x)
>> axis([0 100 -200 200])
>>
>> title('Signal x')
>> subplot(1,2,2)
>> plot(FPA_filtered)
>> axis([0 100 -200 200])
>> title('Filtered signal FPA_filtered')
>>
>> title('Filtered signal FPA _ filtered')
>> xlabel('Sample')
>> subplot(1,2,1)
>> xlabel('Sample')
>> FIFPA = zeros(1,15)
FIFPA =
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
>> for i = 1:15
FIFPA(i) = 1/15
end
FIFPA =
Columns 1 through 9
0.0667 0.0667 0.0667 0.0667 0.0667 0.0667 0.0667 0.0667 0.0667
Columns 10 through 15
0.0667 0.0667 0.0667 0.0667 0.0667 0.0667
>> subplot(1,3,1)
>> plot(x)
>> axis([0 100 -500 500])
>> title('Signal x')
>> xlabel('Sample')
>> subplot(1,3,2)
>> plot(FPA_filtered)
>> axis([0 100 -500 500])
>> title('Filtered signal FPA filtered')
>> xlabel('Sample')
>> subplot(1,3,3)
>> FIFPA_filtered = firfilt(FIFPA,x);
>> plot(FIFPA_filtered)
>> axis([0 100 -500 500])
>> xlabel('Sample')
>> title('Filtered signal FIFPA filtered')
>>
Problem 5
>> FD = [1 -1]
>> FD_filtered = firfilt(FD,x)
>> subplot(1,2,1)
>> plot(x)
>> xlabel('Sample')
>> title('Signal x')
>> subplot(1,2,2)
>> plot(FD_filtered)
>> xlabel('Filtered signal FD filtered')
>> xlabel('Sample')
>> title('Filtered signal FD filtered')
>> axis([0 100 -500 500])
>> subplot(1,2,1)
>> axis([0 100 -500 500])