home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / rec / audio / 17216 < prev    next >
Encoding:
Internet Message Format  |  1992-12-22  |  8.5 KB

  1. Path: sparky!uunet!think.com!rpi!usc!elroy.jpl.nasa.gov!nntp-server.caltech.edu!andrey
  2. From: andrey@cco.caltech.edu (Andre T. Yew)
  3. Newsgroups: rec.audio
  4. Subject: Re: CD SOund QUality (really long)
  5. Date: 23 Dec 1992 02:45:46 GMT
  6. Organization: California Institute of Technology, Pasadena
  7. Lines: 176
  8. Message-ID: <1h8jsqINNpk1@gap.caltech.edu>
  9. References: <1h17e4INNrkv@usenet.INS.CWRU.Edu> <24459@alice.att.com> <1992Dec21.213820.2737@cbnewsh.cb.att.com> <vanz.029i@tragula.equinox.gen.nz>
  10. NNTP-Posting-Host: punisher.caltech.edu
  11.  
  12.     Perhaps this should be an FAQ entry -- the sampling theorem.
  13. I'm going to give my attempt to explain this clearly  (yeah,
  14. right), so maybe someone could write one about bits needed
  15. and dithering.  A warning: my explanation is quite long.
  16.  
  17. vanz@tragula.equinox.gen.nz (Martin Nieuwelaar) writes:
  18.  
  19. >I haven't introduced oversampling, as I'm still not too sure what it
  20. >is.  If someone could tell me if what I think is correct, is
  21. >correct I'd be pleased.  What I think happens is that you take
  22. >two of the samples, and do a straight line interpolation between
  23. >the two.  eg, with 4 times oversampling, there will be three extra
  24. >values created between the originals.  If this is so, then I
  25. >would expect the maximum sampling frequency would remain the same,
  26. >which makes sense.
  27.  
  28. >One result of this (assuming I'm correct) would then be that
  29. >an analog 22 KHz sine wave, could be sampled at 44 Khz.  The result
  30. >would be a square wave.  Oversampling this with linear interpolation
  31. >would result in a triangular wave.  Interesting.
  32.  
  33.     Well, you're using the wrong kind of interpolation:  for a
  34. point-sampled signal, you want to do sinc interpolation (what
  35. the heck is a sinc?  It's sin(pi*x)/(pi*x)), not linear or
  36. zeroth-order hold (stairsteps).  Why is this?  Let's just
  37. say your sampling method dictates what kind of interpolation
  38. you have to do.
  39.  
  40.     Let's go through a little proof of why 2 points is enough
  41. (it really isn't -- you can retrieve information that has
  42. just below half of your sampling frequency;  as an example, point-
  43. sample a sine wave at exactly twice its frequency and look
  44. at its Fourier transform).
  45.  
  46.     Okay, for simplicity's sake, let's look at a point-sampled
  47. signal, that is our samples are just points on the signal we're
  48. sampling.  Now, we need a function called a delta function -- imagine
  49. it as a spike of infinite height at exactly one point and zero
  50. everywhere else.  Usually the spike is centered at zero.
  51. Now, let's say we have a function that's made up of these spikes
  52. placed at regular intervals, say they're placed a distance
  53. exactly equal to our sampling period (this is a function that
  54. depends on time).  Now multiply this delta-function train
  55. by the signal we're trying to sample.  Waving our hands a little,
  56. this is exactly the same as point-sampling our function.
  57. Think of the spikes as giving us our points and the zero
  58. parts between spikes giving us the gaps between the sample
  59. points.
  60.  
  61.     Now you need a little faith in math.  Fourier transform
  62. the multiplied functions.  What's a Fourier transform?
  63. Think of it as a change in coordinate systems -- kind of
  64. like changing to polar coordinates, except fancier.  Instead
  65. of having straight lines as our coordinate axes, we now have
  66. functions (exp(i*n*w*t), i = sqrt(-1)).  Why are we doing
  67. this?  It makes certain things easier to see -- the t you
  68. see in exp(i*n*w*t) is time, the w frequency, and the n
  69. just says which axis we're looking at.  It's intuitively
  70. believable that this Fourier transform thing changes
  71. things between time and frequency domains, or at least
  72. has something to do with, right?  So, the reason we're
  73. doing this is because we want to look at the frequency
  74. content of our sampled signal.  This is the same idea as
  75. those spectrum analyzers you see on some stereo equipment.
  76.  
  77.     Now, one requirement of the signal we're sampling is that
  78. it has to have finite bandwidth.  This means that there's no
  79. frequency above some limit we name.  So, on our frequency graph,
  80. the signal we're trying to sample should go to zero before
  81. infinity.  That is, it could start off at some level at zero
  82. frequency, but then goes to zero and stays at zero at and above
  83. say 20 kHz.  Another thing that happens is that our function
  84. looks symmetrical when we Fourier transform it, so it's
  85. mirrored over the origin like so:
  86.  
  87.       amplitude (well, not really, but linear proportional)
  88.           |
  89.       ----|----
  90.     /     |    \    <---- This will be refered to as the brick
  91.    /      |     \         because, well, it looks like one!
  92.  ------------------ frequency
  93.           0
  94.  
  95.     Okay here's the faith part.  When you Fourier transform
  96. a multiplication, it becomes something called a convolution.
  97. A convolution is when you take two signals, multiply them,
  98. and integrate them.  Then move one of the functions over a
  99. little bit, and do the same thing.  Now, plot the value of the
  100. integral against the distance you moved the function (x = 
  101. distance, y = integral), and you have a convoluted signal.
  102. You do this all the way from -infinity to +infinity, that
  103. is you move one function over that whole range.
  104.  
  105.     So now let's look at our Fourier transformed
  106. function.  We have the signal we're trying to sample,
  107. which looks like this thing that goes to zero at some
  108. finite frequency, we have our delta-function train,
  109. which, on faith, stays a delta function train, except
  110. spaced apart a little differently (at multiples of the
  111. sampling frequency, instead of multiples of the sampling
  112. period because of a basic property of delta-functions
  113. when you integrate them over infinity), and they're
  114. multiplied, which becomes a convolution.  It's pretty
  115. easy to convolve a train of delta functions and something
  116. else -- you've just got those spikes to worry about, the
  117. rest are zero.  What you get is the Fourier transform of
  118. the signal we're trying to sample, that brick thing
  119. above, centered on every spike in the delta function
  120. train.  So the upshot of this is that when you point
  121. sample a signal with finite bandwidth and you take
  122. its Fourier transform, you get a bunch of bricks 
  123. spread over regular intervals in frequency.  Each
  124. of these bricks contain all of the original signal,
  125. except they are shifted up to higher frequencies.
  126.  
  127.     Okay, nice picture, so what?  How do we recover
  128. our original signal?  We multiply our bricks graph
  129. with a box filter that's zero above and below some
  130. limits.  Our box filter wipes out the higher frequency
  131. copies and leaves the one centered at zero intact.
  132. Voila!  We have our original signal.  By the way, the
  133. reason it's called a box filter is because it looks like a
  134. box -- some non-zero value in the center and zero outside
  135. some limits l and -l:
  136.  
  137.   amplitude
  138.    ___|___
  139.    |  |  |
  140. ___|__|__|___ frequency
  141.   -l  0  l
  142.  
  143.     Now when can't we do this -- multiply by a box
  144. filter?  When we have our bricks overlap.  When do
  145. our bricks overlap?  When either the spikes they're
  146. centered around aren't far enough apart, or the bricks
  147. are too fat.  Put another way, when our sampling
  148. frequency isn't high enough (the spikes are placed
  149. at multiples of our sampling frequency), or the
  150. signal we're trying to sample has frequencies that
  151. are too high (the fatter the bricks, the higher frequencies
  152. they contain).  Now geometrically, we can see what this
  153. relationship between spikes and bricks have to be:
  154. since the spikes are placed at a distance equal to
  155. our sampling frequency apart, the bricks have to be
  156. less than half that distance, or half the sampling
  157. frequency, on one side (remember they're mirrored
  158. around their spikes) not to overlap.  Guess what, 
  159. this is the sampling theorem:  for a signal of 
  160. finite bandwidth B, you need to sample faster than
  161. 2B to be able to reproduce it exactly.  Note to
  162. nitpickers:  bandwidth in my book means w >=0.
  163.  
  164.     Now, just for fun, let's take the inverse Fourier
  165. transform of the multiplication of the box filter and
  166. our series of bricks.  What we get back is the convolution
  167. (works the same going backwards) of the sample points,
  168. the series of bricks, and the inverse Fourier transform
  169. of our box filter.  The inverse Fourier transform of
  170. the box filter is a sinc function.  And interpolation
  171. means convolving these two functions together.  So
  172. there you go -- if anyone hung out til the gory end.
  173.  
  174.     Here's a piece of party trivia that some might feel
  175. would put a damper on the wonderful sampling theorem:
  176. a bandlimited signal is not timelimited.  And vice-versa.
  177. So, we can't ever produce a signal that satisfies the
  178. sampling theorem.
  179.  
  180.     A much better explanation of this is found in the
  181. book by Oppenheimer, somebody, and Young, called, I think,
  182. _Signals and Systems_.  It's a red book.
  183.  
  184. --Andre
  185.  
  186. -- 
  187.              Andre Yew andrey@cco.caltech.edu (131.215.139.2)
  188.