Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord...

27
Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal Speech: f 0 = vocal cord vibration frequency (>=80Hz) Speech signals contain harmonics of 5 KHz or less The upper limit of human hearing is about 22 KHz f s = sampling frequency in measurements per second t s is the sampling period (t s = 1/f s ) x[n] x n = amplitude of the n th signal measurement (sample) X[f] or X f = amplitude of the f th frequency component (bin) X(f) or x(n) = continuous signal frequency and time domains

Transcript of Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord...

Page 1: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Sampling Terminology• f0 is the fundamental frequency (Hz) of the signal

– Speech: f0 = vocal cord vibration frequency (>=80Hz)

– Speech signals contain harmonics of 5 KHz or less– The upper limit of human hearing is about 22 KHz

• fs = sampling frequency in measurements per second

• ts is the sampling period (ts = 1/fs)

• x[n] xn = amplitude of the nth signal measurement (sample)

• X[f] or Xf = amplitude of the fth frequency component (bin)

• X(f) or x(n) = continuous signal frequency and time domains

Page 2: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Quantization

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 3: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Measurements• Terminology

– We normally measure continuous signals at discrete times– Quantization (bits) converts measurements to numeric values– Sample rate (samples per second) = time between measurements

• Measurement error (|measured value - true value|)– Precision: quality of a single measurement

• Half of the least significant digit• Random noise eliminated by averaging many measurements

– Accuracy: quality of the result• Repeat experiment and average the results• Ex: Sample the ocean floor 1000 times to determine the depth.• Poor accuracy indicates poor repeatability or bad calibration

Page 4: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Quantization Errors

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 5: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Quantization errors effect on frequency domain

Time domain quantization errors

Frequency domain

Page 6: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Analog-to-digital Converters (A-D)

• The A-D Conversion process– Converts a stream of varying air pressure into voltages– The A-D converter samples the voltage at regular intervals– Convert each sample to an integer of a fixed bit size

• Insufficient Quantization (Not enough quantization bits)– Different perceived sounds convert to the same value

• Limits of quantization (Signal-to-noise ratio (SNR))– If SNR is small, the lower bits simply measure noise

• Quantization types– Linear: output varies linearly with input– Non-linear: logarithmic conversion from input to output

Quantize continuous signals to streams of discrete integers

Page 7: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Linear Encoding

• Example: Values 0..255 has an 8 bit resolution. – Measurement range: -64 to 63 decibels – Voltage resolution: (27-0)/28 = ½ decibel

The output values relates linearly to the input values

Decibels

Am

plit

ude

Page 8: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Non-linear Encoding Algorithms

• Uses (ex: telephony – voice over distance)– Use limited bandwidth channels– Convert from 12 or 16 -> 8 bits– Logarithmic representation

• Formulae– Mu-law algorithm (North America, Japan)

• μ = 255, x normalized between [-1,1]• -1<=x<=1; y=ln(1+μx) / ln(1+μ)

– A-LAW algorithm (Europe, world wide)• A = 87.6, x normalized between [-1,1]• IF |x|<=1/A; y=Ax/(1+ln A)• IF 1/A<=|x|<=1; y=(1+lnAx)/(1+lnA)

Humans hear sounds up to 120db with a sensitivity of about 1dbTherefore 8 bit samples should be sufficient

Page 9: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Fixed Point Representation

• Advantages– Very fast add, multiply, and subtract operation– Shift operations for extremely fast power of two operations

• Disadvantages– Division operations convert to use floating point circuitry– Cannot represent very large or very small numbers– Represents a fixed range of numbers– Loss of precision during division– Scaling between precisions is very cumbersome

• Example– Scale values 0 to 10.5 using 64 bit integers– The value zero maps to zero.– The value 10.5 maps to 264 -1– The resolution is 10.5 / 265

The decimal point is at a fixed position

Page 10: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Floating Point Representation

• Represents numbers in scientific notation – Decimal: 987.654 = 9.87654 * 102

– Hexadecimal: 89a.bcd = 8.9abcd * 162

– Contains an exponent and a base (mantissa)

• Advantages– A sliding window of precision– Represents an extremely large range of numbers

• Disadvantages– Add, multiply, and subtract operations are slower– Shift operations cannot be used– Holes in the number line

A sliding decimal point according to the size of the number

Page 11: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Floating Point

Formats• Example: Convert 329.390625 to 32 bit floating point

