This unit is concerned with the representation and measurement of signals as digital waveforms: specifically with sampling, quantisation, the measurement of energy and the generation of sine and noise signals.
When you have worked through this unit you should:
· understand the concept of sampling
· know the limits to the setting of sampling frequency
· be able to state the sampling theorem
· be able to explain how and why aliasing occurs
· understand the concept of quantisation
· be able to explain the origin of quantisation noise
· understand how sinewaves and noise waveforms can be generated by a program
· have tried to create programs to build and replay waveforms to specification
Sampling is the process whereby an analogue signal (continuous in time and continuous in value) is converted to a series of impulses of a size equal to the amplitude of the signal at regularly spaced instants of time. Related ideas are the sample period (T): the time between samples expressed in seconds, and sampling frequency (Fs=1/T): the number of samples taken per second of signal, usually expressed in units of samples per second or less accurately and more commonly in hertz (Hz).
Quantisation is the process of converting the sampled analogue signal (discrete-time continuous value) into impulses of discrete values of amplitude (analogous to the conversion from 'floating-point' values to 'integer' values in a program). Related ideas are quantisation error: the error in amplitude estimate introduced by quantisation, and quantisation noise: the noise introduced into a quantised signal by the approximation of the quantisation to the real analogue values. The most common forms of quantisation are linear and produce a binary code conveniently described in terms of numbers of bits. Each bit approximates to 6dB of additional signal/noise improvement. However, non-linear quantisation schemes are also used, primarily in telecommunication systems to make the best use of available capacity. In a logarithmic quantisation scheme, the amplitude levels are further apart at large amplitudes and closer at smaller amplitudes, thereby giving a quantisation error which is proportional to the size of the signal at that instant.
The sampling theorem (of Nyquist and Shannon) states that a signal which has a highest frequency component of f Hz must be sampled at a rate of at least 2f Hz if the signal is to be faithfully reconstructed from the digital samples. The consequence of not following the sampling theorem is aliasing, whereby the spectral components above f Hz are 'mapped' down to the frequency region 0..f Hz by the sampling process thereby distorting the representation. To prevent aliasing a pre-sampling or anti-aliasing filter is used to remove spectral components above half the sampling frequency; this is usually implemented as a low-pass filter of high order, with a corner frequency a little less than half the sampling frequency. A similar low-pass reconstruction filter is also used in digital-to-analogue conversion, to rebuild the analogue waveform from the digital samples in the frequency region 0..f Hz only.
To demonstrate formally that a sampled signal has many possible aliases as continuous waveforms, consider the sampled sinusoid:
where W controls the frequency of the sinusoid (there are 2p/W samples per period). Consider the sequence y1[n] obtained by increasing W by 2p:
In other words, the same sequence as x[n]. Similarly the sequence y2[n] given by:
is also identical with x[n].
The value W is just the angular change per sample, expressed in radians. To convert this to a basis in time, we set W = wT, where T is the sample interval, and w is the angular frequency expressed in radians per second. w is related to conventional frequency f (in hertz) by w = 2pf. When f = Fs, then W = 2p. From this we can see that the aliases of a sinusoid at a frequency f are just mFs+f and mFs–f, (m is some integer), since:
The total energy in a digital waveform is simply the sum of the squared amplitude values, the average energy is the total energy divided by the number of samples, and the r.m.s. amplitude is the square root of the average energy. For a sine wave, the r.m.s. amplitude is just the peak amplitude/Ö2.
Sinewaves can be constructed from the sin() function provided in the ‘C’ language. Noise signals can be generated through the use of the 'C' function random().
Algorithm 3.1 Sampling a sinusoid
Algorithm 3.2 Quantisation
Algorithm 3.3 Sampling a noise signal
Rosen & Howell, Signals and Systems for Speech and Hearing, Chapter 14.
Meade & Dillon, Signals and Systems, Chapter 1.
Lynn & Fuerst, Introductory Digital Signal Processing, Sections 1.1-1.4.
Orfanidis, Introduction to Signal Processing, 1.1-1.4.
Example 3.1 Demonstrate Sampling and Quantisation
Example 3.2 Demonstrate noise signal generation and replay
3.1 Use example program 3.1 to construct a program to display 1s of a sinewave signal of 25Hz sampled at 1,000 samples per second.
3.2 Adapt your program from exercise 3.1 to display a sine signal that increases linearly in frequency from 10Hz to 50Hz over an interval of 1 second.
3.3 Adapt your program from exercise 3.1 to construct and display 1s of a 10Hz square wave made up from the sum of 16 odd harmonics. The relative amplitude of the nth harmonic is given by 1/n, i.e. H1 + 0.33H3 + 0.2H5 + …, or