Академический Документы
Профессиональный Документы
Культура Документы
Sampling Theory
1.1 Introduction
Samples are successive snapshots of a signal. In the case of audio, the
signal is a sound wave. A microphone converts the acoustic signal into
a corresponding analog electric signal, and an analog-to-digital converter
transforms that analog signal into a sampled digital form. The accuracy
of the digital approximation of the analog signal depends on its resolution
in time (the sampling rate) and its quantisation, or resolution in amplitude
(the number of bits used to represent each sample). For example, the audio
recorded for storage on compact discs is sampled 44 100 times per second
and represented with 16 bits per sample.
put low-pass filter. The calculation of the output signal using a difference
equation requires a multiply and accumulate operation. This is typically a
single-cycle instruction on DSP chips.
u System Clock
We use the term sample to refer to a single output value from an A/D
converter, i.e., a small integer number (usually 8 or 16 bits). Audio data
is characterized by the following parameters, which correspond to settings
of the A/D converter when the data was recorded. Naturally, the same
settings must be used to play the data.
rates are always measured per channel, so for stereo data recorded a t 8000
sampIes/sec, there are actually 16000 samples in a second.
Some sampling rates are more popular than others, for various reasons.
Some recording hardware is restricted t o (approximations of) some of these
rates, some playback hardware has direct support for some. The popularity
of divisors of common rates can be explained by the simplicity of clock
frequency dividing circuits.
Samples/sec Description
----------- -----------
8000 Exactly 8000 samples/sec is a telephony standard
that goes together with U-LAW (and also A-LAW)
encoding. Some systems use an slightly different
rate.
Files samples on SoundBlaster hardware have sampling rates that are divi-
sors of 1000000.
r a t e (samp/sec) s t y l e mono/stereo
such that
S,(iw) =0
for
w 2 27rW
then the analog signal sa(t) can be reconstructed from its sampled version
if
T 1 1/2W.
The quantity W is called the Nyquist frequency. We can reconstruct the
analog signal using (Shannon's series or cardinal series)
where
fs = 1/T
is the sampling frequency and t the continuous time. The series converges
both uniformly and in the mean-square sense.
Thus the function sa(t) will be represented digitally without any loss of
information as long as sampling occurs in accordance with the Nyquist
criteria. Often one introduces the short-cut notation
The information about the signal sa(t) a t any given time t # nT is dis-
tributed among all discrete samples s ( n ) with appropriate weights. We are
never presented with an infinite discrete time sequence and are therefore
forced to perform the summation over a finite range. This is equivalent
to a loss of information about the function sa(t) not only before and after
our time window (which is understandable), but also a t the time points
between the sampling points. This can introduce errors into the process of
reconstructing the function s,(t). For example, if
the analog signal image centred at 21rlT overlaps into the base band im-
age. The distortion caused by high frequencies overlapping low frequencies
is called aliasing. To avoid aliasing distortion, either the input analog sig-
nal has to be band limited t o a maximum of half the sampling frequency,
or the sampling frequency has to be increased to a t least twice the highest
frequency in the analog signal.
The sampling theorem can be extended to two and higher dimensions. For
1.3. LAGRANGE SAMPLING THEOREM
(
xsinc 2nw1 xl ( - zl))
- sine (Saw2(x2 - z)) .
The sampling theorem can also be extended to sampling lattices other than
rectangular lattices, for example, hexagonal lattice.
where
An = n .
we finally arrive at
n=cu
sin(,(" - n))
n=-00
1.4 Application
The following Java program SineSound. java shows how to save generated
audio data to a file, in our case sine.wav. In the code we set the parameters:
sampling frequency, signal frequency and amplitude. The operation & is the
bitwise AND operation and >>> is the triple right shift to act as a logical
right shift by inserting zeros at the top end. The Math class of Java is used
for the number Math. P I and the function Math. sin ( ) .
import java.io.ByteArrayInputStream;
import j ava. io .File;
import java.io.10Exception;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Audio1nputStream;
import javax.sound.sampled.AudioFileFormat;
byte[] data;
AudioFormat format;
int amplitude = 10000; / / [0..32767]
1.4. APPLICATION
int value = 0;
value = (int)
(Math.sin(((double)frame/(double)periodLengthInFrames)*
2.0*Math.PI)*amplitude) ;
new ~ i l ("sine.
e wavl'));
>
catch(I0Exception e)
C
;
e .~rintStack~race()
>
> // end m a i n 0
1
1) Non Return To Zero Coding (NRZ): Signal level is low for a 0 bit and
high for a 1 bit and does not return to zero between successive 1 bits.
In existing commercial optical fiber communications links, information is
encoded with square-wave pulses in the non-return-to-zero format. These
pulses propagate essentially linearly in existing systems. Dispersion, ab-
sorption and imperfections in the fiber cables deform them causing errors
in the transmitted signal. To keep the signal error free, it is periodically
corrected and amplified.
2 ) Return To Zero Coding (RZ): Signal level during the first half of a bit
interval (data cell) is low for a 0 bit and high for a 1 bit. Then it returns
to zero for either a 0 or 1 in the second half of the bit interval.
Depending on the data pattern, there may be a transition a t the data cell
boundary (beginninglend). A pattern of corlsecutive "1s" or "0s" results in
a transition on the data cell boundary. When the data pattern alternates
between "1" and " 0 , there is no transition on the cell data cell boundary.
4) Mzller Coding: For a 1 bit the signal changes in the middle of a bit
interval (data cell) but not a t the beginning or end. For a 0 bit, the signal
level remains constant through a bit interval, changing a t the end of it if
followed by another 0 but not if it is followed by a 1.
Clock
Manchester
Figure 1.2. NRZ Encoding and Manchester Encoding for the bitstring
10010
In NRZ only one levelldata cell is required, while in Manchester coding two
levels are required. A DC component exist in NRZ when contiguous "1s"
or contiguous "0s" are transmitted. When the data pattern alternates be-
tween "1s" and "Os", the frequency response is equal to 112 the clock rate.
The frequency response for NRZ then ranges from DC t o clock12. The fre-
quency response of Manchester code ranges from clock/2, occurring when
the data pattern is alternating "1s" to "Os", to clock which occurs when the
12 CHAPTER 1. SAMPLING THEORY
data pattern is consecutive "1s" or "0s". Two advantages of NRZ are that
it does not require encoding/decoding, and it makes the most efficient use of
a communication channels bandwidth. Manchester coding requires a mod-
ulation rate twice that of NRZ to transmit the same amount of information.
This can be important in bandwidth limited communication channels. On
the other hand, the receiver of NRZ requires a true DC response. Since
Manchester code has no DC component, it can be transformer coupled.