1. Convert to binary: 329 -> 101001001.011001 (256+64+8+1)Fractional portion: 0110010.390626 * 2 = 0.78125 -> 00.78125 * 2 = 1.5625 -> 10.5625 * 2 = 1.125 -> 10.125 * 2 = 0.25 ->00.25 * 2 = 0.5 -> 00.5 * 2 = 1 -> 1 (no fraction left, so we are done)

2. Convert to binary scientific notation: 1.01001001011001 * 28

3. Add the exponent to the bias: 8 + 127 = 135 (10000111)4. Answer: 0 10000111 01001001011001000000000

• Special Values– Zero: Exponent = Fraction = 0– ± Infinity: sign * (Exponent all 1s, faction = 0)– NaN: Exponent all 1s and fraction ≠ 0

Sign Exponent Fraction Bias

Single 1[31] 8[23->30] 23[0-22] 127

Double 1[63] 11[52-62] 52[0-51] 1023

Page 12: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Recommendations forHuman Speech Processing

• Computers are not as good as the human ear• Most humans cannot hear frequencies above 20 kHz.• Human Hearing Sensitivity

– Most speech is encoded in frequencies < 8kHZ– Maximum sensitivity is approximately 22kHZ– Hearing loss occurs at the high end of the range– We are more sensitive to frequencies at the low end of the range – Sensitivity follows a logarithmic curve

• Quantization– Linear: Bits per sample >=12– Non-linear: Bits per sample = 8

• Common audio CD formats: 44.1, 22.05, and 11.025 kHz

Page 13: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Aliasing

• When does this occur?– Frequencies (f>N) present that are above Nyquist Frequency(fN)– If f∆ = f>N – fN, then fN+f∆ is indistinguishable from fN-f∆.

• What do we do about it?– Place an anti-aliasing filter to eliminate high frequencies– This CANNOT be done in software

• Example of aliasing - Take a picture of sun every 23 hours• 24 x 23 = 552 hours between sunrises• Sun appears to move from west to east

Different frequencies become indistinguishable

Page 14: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 15: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

7khz appears as 1khz

4khz appears as -2khz, or 2khz 1800 out of phase

Page 16: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Aliasing and Filtering

Alias is out of phase in this example

Page 17: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 18: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Low Pass Filtered Signal

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 19: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 20: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 21: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Nyquist Theorem

Nyquist Frequency (fN) = highest detectible frequencySampling Frequency (fs) = samples per time periodMaximum Signal Frequency of Interest (fmax)

Theorem: fN = 2 * fmax; fs >= fN

Inadequate Sampling Adequate Sampling

How many cycles per second do we need?

Page 22: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Sampling formulae

0th sample: x0 = sin(2πfX 0ts)

1st sample: x1 = sin(2πfx 1ts)

nth sample: xn = sin(2πfx nts)

Note: Sinewave of (fx+kfs) Hz aliases sinewaves of f0 Hz sin(2πfx nts)

= sin(2πfx nts+2πm) ; where m is any positive or negative integer= sin(2πfxnts+2πm(nts)/(nts)) ; multiply 2nd term by one

= sin(2πnts(fx+m/(nts)) ; we factor 2πnts from both terms

= sin(2πnts(fx+k/ts) ; Let k = m/n ratio

= sin(2πnts(fx+kfs) ; because fs = 1/ts

A sinusoid cycle from 0 to 3600 is equivalent to 2 π radians

Note: fx is some frequency less than the sampling rate fs

Page 23: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Using Carrier Frequencies

Goal: Choose optimal fs > 2B

Page 24: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 25: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Choosing Sampling Frequencies• Goal: Bring band of frequency between –fs and + fs

• Solution: Pick largest m such that fs >= 2*B

• Choosing fs that maintains the spectral direction

m fs = 2 (fc – B/2)

fs = (2 fc – B)/mExample: If fc=20000, B = 5 m=1,2,3,4 Then fs=35,17.5,11.25, 8.75

• Choosing fs that reverses the spectral direction(m+1) fs = 2 (fc + B/2)

fs = (2fc + B)/(m+1)

Example: If fc=20000, B = 5 m=1,2,3 Then fs=22.5,15,7.5

• Restore spectral directionx[n] = (-1)n * x[n]

Page 26: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

Page 27: Sampling Terminology f 0 is the fundamental frequency (Hz) of the signal –Speech: f 0 = vocal cord vibration frequency (>=80Hz) –Speech signals contain.

Understanding Digital Signal Processing, Third Edition, Richard Lyons(0-13-261480-4) © Pearson Education, 2011.

SNR Degradation