0% found this document useful (0 votes)
7 views12 pages

Digital Audio Basics: Sampling & Conversion

Uploaded by

Sisay
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views12 pages

Digital Audio Basics: Sampling & Conversion

Uploaded by

Sisay
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Chapter 4

Basics of Digital Audio

Digitizing Sound
 Microphone produces analog signal
 Computer deals with digital signal

Sampling Audio

Analog Audio
Most natural phenomena around us are continuous; they are continuous transitions between two
different states. Sound is not exception to this rule i.e. sound also constantly varies. Continuously
varying signals are represented by analog signal.
Signal is a continuous function f in the time domain. For value y=f(t), the argument t of the
function f represents time. If we graph f, it is called wave. (see the following diagram)

Fig 1 analog signal

A wave has three characteristics:


 Amplitude
 Frequency, and
 Phase

1
Amplitude: is the intensity of signal. This is can be determined by looking at the height of signal.
If amplitude increases, the sound becomes louder. Amplitude measures the how high or low the
voltage of the signal is at a given point of time.
Frequency: is the number of times the wave cycle is repeated. This can be determined by
counting the number of cycles in given time interval. Frequency is related with pitchness of the
sound. Increased frequencyhigh pitch.
Phase: related to the wave s appearance.

Fig 2 recording sound and the need for digitization

When sound is recorded using microphone, the microphone changes the sound into analog
representation of the sound. In computer, we can t deal with analog things. This makes it
necessary to change analog audio into digital audio. How? Read the next topic.

Analog to Digital Conversion

Converting an analog audio to digital audio requires that the analog signal is sampled. Sampling
is the process of taking periodic measurements of the continuous signal. Samples are taken at
regular time interval, i.e. every T seconds. This is called sampling frequency/sampling rate.
Digitized audio is sampled audio. Many times each second, the analog signal is sampled. How
often these samples are taken is referred to as sampling rate. The amount of information stored
about each sample is referred to as sample size.

Analog signal is represented by amplitude and frequency. Converting these waves to digital
information is referred to as digitizing. The challenge is to convert the analog waves to numbers
(digital information).

In digital form, the measure of amplitude (the 7 point scale - vertically) is represented with
binary numbers (bottom of graph). The more numbers on the scale the better the quality of the
sample, but more bits will be needed to represent that sample. The graph below only shows 3bits
being used for each sample, but in reality either 8 or 16-bits will be used to create all the levels of
amplitude on a scale. (Music CDs use 16-bits for each sample).

2
Fig 3 quantization of samples

In digital form, the measure of frequency is referred to as how often the sample is taken. In the
graph below the sample has been taken 7 times (reading across). Frequency is talked about in
terms of Kilohertz (KHz).
Hertz (Hz) = number of cycles per second
KHz = 1000Hz
MHz = 1000 KHz

Music CDs use a frequency of 44.1 KHz. A frequency of 22 KHz for example, would mean that
the sample was taken less often.

Sampling means measuring the value of the signal at a given time period. The samples are then
quantized. Quantization is rounding the value of each sample to the nearest amplitude number
in the graph. For example, if amplitude of a specific sample is 5.6, this should be rounded either
up to 6 or down to 5. This is called quantization. Quantization is assigning a value (from a set) to
a sample. The quantized values are changed to binary pattern. The binary patterns are stored in
computer.

Fig 4 digitization process (sampling, quantization, and coding)

3
Fig 5 Sampling and quantization

Example:
The sampling points in the above diagram are A, B, C, D, E, F, H, and I.
The value of sample at point A falls between 2 and 3, may be 2.6. This value should be
represented by the nearest number. We will round the sample value to 3. Then this three is
converted into binary and stored inside computer.

Similarly, the values of other sampling points are:


B=1 C=3
D=1
E=3
F=1
G=2
H=3
I=1
The values of most sample points are quantized. After quantization, we convert sample values
into binary digits.

Sample Rate
A sample is a single measurement of amplitude. The sample rate is the number of these
measurements taken every second. In order to accurately represent all of the frequencies in a
recording that fall within the range of human perception, generally accepted as 20Hz 20KHz, we
must choose a sample rate high enough to represent all of these frequencies. At first
consideration, one might choose a sample rate of 20 KHz since this is identical to the highest
frequency. This will not work, however, because every cycle of a waveform has both a positive
and negative amplitude and it is the rate of alternation between positive and negative amplitudes
that determines frequency. Therefore, we need at least two samples for every cycle resulting in a
sample rate of at least 40 KHz.

4
Sampling Theorem
Sampling frequency/rate is very important in order to accurately reproduce a digital version of an
analog waveform.

Nyquist s Theorem:
The Sampling frequency for a signal must be at least twice the highest frequency component in
the signal.
Sample rate = 2 x highest frequency

