Vous êtes sur la page 1sur 4

DIGITAL SIGNAL PROCESSING

Lab Session 3: Audio Processing. Objective Audio Processing Basics in MATLAB To study effect of adding noise to any voice signal.

Load a voice file already present in MATLAB using the following command: >>load mtlb You may play the file using the soundsc function. How many voice samples are contained in the mtlb file? 4001

Create a random row vector of the same size as the mtlb signal above using the randn function. Now add the two vectors (the one generated using the randn function and the one obtained using mtlb). The sum of these two signals is the corrupted signal. Plot all the signals obtained, your plot should show the uncorrupted signal; the noise vector generated using randn function and the corrupted signal. Write code in the space provided below. (you might want to hear and compare sound quality)

Code & Figure: load mtlb; soundsc(mtlb); x=mtlb; z=randn(size(x)); [y,n]=sigadd(x,z,size(x),size(z)); subplot(311),plot(n,x) subplot(312),plot(n,z) subplot(313),plot(n,y) soundsc(y);

-5 5

500

1000

1500

2000

2500

3000

3500

4000

4500

-5 5

500

1000

1500

2000

2500

3000

3500

4000

4500

-5

500

1000

1500

2000

2500

3000

3500

4000

4500

Sinusoidal Sequence: Plot the following functions in a plot of 3x3 subplots:

f(t) = exp(k*t) * sin(2*PI*f*t) t = [0, 1] in steps of 0.0001 k = -3, 0, 3 f = 1, 3, 6 Hz


Code: a=1; t = [0:0.0001:1]; %in steps of 0.0001 fl=[1 3 6]; kl=[-3:3:3]; for f=[1 3 6] for k=-3:3:3 func=exp(k*t).*sin(2*pi*f*t); subplot(length(kl),length(fl),a),plot(t,func); a=a+1; end end

Figure:

1 0.5

10 0

0 0 -0.5 1 0.5 0 0 -0.5 1 0 0.5 1 -1 1 0 0.5 1 -10 -20 20 0 0.5 1 0 0.5 1 -1 1 0 0.5 1 -10 -20 10 0 0 0.5 1

-1

0.5

-1

0.5

-20

0.5

Use the soundsc function in MATLAB to hear the tones produced by each function. Describe the relation of the intensity and pitch of the tones to the amplitude and frequency of the function. Intensity of the function is increased by increasing amplitude of the function and vice versa. Pitch of the function is increased by increasing frequency of the function and vice versa.

The echo, y(n), of a discrete signal, x(n), of length N, may be modeled as a repeated and scaled version of the original signal. Write a function that generates an echo of an argument signal, with the repeated signal scaled down by an argument factor.

function y = echogen (x, u, n) % Generates an echoing version of input signal % x : original signal % u : scaling factor of the intensity of each % repeated signal: the intensity of i-th % (1 <= i <= n) repeated signal is % (u^i)*x(m), where 1 <= m <= length(x) % n : number of repetitions of the original signal % in the echo; thus, for an echo, n >= 1

[r c] = size(x); if r ~= 1 x = x'; end y=x; for i=1:n y=[y (u^i)*x]; end

Test you code using the command: >> soundsc (echogen(mtlb, 0.6, 8))

Vous aimerez peut-être aussi