4510&4488 DspLab 3

Embed Size (px)

Citation preview

  • 8/2/2019 4510&4488 DspLab 3

    1/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 mayplay 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 andcompare 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);

  • 8/2/2019 4510&4488 DspLab 3

    2/4

    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:3func=exp(k*t).*sin(2*pi*f*t);

    subplot(length(kl),length(fl),a),plot(t,func);

    a=a+1;

    end

    end

    0 500 1000 1500 2000 2500 3000 3500 4000 4500-5

    0

    5

    0 500 1000 1500 2000 2500 3000 3500 4000 4500-5

    0

    5

    0 500 1000 1500 2000 2500 3000 3500 4000 4500-5

    0

    5

  • 8/2/2019 4510&4488 DspLab 3

    3/4

    Figure:

    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 lengthN, may be modeled as a repeated and scaled

    version of the original signal. Write a function that generates an echo of an argument signal, withthe repeated signal scaled down by an argument factor.

    0 0.5 1-0.5

    0

    0.5

    1

    0 0.5 1-1

    0

    1

    0 0.5 1-20

    -10

    0

    10

    0 0.5 1-0.5

    0

    0.5

    1

    0 0.5 1-1

    0

    1

    0 0.5 1-20

    -10

    0

    10

    0 0.5 1-1

    0

    1

    0 0.5 1-1

    0

    1

    0 0.5 1-20

    0

    20

  • 8/2/2019 4510&4488 DspLab 3

    4/4

    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