Fig 5 Sampling at signal frequency and at twice Nyquist frequency

When the sampling rate is lower than or equal to the Nyquist rate, the condition is defined as
under sampling. It is impossible to rebuild the original signal according to the sampling theorem
when such sampling rate is used.

Aliasing

What exactly happens to frequencies that lie above the Nyquist frequency? First, we ll look at a
frequency that was sampled accurately:

In this case, there are more than two samples for every cycle, and the measurement is a good
approximation of the original wave. we will get back the same signal we put in later on when
converting it into analog.

5
Remember: speakers can play only analog sound. You have to convert back digital audio to
analog when you play it.

If we undersample the signal, though, we will get a very different result:

In this diagram, the blue wave (the one with short cycles) is the original frequency. The red wave
(the one with lower frequency) is the aliased frequency produced from an insufficient number of
samples. This frequency, which was in all likelihood a high partial in a complex timbre, has
folded over and is now below the Nyquist frequency. For example, a 11KHz frequency sampled
at 18KHz would produce an alias frequency of 7KHz. This will alter the timbre of the recording
in an unacceptable way.

Under sampling causes frequency components that are higher than half of the sampling
frequency to overlap with the lower frequency components. As a result, the higher frequency
components roll into the reconstructed signal and cause distortion of the signal. This type of
signal distortion is called aliasing.

Common Sampling Rates


o 8KHz: used for telephone
o 11.025 KHz: Speech audio
o 22.05 KHz: Low Grade Audio (WWW Audio, AM Radio)
o 44.1 KHz: CD Quality audio

Sample Resolution/Sample Size

Each sample can only be measured to a certain degree of accuracy. The accuracy is dependent on
the number of bits used to represent the amplitude, which is also known as the sample resolution.

How do we store each sample value (quantized value)?


o 8 Bit Value (0-255)
o 16 Bit Value (Integer) (0-65535)

The amount of memory required to store t seconds long sample is as follows:


 If we use 8-bit resolution, mono recording
memory = f*t*8*1
 If we use 8-bit resolution, stereo recording
memory = f*t*8*2

6
 If we use 16-bit resolution, and mono recording
memory = f*t*16*1
 If we use 16-bit resolution, and stereo recording
memory =f* t*16*2
where f is sampling frequency, and
t is time duration in seconds

Examples:
Abebe sampled audio for 10 seconds. How much storage space is required if
a) 22.05 KHz sampling rate is used, and 8 bit resolution with mono recording?
b) 44.1 KHz sampling rate is used, and 8 bit resolution with mono recording?
c) 44.1 KHz sampling rate is used, 16 bit resolution with stereo recording?
d) 11.025 KHz sampling rate, 16 bit resolution with stereo recording?

Solution:
a) m=22050*8*10*1
m= 1764000bits=220500bytes=220.5KB
b) m=44100*8*10*1
m= 3528000 bits=441000butes=441KB
c) m=44100*16*10*2
m= 14112000 bits= 1764000 bytes= 1764KB
d) m=11025*16*10*2
m= 3528000 bits= 441000 bytes= 441KB

Implications of Sample Rate and Bit Size


 Affects Quality of Audio
 Affects Size of Data

File Type 44.1 KHz 22.05 KHz 11.025 KHz


16 Bit Stereo 10.1 Mb 5.05 Mb 2.52 Mb
16 Bit Mono 5.05 Mb 2.52 Mb 1.26 Mb
8 Bit Mono 2.52 Mb 1.26 Mb 630 Kb
Table Memory required for 1 minute of digital audio

Clipping

Both analog and digital media have an upper limit beyond which they can no longer accurately
represent amplitude. Analog clipping varies in quality depending on the medium. The upper
amplitudes are being altered, distorting the waveform and changing the timbre, but the alterations
are slightly different. Digital clipping, in contrast, is always the same. Once an amplitude of
1111111111111111 (the maximum value in a 16 bit resolution) is reached, no higher amplitudes

7
can be represented. The result is not the smooth, rounded flattening of analog clipping, but a
harsh slicing of off the top of the waveform, and an unpleasant timbral result.

An Ideal Recording

We should all strive for an ideal recording. First, don t ignore the analog stage of the process.
Use a good microphone, careful microphone placement, high quality cables, and a reliable
analog-to-digital converter. Strive for a hot (high levels), clean signal.

Second, when you sample, try to get the maximum signal level as close to zero as possible
without clipping. That way you maximize the inherent signal-to-noise ratio of the medium.
Third, avoid conversions to analog and back if possible. You may need to convert the signal to
run it through an analog mixer or through the analog inputs of a digital effects processor. Each
time you do this, though, you add the noise in the analog signal to the subsequent digital
reconversion.

