6. The Time Dimension I: Sampling 6.1 Frequency Spectrum All signals which are continuous functions of time have a frequency spectrum. This is essentially a representation of the signal in terms of its rate of change with time, i.e. the speed with which its time profile or morphology changes. Any periodic function of time, i.e. one which has a repetitive or cyclical nature consists of frequency components that are integral multiples of the rate of repetition of the signal. This is known as the frequency spectrum of the signal. An example of this is shown below in Fig. 6.1. V V ↔ …. 0 fR 2fR 3fR 4fR 5fR 6fR t f T = 1/fR Fig. 6.1 The Frequency Spectrum of a Periodic Signal Fourier Series The theory behind Fourier’s Series states that any periodic signal can be represented as a summation of sinusoidal components at the fundamental frequency of repetition of the signal and harmonics of this frequency. The magnitudes of the individual components can be calculated mathematically if a mathematical description of the signal in time is available. Consider the bipolar square wave shown in Fig 6.2 below. This is a symmetrical periodic waveform which has an amplitude of +A Volts for the first half of the cycle time from t = 0 until t = T/2 and an amplitude of –A Volts for the second half of the cycle from t = T/2 until t = T. 1 The waveform is described as a function of time as: f(t) A f(t) = { A, 0 < t ≤ T/2 { -A, T/2 < t ≤ T T/2 0 T 0 -A T Fig. 6.2 The Time Profile of a Bipolar Square Wave The Fouier Series is given as: f(t) 4 1 1 A[Sin2 ft Sin2 3ft Sin2 5ft ............] 3 5 Fig. 6.3 Partial Fourier Components of a Bipolar Square Wave 2 t The Fourier series of a square wave only has odd harmonic components. Fig. 6.3 shows the first three Fourier components of the square wave as well as their summation. The summation bears a reasonably close resemblance to the original square wave but it can be seen that there is some oscillatory variation around the pulse amplitude due to the finite number of components summed. If more components are added, the waveform becomes increasingly more close to the ideal square wave as can be seen from Fig. 6.4. Fig. 6.4 Varying Numbers of Harmonic Components in the Fourier Series 3 Usually the components at higher frequencies have lower magnitudes than those at lower frequencies so that the amount of energy in the spectrum decreases with increasing frequency. This means that in general the higher frequency components contribute much less to the overall signal profile than the lower frequency components. However, they do influence small local changes taking place in a short time span. When a signal is a continuous function of time but is not a periodic or recurrent function, it still has a frequency spectrum. However, the frequency spectrum is not composed of defined harmonic frequencies but rather has all frequencies present, usually up to some maximum frequency of interest, fM, as seen in Fig. 6.5. The magnitudes of components at different frequencies are continuously varying, as are any harmonic relationships present. Consequently, the spectrum is simply shown as a continuous shaded spectrum, up to the maximum frequency of interest. This is referred to as the Baseband Spectrum. The shape of the spectrum shown in Fig. 6.5 is arbitrary as this varies with time and is only for illustrative purposes. V V ↔ t 0 fM f Fig. 6.5 The Frequency Spectrum of a Non-Periodic Signal Bandlimiting: In practice, the higher frequency components in a spectrum at low amplitudes tend to get contaminated by noise and do not really contribute much information to the signal. Consequently, they can be omitted without loss of information while at the same time reducing the amount of noise present in the signal. In Analogue-to–digital conversion the highest frequency present is deliberately limited to a maximum, a process known as bandlimiting. 4 This is done so that the highest frequency present can be guaranteed not to exceed a specified maximum limit. Bandlimiting is accomplished in practice by passing the baseband signal through a low-pass filter which ideally passes frequency components below its cut-off frequency, set to fM, and suppresses all components above this frequency. 6.2 The Principle of Sampling Introduction: The discussion up to this point has centred on the particular value of a signal, its quantisation and encoding into binary form, and the issues of accuracy and resolution surrounding this. Changes in the signal voltage have only been considered in absolute terms and not as changes with time. In the real world all signals, and in particular electrical ones are functions of time, i.e. they are time varying as shown in Fig. 6.6. Moreover, in the real world every process takes time to achieve and this applies to data conversion also. This means that the quantisation of any signal value and its encoding into binary form takes a finite amount of time to accomplish. It cannot be done instantaneously. This means that, just as we cannot quantise the signal amplitude with infinite resolution of its magnitude, we cannot convert the signal with infinite resolution in time either. It can only be converted by taking samples of the signal, usually at regular intervals in time, i.e. at a fixed finite rate. Relative Amplitude Time Fig 6.6 A Continuous Signal as a Function of Time 5 Sampling: This leads to the concept of sampling, where the absolute value of the signal voltage is sampled at regular intervals in time, nTS , as shown in Fig. 6.7. The time in between samples is then used to encode the samples into binary form and store or transmit them. The sampling process results essentially in series of sample values which are updated at a regular rate as shown in Fig. 6.8. Voltage 0 TS 2TS 3TS 4TS 5TS 6TS 7TS 8TS Time Fig 6.7 Sampling of a Continuous Time Signal Voltage 0 TS 2TS 3TS 4TS 5TS 6TS 7TS Fig. 6.8 The Result of the Sampling Process 6 8TS Time The Sampling Theorem: The Sampling Theorem, originally proposed by Nyquist, states that: ‘All of the information present in a time varying signal is contained within samples of the signal taken at regular intervals in time at a rate which is greater than or equal to twice the highest frequency component contained within the spectrum of the signal.’ That is, if a signal which is a function of time, f(t), is bandlimited to contain a maximum frequency component of fM , then all of the information present in the signal can be recovered from samples of the signal taken at a frequency fS , where: fS 2fM The frequency fS is known as the Sampling Frequency and a value of this frequency of fS = 2fM is known as the Nyquist Sampling Rate. It can be seen in Fig. 6.9 below that if there are at least two samples per cycle of the highest frequency component present in the signal, this is sufficient to characterise and later recover this component. If the sampling frequency is exactly equal to twice the highest frequency present then there is a danger that the samples could be synchronised with the zero crossing points of this component and would give a sample value of zero. In order to prevent this happening, the sampling rate is normally made a little higher than the theoretical Nyquist rate, so that the sampling process is not synchronised with any of the frequency components present in the signal. V sinewave at highest frequency present in the waveform sampled at Nyquist rate V 0 recovered sinewave at highest frequency present 0 t t Fig. 6.9 Sampling the Highest Frequency Component at the Nyquist Rate 7 Sampled Signal Spectrum: When a signal is sampled at a rate or frequency of fS ≥ 2fM, then the frequency spectrum of the sampled signal contains the original baseband signal spectrum and images of this spectrum symmetrically located about harmonics of the sampling frequency as shown in Fig. 6.10. V V baseband spectrum image spectrum ↔ t TS = 1/fS Fig. 6.10 0 fM fS-fM fS fS+fM 2fS-fM 2fS 2fS+fM f Frequency Spectrum of a Sampled Signal Aliasing: If the signal is sampled at a rate which is less than the Nyquist rate, i.e. fS < 2fM, which means that fS - fM < fM, then this results in an overlap of the image spectra as shown in Fig. 6.11 and Fig. 6.12 below. This results in distortion of the recovered signal known as Aliasing Distortion so that the time profile of the recovered signal is different from the original input signal which was digitised. V V ↔ t TS = 1/fS Fig. 6.11 0 fS-fM fM fS 2fS-fM fS+fM 2fS 2fS+fM …. f Aliasing Distortion Due to Overlap of Spectra aliasing distortion V Fig. 6.12 Overlap of Baseband and Image Spectra 8 T i m e 6.3 Aliasing Distortion Speech: The following examples are samples of speech all quantised with 8 bits resolution but varying sampling frequencies relative to the Nyquist rate where the phrase spoken is: ‘The possibility of a Mann Act conviction, resulting in disbarment proceedings and total loss of his livelihood, was a key factor in his decision‘. Speech sampled at Nyquist Rate: Speech-Mann Act 22.05kHz.wav Speech sampled at 1/2 Nyquist Rate: Speech-Mann Act 11.025kHz.wav Speech sampled at 1/4 Nyquist Rate: Speech-Mann Act 5.5125kHz.wav Speech sampled at 1/8 Nyquist Rate: Speech-Mann Act 2.75kHz.wav The following examples are samples of speech where the phrase spoken is: ‘Rimmer I’m bored…... Bored?, This is essential routine maintenance. It’s absolutely vital for the well-being of this crew, this mission and this ship……. Dispenser 172 – Chicken Soup nozzle clogged!’. Speech sampled at Nyquist Rate: Speech-Red Dwarf 22.05kHz.wav Speech sampled 1/2 Nyquist Rate: Speech-Red Dwarf 11.025kHz.wav Speech sampled 1/4 Nyquist Rate: Speech-Red Dwarf 5.5125kHz.wav Speech sampled at 1/8 Nyquist Rate: Speech-Red Dwarf 2.75kHz.wav As can be heard the speech becomes more distorted the more the Nyquist sampling rate is infringed and the greater the amount of aliasing present. However, the nature of the distortion is different than that produced by low quantisation resolution. It affects intelligibility much more directly because it alters the relative magnitudes of frequency components. This begins at the higher end of the frequency spectrum but works downwards as the sampling frequency is lowered. However, there is more to intelligibility than simply quantisation resolution. See: http://www.youtube.com/watch?v=-V2MfBoBiyw 9 Music: Note that in the following examples the Nyquist rate is higher than in the speech samples because of the wider baseband spectrum. Music at Nyquist Rate: Music-Eleanor Rigby 44.1kHz.wav Music at 1/2 Nyquist Rate: Music-Eleanor Rigby 22.05kHz.wav Music at 1/4 Nyquist Rate: Music-Eleanor Rigby 11.025kHz.wav Music at 1/8 Nyquist Rate: Music-Eleanor Rigby 5.5125kHz.wav Music at 1/16 Nyquist Rate: Music-Eleanor Rigby 2.75kHz.wav As with quantisation resolution, music signals are much more sensitive to the effects of aliasing. This is again because there is much more energy in a music signal at higher frequencies than is the case in a speech signal. The higher frequency energy defines subtle changes in the signal which affect the harmonic quality of what is heard and is appealing to the listener in a musical context. Therefore a lesser infringement of the Nyquist sampling rate has a more perceptible and disagreeable effect than in the case of speech. 10