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

Lab #2

2021

 

0                 0.2                0.4                0.6                0.8                  1                  1.2                1.4                1.6                1.8                 2


sample n                                                                               106

 

Figure 1: Part of the Signal of Korsakov’s Scheherazade: The Tale of Kalender Prince

Background

The objective of this lab is perform signal processing on several audio signals. An audio signal can be viewed as a periodic signal x[n] with the period of length N , where N is the length of the audio file. In this case x[n] represents the audio output at sample n. While in general, an audio signal might be two dimensional if it is stereo audio, in this lab, we assume all audio signals are one dimensional.

In reality, what we hear in real life is a continuous-time signal x(t) where x(t) is the audio-pressure at time t. Let X(jω) be the Fourier Transform of x(t). An interesting fact is that we cannot hear any component of X(jω) for ω > ωu  ≈ .  In other words, we cannot hear any sound component beyond 20kHz. Similarly, we cannot hear components bellow 20Hz.  This region [20 , 20000] is the hearing range of a normal person. The frequency range [20k, o) is called the ultrasound range. The reason that some of the imaging devices/technologies are named ultrasound  is that the high frequency components in ultrasound range are used for imaging purposes in those devices.

In this project, the following MATLAB commands will be useful:

●  [y,Fs] =  audioread(‘filename’) - Reads the audio file at location ‘file- name’ and stores the samples in y and the sampling frequency at Fs.

●  s =  audioplayer(y,Fs) - Creates an ‘audio player object’  s from the sampled data y and sampling frequency Fs.   You can use play(s) or stop(s) to play the audio player object.

● audiowrite(‘filename’,y,Fs) - Creates an audio file with samples from y and sampling frequency Fs.

● fft(y) - Calculates the Fourier series of a discrete-time signal whose de- scription over one period is given by the vector y .

●  [b,a]=cheby1(n,Rp,Wp,type) - Calculates coefficients b and a for a filter described by a difference equation coefficient for an nth order Chebyshev filter. Rp is a parameter that we set to 10 in this project. In this project we let the filter’s order n = 15. Wp is the cutoff frequency (or frequencies) and type determines the filter’s type:  it can be either ’low’, ’bandpass’, ’high’, or ’stop’.

● y =  filter(b,a,x); This applies the constant-coefficient difference equa- tion system:

b[k]y[n - k + 1] + . . . + b[1]y[n] = a[a]x[n - a + 1] + . . . + a[1]x[n]

to input signal x (with zero initial condition) and returns signal y .

Note

● Be careful of the volume of your computer and keep it down while working on this project.

Warm Up

1.  Define a signal y[n] by executing the following lines: FS = 44100;

dt =  1/FS;

t =  0:dt:10;

y =  cos(2*pi*400*t);

Create an audio player object with vector y and sampling frequency FS by running po =  audioplayer(y,FS). Play the audioplayer object by run- ning play(po). What do you hear? Determine the major frequency that you are hearing. Explain your answer. Save the audio under ‘YourName- Tone.mp4 ’ by running audiowrite(‘YourNameTone.mp4 ’,y,Fs).

2.  Using a similar signal as the one defined in the previous part, create a

20 seconds long and (almost) perfect pitch signal, i.e. a perfect sinusoidal signal, with frequency f = 800Hz (or ω = 2π800). Include your code and explain your answer. Save the audio file as ‘YourName800hz.mp4 ’.

Low-Pass-Filtering

● Download the file ‘RussianDanceLPF.mp4 ’ and load it in MATLAB. Cre- ate an audio player object and play the music.  As you can hear, the file contains high frequency noisy components. Plot the absolute value of the signal’s fft, with axis labels. Include the plot in your report.

● Using appropriately chosen cutoff frequency Wp and  cheby1 command design a low-pass-filter that filters out the undesired noise.  You can de- termine the cutoff frequency by visually inspecting the fft of the signal.

● Include your code and describe how you came about to choose the pa- rameters  for your filter.   Using  freqz(b,a) plot the filter’s  frequency response and include it in your report.  Save the filtered song as ‘Your- NamePF.mp4 ’.

Mysterious Noise

●  Caution:  The audio file in this part contains a sharp noise.  Make sure that the sound volume on your computer is set on a low level.

● Download the file ‘Korsakovn.mp4 ’ and play it on your computer. What do you hear?   Load the file in MATLAB. This music  (which is by the way, part of Korsakov’s Scheherezade symphony) is contaminated by a pointed/sharp noise.

● Using visual inspection of the signal’s fft, determine the frequency of the pointed noise. Using MATLAB’s help, explain what filtertype ‘stop’ does in cheby1 command.  Using cheby1 and filtertype ’stop’ design a filter that cancels out the sharp noise with the minimal distortion to the music file. Explain your design process.

● Include your code in your report. Using freqz plot the frequency response of the designed filter and plot it in the report. Save the filtered audio signal as ‘YourNameKorsakov.mp4.’

Submissions

● Please follow the above instructions and type a report that contains the requested codes, figures, and also answers to the posted questions.  Your report can be in word or pdf format. Put all the saved audio files and the report in YourNameLab2.zip