Upcoming SlideShare
×

# Sampling + Quantation

2,162 views
2,045 views

Published on

Visit us at - http://www.themusicespionage.co.uk/

2 Likes
Statistics
Notes
• Full Name
Comment goes here.

Are you sure you want to Yes No
• Be the first to comment

Views
Total views
2,162
On SlideShare
0
From Embeds
0
Number of Embeds
683
Actions
Shares
0
2
0
Likes
2
Embeds 0
No embeds

No notes for slide

### Sampling + Quantation

1. 1. The Music Espionage: Sampling + QuanisationNotes for Digital AudioSamplingAn analogue audio signal is a time-continuous electrical waveform, and the analogue-to-digitalconverters task is to turn this signal into a time-discrete sequence of binary numbers. The samplingprocess employed in an A/D converter involves the measurement or sampling of the amplitude ofthe audio waveform at regular intervals in time. The sample pulses represent the instantaneousamplitudes of the signal at each point in time. The samples can be considered as like instantaneousstill frames of the audio signal which together and in sequence form a representation of thecontinuous waveform rather as the still frames which make up a movie film give the impression ofa continuously moving picture when played in quick succession.In order to represent the fine detail of the signal it is necessary to take a large number of thesesamples per second, and the mathematical sampling theorem proposed by Shannon indicates that atleast two samples must be taken per audio cycle if the necessary information about the signal is tobe conveyed.A way of visualising the sampling process is to consider it in terms of modulation, as shown inFigure 2.4. 1
2. 2. The Music Espionage: Sampling + QuanisationThe continuous audio waveform is used to modulate a regular chain of pulses. The frequency ofthese pulses is the sampling frequency. Before modulation, all these pulses have the sameamplitude (height), but after modulation the amplitude of the pulses is modified according to theinstantaneous amplitude of the audio signal at that point in time. This process is pulse amplitudemodulation (PAM). The frequency spectrum of the modulated signal is as shown in Figure 2.5.It will be seen that in addition to the baseband audio signal (the original spectrum beforesampling) there are now a number of additional spectra, each centred on multiples of the samplingfrequency. Sidebands have been produced either side of the sampling frequency and its multiples,as a result of the amplitude modulation, and these extend above and below the sampling frequencyand its multiples to the extent of the base bandwidth. In other words these sidebands are pairs ofmirror images of the audio band. 2
3. 3. The Music Espionage: Sampling + QuanisationFiltering and AliasingIt is relatively easy to see why the sampling frequency must be at least twice the highest basebandaudio frequency from Figure 2.6.It can be seen that an extension of the baseband above the Nyquist frequency results in the lowersideband of the first spectral repetition overlapping the upper end of the baseband. Two furtherexamples are shown to illustrate the point - the first in which a baseband tone has a low enoughfrequency for the sampled sidebands to lie above the audio frequency range, and the second inwhich a much higher frequency tone causes the lower sampled sideband to fall well within thebaseband, forming an alias of the original tone.The aliasing phenomenon can be seen in the case of the well- known spoked-wheel effect on films,since moving pictures are also an example of a sampled signal. In film, still pictures (imagesamples) are normally taken at a rate of 24 per second. If a rotating wheel with a marker on it isfilmed it will appear to move round in a forward direction as long as the rate of rotation is muchslower than the rate of the still photographs, but as its rotation rate increases it will appear to slowdown, stop, and then appear to start moving backwards. 3
4. 4. The Music Espionage: Sampling + QuanisationThe virtual impression of backwards motion gets faster as the rate of rotation of the wheel getsfaster, and this backwards motion is the aliased result of sampling at too low a rate. Clearly thewheel is not really rotating backwards; it just appears to be.If audio signals are allowed to alias in digital recording one hears the audible equivalent of thebackwards-rotating wheel frequency as the original frequency of the signal increases. In basicconverters, therefore, it is necessary to filter the baseband audio signal before the sampling process,as shown in Figure 2.7, so as to remove any components having a frequency higher than half thesampling frequency (known as the Nyquist frequency).In real systems, and because filters are not perfect, the sampling frequency is made slightly higherthan twice the highest audio frequency to be represented, allowing for the filter to roll off slightlymore gently. The filters incorporated into both D/A and A/D converters have a pronounced effecton sound quality, since they determine the linearity of the frequency response within the audioband, the slope with which it rolls off at high frequency, and the phase linearity of the system.The filter must reject all signals above half the sampling frequency with an attenuation of at least80 dB. Steep filters tend to have erratic phase response at high frequencies, and may exhibitringing due to the high Q of the filter. 4
5. 5. The Music Espionage: Sampling + QuanisationQuantisationAfter sampling, the modulated pulse chain is quantised. In quantising a sampled signal the range ofsample amplitudes is mapped onto a scale of stepped values, as shown in Figure 2.8.The quantiser determines which of a fixed number of quantising intervals (of size Q) each samplelies within, and then assigns it a value which represents the mid-point of that interval. This is donein order that each sample amplitude can be represented by a unique binary number in pulse codemodulation (PCM). In linear quantising each quantising step represents an equal increment of nsignal voltage, and in a binary system the number of quantising steps is equal to 2 where n is thenumber of bits in the binary words used to represent each sample. Consequently, a 4-bit quantiseroffers only 24 (16) quantising levels, whereas a 16-bit quantiser offers a much larger 216 or 65, 536levels and a 20-bit quantiser provides 220 or 1,048,576 levelsClearly an error is involved in quantisation, since there are only a limited number of discrete levelsavailable to represent the amplitude of the signal at any time. The error size will be a maximum ofplus or minus half the amplitude of one quantising step, and a greater number of bits per samplewill therefore result in a smaller error (see Figure 2.9). 5
6. 6. The Music Espionage: Sampling + Quanisation 6
7. 7. The Music Espionage: Sampling + QuanisationAudible effects of sample resolutionThe quantising error may be considered as an unwanted signal added to the wanted signal, asshown in Figure 2.12.Unwanted signals tend to be classified either as distortion or noise, depending on theircharacteristics, and the nature of the quantising error signal depends very much upon the level andnature of the related audio signal.If we consider a very low level sine wave signal, sampled then quantised, having a level only justsufficient to turn the least significant bit of the quantiser on and off at its peak (see Figure 2.13(a)).Such a signal would have a quantising error that was periodic, and strongly correlated with thesignal, resulting in harmonic distortion, notice these are odd harmonics. 7
8. 8. The Music Espionage: Sampling + Quanisation 8
9. 9. The Music Espionage: Sampling + QuanisationFigure 2.13(b) shows the frequency spectrum, analysed in the digital domain of such a signal,showing clearly the distortion products in addition to the original fundamental.Once the signal falls below the level at which it just turned on the least significant bit (LSB) therewould be no modulation. The audible result, therefore, of fading a signal down to silence would bethat of an increasingly distorted signal suddenly disappearing.As the signal level rises the quantising error, still with a maximum value of + or - 0.5Q, becomesincreasingly small as a proportion of the total signal level and the error gradually loses itscorrelation with the signal.Consider now a music signal of reasonably high level. Such a signal has widely varying amplitudeand spectral characteristics and consequently the quantising error is likely to have a random nature.In other words it will be more noise-like than distortion-like, hence the term quantising noise whichis often used to describe the audible effect of quantising error.An analysis of the power of the quantising error, assuming that it has a noise-like nature, shows thatit has an r.m.s. amplitude of Q/√12 where Q is the voltage increment represented by one quantisinginterval.Consequently the signal-to-noise (S/N) ratio of an ideal n bit quantised signal can be shown to be:6.02n + l.76dBThis implies a theoretical S/N ratio which approximates to just over 6 dB per bit.So, a 16-bit converter might be expected to exhibit an S/N ratio of around 98 dB, and an 8-bitconverter around 50 dB.If a converter is undithered there will only be quantising noise when a signal is present, but therewill be no low-level noise floor in the absence of a signal. 9
10. 10. The Music Espionage: Sampling + QuanisationUse of ditherThe use of dither in an ADC conversion, and in conversion between one sample resolution andanother, turns quantising distortion into a random, noise-like signal. This is desirable for a numberof reasons.1) Because white noise at very low level is less subjectively annoying than distortion2) Because it allows signals to be faded smoothly down to silence without the suddendisappearance noted above3) Because it often allows signals to be reconstructed even when their level is below the noise floorof the systemUndithered audio signals may begin to sound grainy and distorted as the signal level falls.Low-level hiss will disappear if dither is switched off, making a system seem quieter, but it isnormally considered that a small amount of continuous hiss is vastly preferable to low leveldistortion. 10
11. 11. The Music Espionage: Sampling + QuanisationHow then does dither perform the seemingly remarkable task of removing quantisingdistortion?Dithering a converter involves the addition of a very low-level signal to the audio. The dither signalis usually noise, but may also be a waveform at half the sampling frequency, or a combination ofthe two.It was stated above that the distortion was a result of the correlation between the signal and thequantising error, making the error periodic and subjectively annoying.Adding noise, which is a random signal, has the effect of randomising the quantising error andmaking it noise-like as well (shown in Figure 2.14 (a) and (b)).If the noise has amplitude similar in level to the LSB (in other words, one quantising step) then asignal lying exactly at the decision point between one quantising interval and the next may bequantised either upwards or downwards, depending on the instantaneous level of the dither noiseadded to it.Over time this random effect is averaged, leading to a noise-like quantising error and a fixed noisefloor in the system.Figure 2.15(a) shows the same low-level sine wave as in Figure 2.13, but this time with dither noiseadded. 11
12. 12. The Music Espionage: Sampling + Quanisation 12
13. 13. The Music Espionage: Sampling + QuanisationThe quantised signal retains the cyclical pattern of the 1 kHz sine wave but is now modulated muchmore frequently between states, and a random element has been added.The frequency spectrum of this signal, Figure 2.15(b), shows a single sine wave componentaccompanied by a flat noise floor.Figure 2.15(c) and (d) show the waveform and spectrum of a dithered sine wave at a level whichwould be impossible to represent in an undithered 16-bit system. 13
14. 14. The Music Espionage: Sampling + Quanisation 14
15. 15. The Music Espionage: Sampling + QuanisationThe LSB is in the zero state much more frequently, but an element of the original 1 kHz period canstill be seen in its modulation pattern if studied carefully.When this is passed through a DAC and reconstruction filter the result is a pure sine wave signalplus noise, as can be seen from the spectrum analysis.Dither is also used in digital processing devices such as mixers and sound processors, but in suchcases it is introduced in the digital domain as a random number sequence (which is the digitalequivalent of white noise).In this context it is generally used to optimise the conversion from high resolution to lowerresolution during post-production. 15