TX00CQ31 –Digital Signal Processing

Study 3: Signal Spectrum


Number

Questions

Write your answer in this column

Hints

Q1

Generate a sine wave sample with

  • Amplitude 1
  • Signal frequency 8000/2^(960 % 5 + 3) Hz (’%’ is a remainder operator)
  • Sampling rate 8000 s-1
  • Sample length 212 samples
  • Signal to noise level  +50 dB

Commands:

amplitude = 1;

signal_frequency = 8000/(2^3);

sampling_rate = 8000;

sample_length = 2^12;

SNR = 50;

tt = (0:sample_length-1) / sampling_rate;

sine_wave = amplitude*sin(2*pi*signal_frequency*tt);

Psignal = var(sine_wave);

Pnoise = Psignal/(10^(SNR/10));

noise = randn(size(sine_wave))*sqrt(Pnoise);

ssn = sine_wave + noise;

Signal to noise level:
   SNR = 10*log10(Psignal/Pnoise)

Total power of signal (or noise)  is proportional to the  variance of the signal (or noise)... therefore, calculate the variance!

Frequency need to be selected in this way so that it contains integer number of cycles in order to avoid spectral leakage.

Q2

Use Fourier Transformation to generate the power spectrum of the previous sample:

  • Use frequency [0-Fn] in horizontal axis
  • Use decibels in vertical axis
stem plot

Explain why the signal level in spectrum seems higher than approx. 83 dB compared to the noise level.

Due to processing gain: compromisation on time to gain precision.

spk.m

Q3

Simulate gain and distorion on the sinusoid signal of Q1 to produce a saturated sine wave:

  • Gain = 60 + 2
  • Distortion at amplitude level of 1

Generate the power spectrum of this sample and compare it with the spectrum in Q2.

Commands:

ssn62 = ssn * 62;

ssn62(ssn62 > 1) = 1;

ssn62(ssn62 < -1) = -1;

stem plot
  

Explain the main differences of the power spectra in this and previous case.

The signal has been amplified by 62, thus the output is more pronounce with samples that had greater values originally. The signals that were exceeding the max limit or not fulfilling the minimum limit were clipped off. Due to clipping the signal to noise ratio has lowered. The db range has been shifted. 3000: odd harmonic (If the clipping is symmetric, there is only odd harmonics.).

max, min, ones

Q4

Produce a one second long sound sample where

  • signal frequency increases linearly in time from 100Hz to 200Hz in one second.
  • signal amplitude decreases exponentially with time constant of 0.2 s
  • maximum amplitude is 1
  • add white noise with standard deviation of 0.02
  • sampling rate is 960*10 s-1

Commands:

duration = 1;

sampling_rate = 9600;

t=0:1/sampling_rate:1-(1/sampling_rate);

frequency_start = 100;

frequency_end = 200;

y = chirp(t,frequency_start,duration,frequency_end,'linear');

time_constant = 0.2;

amplitude = exp(-t/time_constant);

white_noise = 0.02 * randn(size(t));

signal = amplitude .* y + white_noise;

signal = signal / max(abs(signal));

sound(signal,sampling_rate);

chirp

Q5

Generate a spectrogram of the previous sample. Use frequency in Hz as your vertical axis and time in second as your horizontal axis.

stem plot

specgram(s,128,fs)

Q6

Generate separate pulses of duration 4ms, 8ms and 16ms when the sampling frequency is 1 Mhz. Then evaluate the spectrum of those pulses in one figure. How the pulse width and its spectral content are related?

The shorter the pulse duration, the larger the spectrum is.

stem plot

spk.m, hold on, hold off