I just came across a concept that doesn't completely make sense to me, and I am hoping that the group can help me to understand more. I just received a copy of Rabiner & Gold "Theory of Application of Digital Signal Processing" (probably from a recommendation here) today, and section 5.3 talks about DAC technology; particularly a zero-order hold DAC. The point is made that the spectrum is altered by the zero-order hold, and this much makes sense. The text uses h(t) to characterize the particular DAC and H(w) as its spectrum. Here's where the authors lose me: "To compensate for this spectrum shaping by the D/A converter, the digital sequence is often preprocessed by a digital filter with a magnitude response approximating |G(e^jw)| = w/2sin(wT/2) = 1/|H(w)| Thus the cascade of G(e^jw) and H(w) yields an overall flat magnitude response." Now, I certainly understand the concept that you can use one filter to pre-compensate for the effects of another filter, and it even makes sense that the magnitude could be made flat perhaps only by ignoring the phase changes (but that's getting into a side topic that's not my concern). But what baffles me is that I would intuit that the zero-order hold would affect frequencies above the sample rate, only. I do not understand how a digital filter can affect frequencies above Nyquist, much less above the sample rate. The text makes no mention of oversampling, and even if it did then I don't see how the response of a DAC at a given sample rate can be repaired by processing at that same rate. So, I assume that I am missing something - perhaps something fundamental. Maybe it would help if I could visualize the frequency response changes brought on by a zero-order hold. Thus, if the response were non-flat below Nyquist then I would instantly understand how pre-filtering could fix that. Of course, I've already mentioned my assumption that zero-order hold would only affect multiples of the sample rate, not fractions. Any comments or explanations? Not only am I curious about this, and suspect that I could learn something fundamental by pursuing an understanding of what Rabiner and Gold are alluding to, but this also seems related to a debate I had some years back about which is more correct in digital-to-digital sample rate conversion. I tend to understand the insertion of zeroes between samples when increasing the sample rate, perhaps being biased by the fact that this allows the filter code to be optimized. But the mathematician that I was debating was convinced that digital upsampling would require what was basically the digital equivalent of zero-order hold. At a minimum, I thought this would increase the signal level on the output of the SRC filter, or worse it would create an incorrect waveform that was the sum of several phase-shifted copies of the original. In any event, understanding the spectrum modifications created by zero-order analog hold will probably help explain the differences between zero-order digital hold in SRC versus pulse with zero-sample fill between. I sincerely hope that someone is up to explaining this particular concept. Note that in my copy, section 5.3 falls on page 300. Brian Willoughby Sound Consulting
Spectrum compensation for zero-order hold DAC
Started by ●February 3, 2012
Reply by ●February 3, 20122012-02-03
Hello, if I consider digital samples Dirac pulses (which is the standard way to look at it), the discrete time signal holds an infinite number of spectral replicas. The DAC reconstructs a continuous-time signal by holding each Dirac pulse over the distance to the next pulse. This can be described as time-domain convolution of a discrete-time Dirac pulse train (the samples) with a continuous-time rectangular pulse (the S&H). Time-domain convolution equals frequency multiplication. Thus, you observe the product of spectra at the output: => An infinite number of replicas, spaced with the sampling rate: the original signal times => The spectrum of your sample-and hold pulse. Now the latter is a sinc() function, with notches at multiples of the sampling rate. Intuitively, any frequency that fits an integer number of periods into the S&H window disappears, this is easy to remember. With that in mind, it's clear to see that the S&H -does- affect your wanted signal frequency range. The question is, how much. The answer depends on the percentage of the sampling rate you're using.
Reply by ●February 3, 20122012-02-03
On Fri, 03 Feb 2012 04:44:45 -0800, Brian Willoughby wrote:> I just came across a concept that doesn't completely make sense to me, > and I am hoping that the group can help me to understand more. > > I just received a copy of Rabiner & Gold "Theory of Application of > Digital Signal Processing" (probably from a recommendation here) today, > and section 5.3 talks about DAC technology; particularly a zero-order > hold DAC. The point is made that the spectrum is altered by the > zero-order hold, and this much makes sense. The text uses h(t) to > characterize the particular DAC and H(w) as its spectrum. Here's where > the authors lose me: > > "To compensate for this spectrum shaping by the D/A converter, the > digital sequence is often preprocessed by a digital filter with a > magnitude response approximating > |G(e^jw)| = w/2sin(wT/2) = 1/|H(w)| > Thus the cascade of G(e^jw) and H(w) yields an overall flat magnitude > response." > > Now, I certainly understand the concept that you can use one filter to > pre-compensate for the effects of another filter, and it even makes > sense that the magnitude could be made flat perhaps only by ignoring the > phase changes (but that's getting into a side topic that's not my > concern). But what baffles me is that I would intuit that the zero-order > hold would affect frequencies above the sample rate, only. I do not > understand how a digital filter can affect frequencies above Nyquist, > much less above the sample rate. The text makes no mention of > oversampling, and even if it did then I don't see how the response of a > DAC at a given sample rate can be repaired by processing at that same > rate. > > So, I assume that I am missing something - perhaps something > fundamental. Maybe it would help if I could visualize the frequency > response changes brought on by a zero-order hold. Thus, if the response > were non-flat below Nyquist then I would instantly understand how > pre-filtering could fix that. Of course, I've already mentioned my > assumption that zero-order hold would only affect multiples of the > sample rate, not fractions. > > Any comments or explanations?You _are_ missing something. Specifically, the fact that a zero-order hold shapes the output spectrum below Nyquist. A DAC with zero-order hold action acts mathematically like an ideal impulsive sampler followed by a rectangular filter with length Ts, where Ts is the sampling interval. The impulsive sampler is a purely abstract mathematical construct that multiplies a signal by a chain of impulses. A rectangular filter (AKA "boxcar filter") is a physically realizable (well, mostly) construct that, at time t, outputs the average of the signal from t - Ts to t. So when you chain the two together in the correct order, you get the familiar stair-steppy DAC response. In the frequency domain, the impulsive sampler has a "transfer function" from -1/(2 Ts) to 1/(2 Ts) of 1, so it only affects the signal spectrum by aliasing. The rectangular filter has a transfer function of { sin w * pi/Ts { ------------- w != 0 Hr(w) = { w * pi/Ts { { 1 w == 0 (Also written as sinc(w * pi/Ts), where sinc x = lim_x to 0 sin(x)/x) If you plot this out, you'll see that it has nulls at every harmonic of the sampling frequency, but you'll also see that the amplitude spectrum drops off well below Nyquist -- in fact, right at Nyquist the filter response is 2/pi, or 0.64, 4dB down from ideal. So, if this is important, then you need to fix it. You can either fix it in digital-land as Rabiner & Gold advocate (note, though, that you only need to approximate 1/sinc(x) up to the point that you want accurate reconstruction). Or, (as I've seen in video systems), you can build the 1/sinc(x) into your reconstruction filter out there in analog-land.> Not only am I curious about this, and suspect that I could learn > something fundamental by pursuing an understanding of what Rabiner and > Gold are alluding to, but this also seems related to a debate I had some > years back about which is more correct in digital-to-digital sample rate > conversion. I tend to understand the insertion of zeroes between samples > when increasing the sample rate, perhaps being biased by the fact that > this allows the filter code to be optimized. But the mathematician that > I was debating was convinced that digital upsampling would require what > was basically the digital equivalent of zero-order hold. At a minimum, I > thought this would increase the signal level on the output of the SRC > filter, or worse it would create an incorrect waveform that was the sum > of several phase-shifted copies of the original. In any event, > understanding the spectrum modifications created by zero-order analog > hold will probably help explain the differences between zero-order > digital hold in SRC versus pulse with zero-sample fill between. > > I sincerely hope that someone is up to explaining this particular > concept. Note that in my copy, section 5.3 falls on page 300.Well, you happened to be more right than the mathematician, but neither of you (in my humble opinion) really hit the nail on the head. For reconstruction you want to interpolate the correct points in between the points that you have. If you can safely assume that the signal of interest was perfectly bandlimited going into the sampling process, then the easiest mathematical approach to reconstruction is the "chain of impulses in zeros", which quickly leads to polyphase filtering. If you _can't_ safely assume that the signal of interest was perfectly bandlimited going into the sampling process then neither you nor the mathematician was right, but while I'm no expert on this part of signal- processing-land, I suspect that the mathematician was more right than you. (and lest you feel like arguing about signals not being perfectly bandlimited going into a sampling process -- consider a camera whose blur spot is significantly smaller than the pixel size of its detector, and think about the spatial sampling that's going on, and the spatial aliasing that's happening to the image). -- My liberal friends think I'm a conservative kook. My conservative friends think I'm a liberal kook. Why am I not happy that they have found common ground? Tim Wescott, Communications, Control, Circuits & Software http://www.wescottdesign.com
Reply by ●February 3, 20122012-02-03
On 2/3/12 7:44 AM, Brian Willoughby wrote:> I just came across a concept that doesn't completely make sense to me, > and I am hoping that the group can help me to understand more. >...> Here's where the authors lose me: > > "To compensate for this spectrum shaping by the D/A converter, the > digital sequence is often preprocessed by a digital filter with a > magnitude response approximating > |G(e^jw)| = w/2sin(wT/2) = 1/|H(w)| > Thus the cascade of G(e^jw) and H(w) yields an overall flat magnitude > response." > > ... what baffles me is that I would intuit that the zero-order > hold would affect frequencies above the sample rate, only. I do not > understand how a digital filter can affect frequencies above Nyquist, > much less above the sample rate. The text makes no mention of > oversampling, and even if it did then I don't see how the response of a > DAC at a given sample rate can be repaired by processing at that same rate. >...> Not only am I curious about this, and suspect that I could learn > something fundamental by pursuing an understanding of what Rabiner and > Gold are alluding to, but this also seems related to a debate I had some > years back about which is more correct in digital-to-digital sample rate > conversion. I tend to understand the insertion of zeroes between samples > when increasing the sample rate, perhaps being biased by the fact that > this allows the filter code to be optimized. But the mathematician that > I was debating was convinced that digital upsampling would require what > was basically the digital equivalent of zero-order hold. At a minimum, I > thought this would increase the signal level on the output of the SRC > filter, or worse it would create an incorrect waveform that was the sum > of several phase-shifted copies of the original.> In any event, > understanding the spectrum modifications created by zero-order analog > hold will probably help explain the differences between zero-order > digital hold in SRC versus pulse with zero-sample fill between.for more than 3 decades, i have objected to the scaling convention you see in nearly every textbook that describe sampling and reconstruction. it is dimensionally clumsy and it can lead folks like you, Brian, that have some real understanding, but to get to a place of a little misunderstanding. the essential misunderstand was expressed here *way* more than a decade ago by some Chinese student posted a question here about how he could design a LPF that had a passband gain of T, where T was a measure of time and the same as the sampling period (and reciprocal of the sampling rate Fs). here is the source of the misunderstanding. open nearly any DSP textbook (exception is Pohlmann and that's not so much a DSP text anyway) that describes the sampling theorem and what you see is this: analog or continuous-time signal: x(t) samples of x(t): x(nT) = x[n] (brackets mean discrete signals) the way they represent this discrete, sampled signal in the continuous-time domain: +inf x_s(t) = SUM{ x[n] * delta(t - nT) } n=-inf +inf = SUM{ x(nT) * delta(t - nT) } n=-inf +inf = x(t) * SUM{ delta(t - nT) } n=-inf "delta(t)" is the dirac delta (or "unit impulse") and the summation on the right is called a "dirac comb" function. the dirac comb is periodic and can be expressed as a Fourier series +inf +inf SUM{ delta(t - nT) } = SUM{ 1/T * e^(j*2*pi*k*t/T) } n=-inf k=-inf the frequency of each term in the Fourier series is k/T. what that means is, when you multiply x(t) by the dirac comb, that causes the spectrum of x(t) (called X(f)) to be copied and repeated with the spectrum centered at all frequencies k/T. those repeated copies are called "images". now the sampling theorem simply says that, if you remove all of those images (using a brick wall LPF), except the one where k=0 (the original), you get your original spectrum back and your original signal. but it does one thing more than that, it scales it (original and images) with the dimensionful constant 1/T. so most textbooks kill that scaling with a passband gain of T in the reconstruction LPF. this is misleading and misleads someone to think that we actually build a LPF with gain of T. moreover, what units would you use to express T? would changing the units on T change the gain of the LPF? so, the *correct* way to look at this is that, to get the sampled signal, we toss in a factor of T in the sampling comb function: +inf x_s(t) = x(t) * T * SUM{ delta(t - nT) } n=-inf that sampling comb has a Fourier series with all coefficients equal to the dimensionless 1. +inf +inf T * SUM{ delta(t - nT) } = SUM{ e^(j*2*pi*k*t/T) } n=-inf k=-inf so now, the reconstruction filter cuts off at f = 1/(2T) and has a passband gain of 1. we know how to unambiguously design that LPF. so, if you have this flat, brickwall LPF with cutoff at f = 1/(2T) and you drive it with a string of weighted impulse functions: +inf x_s(t) = T * SUM{ x[n] * delta(t - nT) } n=-inf the output of that brickwall LPF (with passband gain of 1) is x(t) (because the spectrum is X(f) because you wiped out all of the images, but passed the one image that looks like the original). so now ask yourself "what LTI system or filter will i need to define that will take that dirac-impulse-string x_s(t) above and turn that into the piecewise constant function that is the ZOH DAC output?" this goes in: +inf x_s(t) = T * SUM{ x[n] * delta(t-nT) } n=-inf and this comes out: +inf y(t) = SUM{ x[n] * rect( (t-nT)/T ) } n=-inf where { 1 for |u| < 1/2 rect(u) = { { 0 for |u| > 1/2 now, find the hypothetical filter that does that, and then you'll know what filter is needed to undo that, since the rest of the reconstruction filter is still flat and equal to 1 in the passband. that "ZOH impulse response filter" affects frequencies both below Nyquist (but not sooo bad) and above Nyquist (which teams up nicely with the reconstruction brick-wall LPF). in actuality, the ZOH filter puts in another 1/2 sample delay, and i did not put that in the expressions above. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Reply by ●February 3, 20122012-02-03
Tim Wescott <tim@seemywebsite.com> wrote: (snip)> If you _can't_ safely assume that the signal of interest was perfectly > bandlimited going into the sampling process then neither you nor the > mathematician was right, but while I'm no expert on this part of signal- > processing-land, I suspect that the mathematician was more right than > you. (and lest you feel like arguing about signals not being perfectly > bandlimited going into a sampling process -- consider a camera whose blur > spot is significantly smaller than the pixel size of its detector, and > think about the spatial sampling that's going on, and the spatial > aliasing that's happening to the image).My understanding is that good cameras put a low-pass filter in front of the detector. I don't know what the filter looks like, though. For cheaper cameras, it might be that the lens is designed such that it can't focus that sharp. Even more, the usual camera has an array of red, green, and blue filters on the sensor. If you aren't careful, aliasing will give you color fringes. Maybe not quite like NTSC where high frequencies go into the spectral space for the color subcarrier, but for a high-frequency, such as a striped shirt or picket fence, you might see it. They also put in an IR block filter, as Silicon is sensitive down somewhat below the end of the visible spectrum. Some people like to remove that filter, to do infra-red photography. -- glen
Reply by ●February 3, 20122012-02-03
robert bristow-johnson <rbj@audioimagination.com> wrote: (snip)> for more than 3 decades, i have objected to the scaling convention you > see in nearly every textbook that describe sampling and reconstruction. > it is dimensionally clumsy and it can lead folks like you, Brian, that > have some real understanding, but to get to a place of a little > misunderstanding. the essential misunderstand was expressed here *way* > more than a decade ago by some Chinese student posted a question here > about how he could design a LPF that had a passband gain of T, where T > was a measure of time and the same as the sampling period (and > reciprocal of the sampling rate Fs).> here is the source of the misunderstanding. open nearly any DSP > textbook (exception is Pohlmann and that's not so much a DSP text > anyway) that describes the sampling theorem and what you see is this:(snip)> +inf +inf > SUM{ delta(t - nT) } = SUM{ 1/T * e^(j*2*pi*k*t/T) } > n=-inf k=-inf> the frequency of each term in the Fourier series is k/T. what that > means is, when you multiply x(t) by the dirac comb, that causes the > spectrum of x(t) (called X(f)) to be copied and repeated with the > spectrum centered at all frequencies k/T. those repeated copies are > called "images".(snip)> but it does one thing more than that, it scales it (original and images) > with the dimensionful constant 1/T.Reminds me of the problem of where to put the 2pi in the continuous Fourier transform. My undergrad QM teacher years ago explained this one, to us. (The Fourier transform goes from time to omega, angular frequency, which when muliplied by hbar is energy. Also, from position to wavenumber, or wavevector, which when multiplied by hbar is momentum.) If you use omega and k, 2pi times frequency and 2pi/wavelength, then there is a somewhat obvious place to divide by 2pi. The integral will have a dw or dk, which is a nice place to divide by 2pi.> so most textbooks kill that scaling with a passband gain of T > in the reconstruction LPF. this is misleading and misleads > someone to think that we actually build a LPF with gain of T. > moreover, what units would you use to express T? would changing > the units on T change the gain of the LPF?Reminds me of another thing I learned in the same class. That delta( A x) = delta(x)/abs(A). If you consider delta applied to a quantity with units, you see where the units go. Also, note, that delta is an even function, and so the abs(A).> so, the *correct* way to look at this is that, to get the sampled > signal, we toss in a factor of T in the sampling comb function:> +inf > x_s(t) = x(t) * T * SUM{ delta(t - nT) } > n=-inf> that sampling comb has a Fourier series with all coefficients equal to > the dimensionless 1.(snip)> in actuality, the ZOH filter puts in another 1/2 sample delay, > and i did not put that in the expressions above.Also reminds me of complaints about early CD players. They would use a single DAC for both channels, alternating between them. That results in a 1/2 sample delay between the left and right channel. With loudspeakers, it is unlikely that you could position your head close enough to notice, but maybe with headphones. (Though actual music has very little anywhere near 20kHz, not to mention the hearing of anyone but a baby.) I presume that has been fixed in modern CD players. -- glen
Reply by ●February 3, 20122012-02-03
On 2/3/2012 7:44 AM, Brian Willoughby wrote:> I just came across a concept that doesn't completely make sense to me, > and I am hoping that the group can help me to understand more.[confusion deleted (if only!)] The root of your confusion is a bad assumption early on. The sample-and-hold does affect the response below Nyquist. A sample and hold has no effect at DC, and puts out only DC when the input signal is at the sample rate. In between it gently rolls off along a sin(x)/x curve. (x = pi at the sample rate.) At the Nyquist rate, the output (of the fundamental) sin(pi/2)/(pi/2), or about .637. that's roughly -4 dB. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������
Reply by ●February 3, 20122012-02-03
On Feb 4, 10:31=A0am, Jerry Avins <j...@ieee.org> wrote:> On 2/3/2012 7:44 AM, Brian Willoughby wrote: > > > I just came across a concept that doesn't completely make sense to me, > > and I am hoping that the group can help me to understand more. > > [confusion deleted (if only!)] > > The root of your confusion is a bad assumption early on. The > sample-and-hold does affect the response below Nyquist. A sample and > hold has no effect at DC, and puts out only DC when the input signal is > at the sample rate. In between it gently rolls off along a sin(x)/x > curve. (x =3D pi at the sample rate.) At the Nyquist rate, the output (of > the fundamental) sin(pi/2)/(pi/2), or about .637. that's roughly -4 dB. > > Jerry > -- > Engineering is the art of making what you want from things you can get. > =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF==AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF= =AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF=AF You mean zero-order hold - not sample and hold...
Reply by ●February 4, 20122012-02-04
On 2012/02/03 09:29, Tim Wescott wrote:> The impulsive sampler is a purely abstract mathematical construct that > multiplies a signal by a chain of impulses. A rectangular filter (AKA > "boxcar filter") is a physically realizable (well, mostly) construct > that, at time t, outputs the average of the signal from t - Ts to t. So > when you chain the two together in the correct order, you get the > familiar stair-steppy DAC response.By "boxcar filter," I assume that you're not talking about a "brick wall filter" like what might follow the zero-order hold.
Reply by ●February 4, 20122012-02-04
On 2/4/12 6:28 PM, Brian Willoughby wrote:> On 2012/02/03 09:29, Tim Wescott wrote: >> The impulsive sampler is a purely abstract mathematical construct that >> multiplies a signal by a chain of impulses. A rectangular filter (AKA >> "boxcar filter") is a physically realizable (well, mostly) construct >> that, at time t, outputs the average of the signal from t - Ts to t. So >> when you chain the two together in the correct order, you get the >> familiar stair-steppy DAC response. > By "boxcar filter," I assume that you're not talking about a "brick wall > filter" like what might follow the zero-order hold.i think he means the same basic function, but in the other domain. the "brick wall" filter is a rectangular pulse in the frequency domain: { 1 |f|/Fs < 1/2 H(f) = rect(f/Fs) = { { 0 |f|/Fs > 1/2 and this filter has for its impulse response: h(t) = Fs * sinc(Fs*t) The boxcar filter that Tim refers to has impulse response { Fs |t - Ts/2| < Ts/2 h(t) = Fs * rect( (t - Ts/2)/Ts ) = { { 0 |t - Ts/2| > Ts/2 now what do you think the frequency response of this filter is? -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."






