How a CD player works: Difference between revisions

From Class Wiki
Jump to navigation Jump to search
 
(13 intermediate revisions by 3 users not shown)
Line 3: Line 3:
So, what is actually happening when you put a CD into your CD player? The disk spins and music comes out, but how exactly does that work? The answer is that it works by combining the properties of sampling and Fourier Transforms to change the data on the CD into the music coming out of the CD player.
So, what is actually happening when you put a CD into your CD player? The disk spins and music comes out, but how exactly does that work? The answer is that it works by combining the properties of sampling and Fourier Transforms to change the data on the CD into the music coming out of the CD player.


==Nyquist Theorem==
===Nyquist Theorem===
The problem with a computer is that when it records the music, it actually is only sampling the wave over and over again, and then it stores those samples instead of the actual wave itself. The samples are usually expressed as a series of delta functions multiplied by their respective coefficients: <br><math>\sum_{n=-\infty}^\infty x(nT) \delta(t-nT)</math> <br>However, from these samples it is possible to recreate the original wave if the sampling rate is greater than or equal to twice the frequency of the maximum frequency of the wave being sampled. So,<br>
The problem with a computer is that when it records the music, it actually is only sampling the wave over and over again, and then it stores those samples instead of the actual wave itself. The samples are usually expressed as a series of delta functions multiplied by their respective coefficients: <br><math>\sum_{n=-\infty}^\infty x(nT) \delta(t-nT)</math> <br>However, from these samples it is possible to recreate the original wave if the sampling rate is greater than or equal to twice the frequency of the maximum frequency of the wave being sampled. So,<br>
<math>T \ge 2f_{max}</math> <br>This is called the Nyquist Theorem, and it allows us to select the sampling rate we need in order to recreate the music.
<math>\frac{1}{T} \ge 2*F_{max}</math> <br>This is called the Nyquist Theorem, and it allows us to select the sampling rate we need in order to recreate the music.
The way we get to the Nyquist Theorem goes something like this: Lets say that our original frequency goes between <math> \pm F_{max} </math>. Because of the way sampling works, the frequency response will be duplicated every <math> \frac{1}{T} = F_{rep}</math> (the frequency difference between the center of the replicas. Also, we know that the difference between the upper portion of one replica and the lower portion of the next higher replica is going to be equal to <math> F_{diff}=F_{rep}-2*F_{max}\, </math>. If we want <math> F_{diff} \ge 0 </math>, meaning that the two replicas have no overlap and are therefore reconstructable, we need <math> F_{rep}-2*F_{max} \ge 0 </math> => <math> F_{rep} \ge 2*F_{max} </math>. So, our sampling frequency has to be at least twice the max frequency of our original signal in order keep the replications from overlapping. If the replicas don't overlap, we then have the chance to reconstruct the signal as it was originally received.


===Dealing with the issues of sampling===
==Sampling==
Because a computer must use sampling in order to store music, it is necessary to have ways of turning the sampled data back into music. When we sample in time, it changes the characteristics of the frequency domain. This changes the music, so we need to figure out how to undo those changes and bring back the original music so that it will sound good to listen to. The change the occurs is called ??something?? and it means that when we sample in time, the original frequency response is repeated every 1/T Hz, which means that you are adding in a whole bunch of high frequency responses that shouldn't be there. How do we fix this? Well, one method is to send the output (a series of impulse functions corresponding to the sampled values) through a perfect brickwall (basically brickwall means perfect) low pass filter that will take out all of the high frequency components and just leave the original sound wave. This would be nice, but it doesn't exactly work that way, since it isn't humanly possible to create a perfect brickwall filter. So, what do we do to fix this?
Because a computer must use sampling in order to store music, it is necessary to have ways of turning the sampled data back into music. When we sample in time, it changes the characteristics of the frequency domain. This changes the music, so we need to figure out how to undo those changes and bring back the original music so that it will sound good to listen to. The change that occurs is called replication and it means that when we sample the music (we are sampling it in the time domain), the original frequency response of the music is replicated every 1/T Hz, which means that you are adding in a whole bunch of high frequency components that shouldn't be there. How do we fix this? Well, one method is to send the output (a series of impulse functions corresponding to the sampled values) through a perfect brickwall (basically brickwall means perfect) low pass filter that will take out all of the high frequency components and just leave the original sound wave. It would be nice if we could actually do this, but it doesn't exactly work that way, since it isn't humanly possible to create a perfect brickwall filter. So, instead we use other methods to create the output we are looking for, starting with the Digital to Analog converter.


==D/A converter==
===D/A converter===
A Digital to Analog converter doesn't send out impulse functions, instead it sends out a function that will step along with the height of the steps being the height of the impulse functions, basically convolving the impulse functions with a pulse of period T and amplitude 1. This changes things a bit. Because the impulse functions are being convolved with the pulse, their fourier transfers are being multiplied. The fourier transform of the pulse, when multiplied by the fourier transform of the impulse functions, changes the output in two ways. It smushes the response that we want, the low frequency components of the wave, but it also cuts out a big portion of the high frequency components we don't want since the fourier transform of the pulse is zero in the middle of the higher frequency responses, thereby making them much much smaller and less significant. This is very good because we can correct for the smushing of the response we want by changing our low pass filter, and we don't have to worry as much about the stuff we don't want, since it is mostly removed by the pulse function. The shape of the low pass filter is determined by the shape of the fourier transform of the pulse function. Then, after the signal passes through the low pass filter, it comes out of the speaker as music!
A Digital to Analog converter doesn't send out impulse functions, instead it sends out a function that is a series of steps with the height of the steps being the magnitude of the area under the impulse functions stored in the data, basically convolving the impulse functions with a pulse of period T and amplitude 1. This changes things a bit. Because the impulse functions are being convolved with the pulse, their fourier transferms are being multiplied. The fourier transform of the pulse, when multiplied by the fourier transform of the impulse functions, changes the output in two ways. It deforms the response that we want, the low frequency components of the wave, but it also cuts out a big portion of the high frequency components we don't want since the frequency component of the pulse is zero in the middle of the higher frequency responses, thereby making the higher frequency replications much much smaller and less significant. This is very good because we can correct for the deformation of the response we want by adjusting for it in our low pass filter. In addition, we don't have to worry as much about the stuff we don't want, since it is mostly removed by the pulse function. The shape of the low pass filter is determined by the shape of the fourier transform of the pulse function. Then, after the signal passes through the low pass filter, it comes out of the speaker as music!


==2 times oversampling==
==Two times oversampling==
If you aren't satisfied by the pretty good method described above, then take a look at 2x oversampling. The biggest advantage given by 2x oversampling is that it completely knocks out the first replica of the frequency response that is created by sampling. This makes it much much easier to make a low pass filter that gives you an output that is the same, or at least very close to the same, as the original.

===How it works===
It starts the same way, by sampling the incoming signal. But then, in order to get a nicer wave to work with, we convolve the sampled values with another series of impulse functions. This series of impulse functions has a fourier transform that does two things. It is zero in the area of the first replica on either side, and it is shaped so that the top is slightly dished to compensate for the effects of the pulse function later on. The formula for these delta functions is:<br>
<math>h(t)=\sum_{m=-M}^M h\left (\frac{mT}{2}\right )\delta\left (t- \frac{mT}{2} \right )</math>
*Note, the period between these impulse functions is T/2, which is where the 2x comes from in 2x oversampling.
<br>
Also, the frequency response of this is:
<br>
<math>H(f)=\mathcal{F}[\sum_{m=-\infty}^\infty h\left (\frac{mT}{2}\right )\delta\left (t-\frac{mT}{2}\right )]</math>
<br>
<math>=\sum_{m=-\infty}^\infty h\left (\frac{mT}{2}\right )e^{-j2\pi \frac{mT}{2}}</math>
<br>
You can adjust the shape of <math>h\left (\frac{mT}{2}\right )</math> to compensate for the deformation that occurs during the D/A conversion phase of the reproduction. After this is done, it is the same process to recreate the signal, you send the impulse functions to the D/A converter, and then from there to the low pass filter, and then out to the speakers to hear the music.

===Other info===
Oversampling does not have to be 2x oversampling, there is also 1x oversampling, 3x oversampling, etc. The only difference between those and this is the period between the impulse functions that you convolve your data with, for 2x oversampling it is <math>\frac{T}{2}</math> and for Nx oversampling it is <math>\frac{T}{N}</math>.
<br>[[User:Wilspa|Back to my page]]

Latest revision as of 20:58, 30 October 2006

Back to my page

How a CD player works

So, what is actually happening when you put a CD into your CD player? The disk spins and music comes out, but how exactly does that work? The answer is that it works by combining the properties of sampling and Fourier Transforms to change the data on the CD into the music coming out of the CD player.

Nyquist Theorem

The problem with a computer is that when it records the music, it actually is only sampling the wave over and over again, and then it stores those samples instead of the actual wave itself. The samples are usually expressed as a series of delta functions multiplied by their respective coefficients:

However, from these samples it is possible to recreate the original wave if the sampling rate is greater than or equal to twice the frequency of the maximum frequency of the wave being sampled. So,

This is called the Nyquist Theorem, and it allows us to select the sampling rate we need in order to recreate the music. The way we get to the Nyquist Theorem goes something like this: Lets say that our original frequency goes between . Because of the way sampling works, the frequency response will be duplicated every (the frequency difference between the center of the replicas. Also, we know that the difference between the upper portion of one replica and the lower portion of the next higher replica is going to be equal to . If we want , meaning that the two replicas have no overlap and are therefore reconstructable, we need => . So, our sampling frequency has to be at least twice the max frequency of our original signal in order keep the replications from overlapping. If the replicas don't overlap, we then have the chance to reconstruct the signal as it was originally received.

Dealing with the issues of sampling

Because a computer must use sampling in order to store music, it is necessary to have ways of turning the sampled data back into music. When we sample in time, it changes the characteristics of the frequency domain. This changes the music, so we need to figure out how to undo those changes and bring back the original music so that it will sound good to listen to. The change that occurs is called replication and it means that when we sample the music (we are sampling it in the time domain), the original frequency response of the music is replicated every 1/T Hz, which means that you are adding in a whole bunch of high frequency components that shouldn't be there. How do we fix this? Well, one method is to send the output (a series of impulse functions corresponding to the sampled values) through a perfect brickwall (basically brickwall means perfect) low pass filter that will take out all of the high frequency components and just leave the original sound wave. It would be nice if we could actually do this, but it doesn't exactly work that way, since it isn't humanly possible to create a perfect brickwall filter. So, instead we use other methods to create the output we are looking for, starting with the Digital to Analog converter.

D/A converter

A Digital to Analog converter doesn't send out impulse functions, instead it sends out a function that is a series of steps with the height of the steps being the magnitude of the area under the impulse functions stored in the data, basically convolving the impulse functions with a pulse of period T and amplitude 1. This changes things a bit. Because the impulse functions are being convolved with the pulse, their fourier transferms are being multiplied. The fourier transform of the pulse, when multiplied by the fourier transform of the impulse functions, changes the output in two ways. It deforms the response that we want, the low frequency components of the wave, but it also cuts out a big portion of the high frequency components we don't want since the frequency component of the pulse is zero in the middle of the higher frequency responses, thereby making the higher frequency replications much much smaller and less significant. This is very good because we can correct for the deformation of the response we want by adjusting for it in our low pass filter. In addition, we don't have to worry as much about the stuff we don't want, since it is mostly removed by the pulse function. The shape of the low pass filter is determined by the shape of the fourier transform of the pulse function. Then, after the signal passes through the low pass filter, it comes out of the speaker as music!

Two times oversampling

If you aren't satisfied by the pretty good method described above, then take a look at 2x oversampling. The biggest advantage given by 2x oversampling is that it completely knocks out the first replica of the frequency response that is created by sampling. This makes it much much easier to make a low pass filter that gives you an output that is the same, or at least very close to the same, as the original.

How it works

It starts the same way, by sampling the incoming signal. But then, in order to get a nicer wave to work with, we convolve the sampled values with another series of impulse functions. This series of impulse functions has a fourier transform that does two things. It is zero in the area of the first replica on either side, and it is shaped so that the top is slightly dished to compensate for the effects of the pulse function later on. The formula for these delta functions is:

  • Note, the period between these impulse functions is T/2, which is where the 2x comes from in 2x oversampling.


Also, the frequency response of this is:


You can adjust the shape of to compensate for the deformation that occurs during the D/A conversion phase of the reproduction. After this is done, it is the same process to recreate the signal, you send the impulse functions to the D/A converter, and then from there to the low pass filter, and then out to the speakers to hear the music.

Other info

Oversampling does not have to be 2x oversampling, there is also 1x oversampling, 3x oversampling, etc. The only difference between those and this is the period between the impulse functions that you convolve your data with, for 2x oversampling it is and for Nx oversampling it is .
Back to my page