Laboratory 5: DSP - Digital Signal Processing OBJECTIVES - Familiarize the students with Digital Signal Processing using software tools on the treatment of audio signals. - To study the time domain and the frequency domain representation of signals. - Illustrate the information compression process, based on the conversion of an audio file in wav format to mp3 format. - Demonstrate that through digital filtering, the amount of noise in an audio signal can be reduced. DESCRIPTION What is DSP? Digital Signal Processing or DSP refers to the processing of signals by digital means. In order to digitally process a signal, we must first take what is commonly known as a real-world signal or an analog signal. This signal has to be converted to a digital signal, or a signal represented by binary numbers. The analysis is carried out in digital form because once a signal has been converted to numbers, its components can be isolated, analyzed and manipulated more easily than in its analog form. Among the applications that are found within DSP are: signal noise filtering, elimination of interference, amplification of signals within specific bands of frequencies, encryption and compression of information, and analysis of images or complex signals in the frequency domain. Applications The technology of DSP can be found today in applications such as: mobile telephones, computer multimedia, CD readers, controllers of the hard disc drives, and in modems. An important application of DSP is in the compression and decompression of the signals in CD systems. For example, the music stored in the CD is in a compressed format (to enlarge the capacity of the memory, or better memory efficiency) and must be decompressed so that the signal can be reproduced. Signal compression is also used in digital portable telephones to permit that a greater number of calls be handled simultaneously inside each local cell. The technology of signal compression permits that people not only speak through telephones, but can also see each other in their PC (personal computer) screens using computer video cameras, and this is achieved using only a conventional telephone line carrying all signals together. Analog and digital signals In many cases a signal is initially represented in the form of a time-varying voltage or electric current which can be generated, for example, by a microphone or another type of transducer. In other situations the data is already in digital form, as for example, the output of a digital compact disk system. To be able to apply DSP to some data, all analog signals must be converted to a numerical digital form. An analog voltage Lab. # 5 - Introduction to Digital Signal Processing 37
signal, for example, can be converted to digital form using an electronic device called ADC or analog to digital converter. An ADC generates a digital output signal in the form of a binary number that represents the electric voltage values. Representation of signals Every signal can be represented in two forms: the time domain or the frequency domain. - In the time domain a signal can be represented as a variation of amplitude vs. time - In the frequency domain a signal can be represented as a variation of amplitude vs. frequency. PROCEDURE Time domain representation The objective is to represent a sinusoidal, square and triangular signal of 500 Hz in the time domain. 1. Run the program Cool Edit 2000 accessible in the computer Desktop 2. To work on a new project select File>New, choose the desired type of signal, the sample rate and the resolution of the samples. a. To select the Sample Rate follow the Nyquist Criteria F s 2*f max. Nyquist Theorem tells us that in order to recover a complete analog signal the sampling frequency must be at least twice the value of the maximum frequency component of the signal. For example, if the signal frequency is 500 Hz, the sampling frequency can be 1000 Hz; Fs=2*500=1000 Hz. If the desired sampling frequency is not available in the program, choose the following larger value, which in this case is Sample Rate>6000. b. For this exercise we will work with a one channel signal, so in Channels choose Mono. c. The resolution depends on the installed audio card in the computer. For our case it is enough to choose a Resolution>16 bit. 3) To generate the tone select in the menu toolbar Generate>Tones, and click on Lock to these settings only to select it. Configure the window as presented in Figure 1, to generate a sinusoid signal of 500 Hz, with duration of 10 sec. a. Click on OK to plot the signal on the display. The signal appears on the display represented in its time domain format, that is, you will see a plot of amplitude (vertical axis) vs. time (horizontal axis). Notice the length of the time axis is 10 sec. Lab. # 5 - Introduction to Digital Signal Processing 38
b. To effectively observe the characteristics of the signal, zoom in the time axis. To do this, click various times in the zoom in to center icon located in the lower left corner. c. To display the signal, click on the icon. Figure 1 CoolEdit window for tone generation Frequency domain representation Using as reference the previously generated signal, a frequency domain transformation is applied. 1) Select Analyze> Frequency Analysis. A new window will appear illustrating the depiction of amplitude, in decibels (db), vs. frequency in Hz. 2) Repeat all the steps for both, time domain and frequency domain representations, but this time using a square signal and a triangular signal. Observe the differences. Lab. # 5 - Introduction to Digital Signal Processing 39
3) To change the type of signal select Generate>Tones to view the same window as Figure 1. Then select General>Flavor and select the desired signal type: Square or Triangle. Conversion of a file of format.wav to format.mp3 The objective is to convert an audio file of extension.wav to.mp3, and then view differences between these two formats such as file size and quality. For this demonstration the file cancion.wav will be used. 1. First, choose the desired sampling rate to read the file. These.wav files have a reproduced frequency range of 22 KHz. These indicates that if we use the Nyquist Criteria, the sampling frequency must be 2*f max =44 KHz. To choose the sampling rate input File>New, then choose in each option: Sample Rate>44100 Channels>Mono Resolution>16-bit 2. Open the file cancion.wav; for this select File>Open and seek in the folder C:\Program Files\Cool2000 and open de file named Test 1. 3. Open the frequency analysis window, Analyze>Frequency Analysis and place a Range of 200 db. 4. Play the song; click over the icon. 5. Observe the frequency spectrum of the signal and register the frequency range of the reproduced signal. Compresses the archive in format.mp3 1. Enter File>Save As, to save the file with extension.mp3, cancion.mp3, as shown in Figure 2. 2. First enter in Options to configure the conversion formatting as shown in Figure 3. 3. Now press the save key. 4. The signal will be saved in the computer buffer and displayed in the computer monitor. Try to reproduce the signal and verify the frequency spectrum. 5. Register the operation frequency range of the file in format.mp3. Lab. # 5 - Introduction to Digital Signal Processing 40
6. Verify the size of the file and observe any difference with the.wav file. Figure 2 Saving the music file in.mp3 format. Figure 3 Conversion formatting window Lab. # 5 - Introduction to Digital Signal Processing 41
Filtering Below the effect of digital filtering of a music file is illustrated. 1. Open the file cancion.wav; for this select File>Open and seek in the folder C:\Program Files\Cool2000. 2. Open the frequency analysis window, Analyze>Frequency Analysis to view the effect of the filtering. 3. Play the song to listen to the sound quality; click on the icon. 4. Then filter the signal selecting Transform>Filters>FFT Filter, and a window will come into view with different filtering options as shown in Figure 4. Figure 4 Filtering options window 5. Select Presets>Low Pass 4000 Hz and then OK to listen and observe the effect of this filter on the signal. 6. Play the filtered file, observe and listen to the attributes of the sound. Lab. # 5 - Introduction to Digital Signal Processing 42
7. Select another type of filtering and find the differences with respect to the past filter. Voice recording and noise reduction In this part it is intended to save a voice recording of a volunteer by way of using a microphone to then process it by eliminating the environmental noise, searching for the best possible reproduction quality. The human voice has an audible frequency range of approximately 3 KHz. This means that if we apply the Nyquist theorem we can calculate the sampling rate of the signal, which in this case will be 6 KHz. 1. Before beginning the recording process, be sure the computer has a microphone connected. 2. Open a new project, File>New, and configure each option in the following way: Sample Rate>6000 Channels>Mono Resolution>16 bit 3. Start the voice recording by clicking in the Record icon. 4. Record for a period of 10 sec, and then stop the process by clicking in the Stop icon. 5. Verify that the recorded signal appears in the display, in case it is not, repeat the previous instructions. 6. Play the signal and listen to the level and quality of the recording. If the level is too weak, the signal must be amplified. This can be done selecting Transform>Amplitude>Amplify, then vary the amplification by moving the slider of the Amplification until the desired level. 7. To reduce the level of noise of the signal, select the piece of signal where only noise exists, and no voice is present, which only happens in speech pauses. Identify the part of the signal which contains a pause and then select this region by right-clicking and dragging over this area with the mouse. 8. Then select in Transform>Noise Reduction> Noise Reduction to complete the necessary noise reduction. Lab. # 5 - Introduction to Digital Signal Processing 43
9. The yellow line that appears in this window represents the frequency response of the filter. With the mouse we can change the flat filter response to a low-pass filter type response, as shown in Figure 5. 10. Then click in Get Profile from Selection to load the level of noise of the selected signal from the last instruction. 11. Moving the slider for Noise Reduction Level we reduce the mean value of the signal noise. Figure 6. 12. Alter selecting the level of noise reduction, click on OK to execute the filtering of the selected region. In the display there should appear a reduction in the noise levels. 13. To reduce the level of noise in the recorded signal you must select the whole signal and then enter in Transform>Noise Reduction>Noise Reduction. The window with the previous Noise Reduction configuration will appear, then, just click on OK to implement it on the whole signal. Flat response Filter shape Figure 5 Filter shapes can be achieved using dragging the white dots. Lab. # 5 - Introduction to Digital Signal Processing 44
Moving the slider for Noise Reduction Level we reduce the mean value of the signal noise Figure 6 Noise Reduction window. Lab. # 5 - Introduction to Digital Signal Processing 45