I. PCM Demo – Quantization Noise and Aliasing

Document Sample
I. PCM Demo – Quantization Noise and Aliasing Powered By Docstoc
					                                UNITED STATES NAVAL ACADEMY
                           DEPARTMENT OF ELECTRICAL ENGINEERING
                                       EE332, Lab #13
                                   PCM and DIGITAL AUDIO

   Instruments and Components
       1. Laptop PC
       2. Audio “.wav” files
       3. Matlab 6.5

   I. PCM Demo – Quantization Noise and Aliasing
   1. In this first section, we will hear some of the effects of quantizing and aliasing of
      audio signals. First, open the Windows Media Player on your computer, and under
      the View button, choose Visualizations Bars and WavesScope. This gives an
      o-scope representation of the voltage signal corresponding to the audio clip that is
      being played. You might need to click the round button near the top right of the
      window that is labeled “Show Equalizer & Settings in Now Playing” if you point the
      mouse over it.
   2. We’ll use the following files, available in the J:\Courses\EE332\Labs\Lab13 folder.
      They can be opened from there, or copied to your computer.

File #                    Audio File                                       Description
  1      a1itchscra.wav                     Original audio file, 16 bits/sample (65,536 levels), sample rate is 8.012 kHz

  2      a2itchscra1024.wav                 Original file quantized to 10 bits/sample (1024 levels), sample rate is same,
                                            8.012 kHz

  3      a3itchscra1024-qnoise.wav          The difference between the original and 10 bits/sample signal

  4      a4itchscra8.wav                    Original file quantized to 3 bits/sample (8 levels), sample rate is same, 8.012
                                            kHz

  5      a5itchscra8-qnoise.wav             The difference between the original and 3 bits/sample signal

  6      a6itchscra 4.wav                   Original file quantized to 2 bits/sample (4 levels), sample rate is same, 8.012
                                            kHz

  7      a7itchscra 4-qnoise.wav            The difference between the original and 2 bits/sample signal

  8      b1emotions-clip.wav                Clip from Mariah Carey’s song “Emotions”, CD quality, 16 bits/sample,
                                            sample rate is 44.1kHz

  9      b2emotions-clip-alias-2500Hz.wav   Original file, still 16 bits/sample (65,536 levels), but sample rate is reduced to
                                            2.5 kHz, introducing aliasing

  10     b3emotions-clip-alias-1000Hz.wav   Original file, still 16 bits/sample (65,536 levels), but sample rate is reduced to
                                            1kHz, introducing more aliasing



   3. Quantization:
      a. Play File #1, which is familiar to anyone who has ever watched “The Simpsons.”
   b. Now play the other quantized files in the following order: 10 bits/sample – File
      #2, 3 bits/sample - #4, 2 bits/sample - #6. Note that the aural quality of the files --
      more bits/sample at the same sample rate yields better quality.
   c. The “qnoise” files result from subtracting the quantized signals from the original
      signal. Note that the higher quality 10-bit file (#3) has very little quantization
      noise (it should be inaudible), and the quantization noise gets stronger as fewer
      bits are used per sample (#5, #7).
   d. In addition to introducing quantization noise, reducing the bit rate also reduces the
      dynamic range of the signal. How do the dynamic ranges of Files #2 and #4
      compare with the original signal (calculate the DR of each)?




4. Aliasing: Play the “b1emotions-clip.wav” file. The “b2emotions-clip-alias-
   2500Hz.wav” and “b2emotions-clip-alias-1000Hz.wav” files show the effects of
   aliasing. When sampled at a 2.5kHz (below the Nyquist rate) aliasing is introduced
   into the original clip. Note these three effects on the recovered file:
   a. If the clip is not sampled fast enough, the higher frequency transitions in the
       original signal are lost. What frequencies are lost using a 2.5 kHz sampling
       rate? A 1 kHz sampling rate?




   b. Additional tonals are introduced which were not in the original signal (alias
      frequencies). These are evident at various parts of the song.
   c. Finally, the further below the Nyquist rate the signal is sampled, more alias
      energy is introduced, and more high frequency information is lost, meaning
      poorer quality.


II. PCM Manipulation
The goal of this lab is to give the student an opportunity to interact with the PCM coding
process. The student will be able to modify the quantization bits to illustrate the quality
vs. quantity trade-off in the design of a communications system. This lab should give the
student an appreciation and a better understanding of the complexities of digital
communications.

BACKGROUND:
Analog-to-digital (A/D) and Digital-to-analog (D/A) Conversion
A great deal of theory and research discusses the A/D and D/A conversion processes, but
for simplicity we will only worry about the time spacing (Ts) between the signal samples.
Principally, the sample interval at the A/D converter must correspond to the D/A rate
being used by the hardware recovering the original sound. A convenient choice for the
D-to-A conversion rate is 8000 samples per second (Ts = 1/8000 second), which is
somewhat of a standard in digitizing voice signals. Another common choice is 11,025
Hz, which is one-quarter of the rate used for audio CDs. Both of these rates satisfy the
requirement of sampling voice signals fast enough as explained in class (the Nyquist
rate). In fact, most piano notes have relatively low frequencies, so an even lower
sampling rate could be used could be used with music. Note, however, that CD-quality
music is sampled at 44.1kHz, and DVD quality music is sampled at up to 192kHz.

In this Lab, we will use pre-recorded CD quality audio files to learn more about PCM.
These files are “.wav” files, one of many standard types of audio files, and are A/D
converted analog signals coded as PCM. The .wav file contains information describing
how the music was recorded (including sample rate and bits/sample), enabling accurate
playback through the sound card and speakers, using a media player program such as
Windows Media Player or Matlab.

PROCEDURE:
1. Double-click the Matlab icon on your desktop and change your directory in Matlab to
J:\Courses\EE332\Labs\Lab13. This can be done as follows: locate the current
directory, which is displayed at the top right of the Matlab command window. Directly
to the right of the current directory listing is a browser button identified with “…”. Click
this button and locate J:\Courses\EE332\Labs\Lab13, then click “OK”. Each is a 5
second clip from a song from one of the following songs:

File Description Artist
springsteen.wav   - “Born in the USA” Bruce Springsteen
aerosmith.wav     - “Back in the Saddle” Aerosmith
indian.wav        - “Monsoon Wedding” soundtrack Abhijeet and Anuradha Shriram
skunk.wav         - “Dead Skunk” Loudon Wainwright III
lumberjack.wav    - “I’m a Lumberjack Monty Python
mozart-1.wav      - “Romanze: Andante” Mozart
mozart-2.wav      - “Eine kleine Nachtmusik-Allegro” Mozart
zappa.wav         - “Don’t Eat the Yellow Snow” Frank Zappa


Matlab knows that a .wav file is a sound file, but we must read in the data in order to
process it. To do this, type the following at the Matlab command line (be sure to type in
the single quotes around the file’s name and the semi-colon at the end):
>> [a , fs, nbits] = wavread(‘filename.wav’);

From the .wav file, variable a is the digitized voltage waveform that was recorded and
sampled at fs samples/sec, with each sample quantized using nbits. The sample values in
these files all fall somewhere between –1V and +1V (standard for .wav files). This is CD
quality music so the sample rate is 44,100 samples/sec, and there are 16 bits/sample.

From the audio file, the value of sample frequency gets stored in variable fs, and
bits/sample gets stored in variable nbits. To see the sample frequency or the bits/sample
values, type fs or nbits at the command line and hit <Enter>.
    a. From this sample rate and bits/sample, what is the bit rate developed in
       recording this music?

    b. If each clip lasts 5 seconds, what is the total size of the audio data from each
       stereo clip in BYTEs?




3. Play your music clip using the Matlab wavplay command. At the command line, type
wavplay(a); and hit <Enter>. This probably doesn’t sound good, as Matlab uses a
default sample rate of 11,025 samples/sec unless told otherwise. Speed up the playback
by telling Matlab the correct sample rate: wavplay(a, fs); and hit <Enter>.

Now try a higher value of fs: tell Matlab that the sample rate was 1.5*fs (which is 66,150
Hz). Type: wavplay(a , 1.5*fs); and hit <Enter>. This sounds more like the Chipmunks
and illustrates the importance of knowing the sample rate of an audio (or video) playback
application.

4. Now we will adjust the quantization of the audio to reduce the quality. To adjust the
quantization we’ll use the following Matlab command “b = lab13(a , bits);” In this
function, variable a is the original audio CD-quality waveform (16 bits/sample) and b
will be the new waveform. You can adjust the value of bits to reduce the quality. For
example, to quantize with 15 bits instead of 16, type b = lab13(a , 15); and hit <Enter>.
The function lab13 also provides two plots -- the original waveform (16-bit) and the
waveform you created. Each time you change the quantization, use the wavplay function
to listen to the degraded result: wavplay(b , fs); and hit <Enter>.

(a) At what number of bits/sample is the quantization noise becoming too annoying
    for you to deal with?


(b) We’ve been reducing the quality by reducing the number of bits per sample.
    Given only the CD-quality audio files you started with, is it possible to improve
    the sound quality by increasing the number of bits/sample beyond 16
    bits/sample? Why?




(c) What trade-offs, in terms of storage size or transmission bandwidth are involved
    when trying to improve quality of the recovered signal by either increasing
    sample rate or bits/sample?

				
DOCUMENT INFO
Shared By:
Categories:
Stats:
views:112
posted:9/3/2010
language:English
pages:4