8
CHAPTER FIVE
Data compression

In digital signal processing, data compression, source coding, or bit-rate reduction involves
encoding information using fewer bits than the original representation. Compression can be either
lossy or lossless.

 Lossless compression reduces bits by identifying and eliminating statistical redundancy.


No information is lost in lossless compression.
 Lossy compression reduces bits by identifying unnecessary information and removing it.

The process of reducing the size of a data file is referred to as data compression. In the context of
data transmission, it is called source coding (encoding done at the source of the data before it is
stored or transmitted) in opposition to channel coding.

Compression is useful because it helps reduce resource usage, such as data storage space or
transmission capacity. Because compressed data must be decompressed to use, this extra
processing imposes computational or other costs through decompression; this situation is far from
being a free lunch. Data compression is subject to a space–time complexity trade-off. For
instance, a compression scheme for video may require expensive hardware for the video to be
decompressed fast enough to be viewed as it is being decompressed, and the option to
decompress the video in full before watching it may be inconvenient or require additional storage.
The design of data compression schemes involves trade-offs among various factors, including the
degree of compression, the amount of distortion introduced (when using lossy data compression),
and the computational resources required to compress and uncompress the data.

Lossless

Lossless data compression algorithms usually exploit statistical redundancy to represent data
more concisely without losing information, so that the process is reversible. Lossless compression
is possible because most real-world data has statistical redundancy. For example, an image may
have areas of color that do not change over several pixels; instead of coding "red pixel, red pixel"

9
the data may be encoded as "279 red pixels". This is a basic example of run-length encoding;
there are many schemes to reduce file size by eliminating redundancy.

 The Lempel–Ziv (LZ) compression methods are among the most popular algorithms for
lossless storage.
 The best modern lossless compressors use probabilistic models, such as prediction by
partial matching. The Burrows–Wheeler transform can also be viewed as an indirect form
of statistical modeling.

Lossy

Lossy data compression is the converse of lossless data compression. In these schemes, some loss
of information is acceptable. Dropping nonessential detail from the data source can save storage
space.

 Lossy data compression schemes are informed by research on how people perceive the
data in question. For example, the human eye is more sensitive to subtle variations in
luminance than it is to variations in color.
 JPEG image compression works in part by rounding off nonessential bits of information.
There is a corresponding trade-off between preserving information and reducing size.

A number of popular compression formats exploit these perceptual differences, including those
used in music files, images, and video.

 Lossy image compression can be used in digital cameras, to increase storage capacities
with minimal degradation of picture quality.
 Similarly, DVDs use the lossy MPEG-2 video coding format for video compression.

Lossless vs. lossy

Lossless compression of digitized data such as video, digitized film, and audio preserves all the
information, but can rarely do much better than 2:1 compression because of the intrinsic entropy
of the data.

10
In contrast, lossy compression (e.g. JPEG for images, or MP3 and Opus for audio) can achieve
much higher compression ratios at the cost of a decrease in quality, such as Bluetooth audio
streaming, as visual or audio compression artifacts from loss of important information are
introduced. A compression ratio of at least 50:1 is needed to get 1080i video into a 20 Mbit/s
MPEG transport stream.

Data compression ratio

Data compression ratio, also known as compression power, is a computer science term used to
quantify the reduction in data-representation size produced by a data compression algorithm. The
data compression ratio is analogous to the physical compression ratio used to measure physical
compression of substances.

Data compression ratio is defined as the ratio between the uncompressed size and compressed
size:

Thus a representation that compresses a 10MB file to 2MB has a compression ratio of 10/2 = 5,
often notated as an explicit ratio, 5:1 (read "five" to "one"), or as an implicit ratio, 5/1. Note that
this formulation applies equally for compression, where the uncompressed size is that of the
original; and for decompression, where the uncompressed size is that of the reproduction.

Sometimes the space savings is given instead, which is defined as the reduction in size relative to
the uncompressed size:

Thus a representation that compresses a 10MB file to 2MB would yield a space savings of 1 -
2/10 = 0.8, often notated as a percentage, 80%.

11
For signals of indefinite size, such as streaming audio and video, the compression ratio is defined
in terms of uncompressed and compressed data rates instead of data sizes:

And instead of space savings, one speaks of data-rate savings, which is defined as the data-rate
reduction relative to the uncompressed data rate:

For example, uncompressed songs in CD format have a data rate of 16 bits/channel x 2 channels x
44.1 kHz x 1.4 Mbit/s, whereas AAC files on an iPod are typically compressed to 128 kbit/s,
yielding a compression ratio of 10.9, for a data-rate savings of 0.91, or 91%.

When the uncompressed data rate is known, the compression ratio can be inferred from the
compressed data rate.

12

You might also like