Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Digital Signal Processing

10003/10095

LAB 1 - Data Collection

Week 5

Instructions

• Attendance of the labs is mandatory and students will be marked accordingly.

• You will need to work in groups of two (2). You will be working with the same lab partner in all the lab sessions.

• Complete Lab tasks during the lab in your group.

• Add proper comments in your code when/where required.

• Use appropriate naming conventions.

• Make sure to save all your .m and .wav files properly. You will be using them in the next lab.

• Make sure all group members have a copy of the .m and .wav files.

• Please use MATLAB versions newer than R2014b.

• Make the most out of the MATLAB documentation before raising your questions to the tutor.

• It is best to create separate script .m files for each task.

• Alternatively, you can use different sections in the script file. To cre-ate a section, go to the Editor or Live Editor tab and in the Section section, click the Section Break button. You also can enter two per-cent signs ( %% ) at the start of the line where you want to begin the new section.

Task 1

In this task, you will practice how to read/play audio signals in MATLAB and get some infor-mation and manipulate it.

You will need to use the following functions in this exercise:

• The MATLAB’s audioread command reads data from an audio file, and returns sam-pled data and a sample rate for that audio signal.

• The MATLAB’a audioplayer is an object that contains properties that enable addi-tional flexibility during playback. For example, you can pause, resume, or define call-backs. Note that the correct sample frequency must be known to play the music correctly. You would also need to use play to play the audio samples in audioplayer object if you want to play back the music.

• The MATLAB’s resample(x,p,q) (Resample uniform or nonuniform data to a new fixed rate) will help you resample the input sequence, x, at p/q times the original sample rate.

Check the documentation of each command for more information, syntax and examples.

For this task, you have been provided with an audio file on Canvas. Download the ”Sample Audio.wav” file, save it in the same directory of your script (.m file) and answer the following questions.

1. Q1.1 What is the sampling frequency of the ”Sample Audio.wav” audio file?

2. Q1.2 What is the number of bits/samples in the ”Sample Audio.wav” audio file?

3. Q1.3 Resample the vector of the given audio file at 2 times the original rate, play it and compare it with the original file.

4. Q1.4 Resample the vector of the given audio file at 2/1 times the original rate, play it and compare it with the original file.

Make sure to use proper comments and save all the .m files for all questions.

Task 2

In this task, you will collect an audio signal of your own voice. You will then use this signal as your data to analyse it in the time and frequency domains throughout all lab sessions. In order to make the signal more realistic, you will record your voice in a noisy environment. To that end, we have provided you with an audio file that you have to play in the background using another device (for example your mobile phone). The Background noise file ”Noise.wav” can be downloaded from Canvas.

Note: Some built-in sound cards in laptops/PCs may not allow you to record your voice and play audio at the same time. Hence, it is safer to use another device to play the background noise while recording your voice.

To ensure the given noise is present in the background throughout the recording, you can try the following:

• Start by setting the volume of the given sound to a moderate level before beginning the recording.

• Start the recording and speak as you normally would while monitoring the audio levels to ensure that your voice is audible and the background noise is not overpowering.

• If the volume of the background noise is too low, increase it until it is audible but not overwhelming.

• If the volume of your voice is too low or the background noise is too high, adjust the levels accordingly.

• Repeat this process until you achieve the desired balance of background noise and voice.

In this part, you will need to use MATLAB’s audiorecorder and audiowrite com-mands. Check the MATLAB documentation. There are plenty of examples of how to use these commands.

For the purpose of this task, you may need to record up to ten (10) seconds worth of data with a sampling frequency of 48000 samples per second, 8 bits and 2 channels. Each group needs to collect one audio signal by saying the following phrase.

Phrase: ”If you can hear this, you are already experiencing Digital Signal Processing magic.

This is <your uni ID>.”.

File Name: ”DSP-<Your Names>.wav”

Note: You only need to collect one audio signal per group.

Note: Once you have finished recording your voice using the audiorecorder, use the audioplayer or sound command in the Command Window to play back the recording and examine its quality. Remember to specify the correct sampling frequency, as it may differ from the default used by the audiorecorder function. To further verify that the recording is functional, open the audio file in a separate media player (outside of MATLAB) and play it. Once you are satisfied with the recording, save your file properly and make sure to keep this file for the next tasks.

Remember that you will be using the same audio file throughout all lab sessions.

Task 3

In this task, you will need to plot your audio signal in MATLAB.

To this end, open your recorded audio file using audioread. Based on the sampling fre-quency you would need to create a time vector and plot your signal with respect to time.

Make sure to add labels on x and y axes as well as a proper title to your plot.

Task 4

In this task, you will add an Echo Effect to your audio signal.

The echo effect is a popular audio processing technique that creates a sense of space and depth in an audio file. It creates a delayed copy of the original sound, creating a sense of repetition and reverberation. This effect allows the user to adjust the delay time and feedback for a desired sound. The echo effect can be used for a variety of purposes, such as adding ambience to a recording or creating a sense of distance in a mix.

The Echo Effect can be applied to a signal using the following equation:

y(n) = x(n) + ax(n − d)

in which, y(n) is the output echoed signal, a is the gain (a.k.a attenuation factor) (0 < a < 1), d is the delay and x(n) is the original signal. Here, the gain specifies how much depth you require.

For this task, use the following parameters:

• a = 0.8

• d = 300ms(0.3s)

Create a function for this task and name it properly with proper Help comments (doc strings). Once you implement the echo effect to your signal, use the audioplayer or sound com-mand in the Command Window to play back the recording and examine the signal. Once confirmed, save the output audio signal to a new file (DSP-<Your Names>-Echoed.wav).

Try changing the gain and delay parameters and comment on your observations.