How to prevent aliasing caused by non-linear function implemented in the digital domain Consider an audio input signal band limited to 20 kHz and sampled at 44.1 kHz for example. No problem. But suppose I want to implement a limiter or other non-linear function in the digital domain. The limiter will create harmonics that can exceed 22 kHz and will therefore cause aliasing. Even if the very next block in the signal chain is a low pass filter, the damage is already done. So I can increase the sampling rate to reduce the aliasing but it seems I would need to over-sample excessively to the point where the harmonics are naturally at a very low level when they are created. Is there another way around this problem? I'm thinking some change to the non-linearity function itself so that it is incapable of creating components above 22 kHz but still provides a limiting function. Any comments? In more general terms...is there a way to modify a non-linearity so that it directly produces the same output that would come out of a non-linearity followed by a low pass filter. This would avoid aliasing without having to over sample. thanks Mark

# How to prevent aliasing caused by non-linear function implemented in the digital domain

Started by ●April 27, 2006

Reply by ●April 27, 20062006-04-27

Mark wrote:> > Consider an audio input signal band limited to 20 kHz and sampled at > 44.1 kHz for example. No problem. But suppose I want to implement a > limiter or other non-linear function in the digital domain. The > limiter will create harmonics that can exceed 22 kHz and will therefore > cause aliasing. Even if the very next block in the signal chain is a > low pass filter, the damage is already done. So I can increase the > sampling rate to reduce the aliasing but it seems I would need to > over-sample excessively to the point where the harmonics are naturally > at a very low level when they are created. Is there another way around > this problem?not much.> I'm thinking some change to the non-linearity function itself so that > it is incapable of creating components above 22 kHz but still provides > a limiting function. Any comments? > > In more general terms...is there a way to modify a non-linearity so > that it directly produces the same output that would come out of a > non-linearity followed by a low pass filter. This would avoid aliasing > without having to over sample.you have to oversample to a finite extent. if you represent the (memoryless, i assume) non-linearity as a finite order polynomial (that approximates whatever curve you are trying to implement), then whatever is the order of polynomial is the same factor of oversampling needed and no aliases will occur. then low-pass filter (at that oversampled rate) to get rid of all frequency components higher than your original Nyquist, then downsample and you will not have aliasing. e.g. let your nonlinearity be a 5th order polynomial that represents some approximation to some curve for "soft" clipping. pass a sinusoid of frequency below Fs/2 and there will be no resulting frequency components with frequency greater than 5*(Fs/2). so if your new upsampled sampling frequency is 5*Fs before applying the upsampled input to the 5th order polynomial, there will be no aliasing. to prevent any aliasing in the downsampling process (picking out one sample out of every 5), one must LPF with a cutoff at 1/5 of the upsampled Nyquist frequency before downsampling by a factor of 5. r b-j

Reply by ●April 27, 20062006-04-27

Reply by ●April 27, 20062006-04-27

"Mark" <makolber@yahoo.com> wrote in message news:1146170572.014630.87610@u72g2000cwu.googlegroups.com...> How to prevent aliasing caused by non-linear function implemented in > the digital domain > > > Consider an audio input signal band limited to 20 kHz and sampled at > 44.1 kHz for example. No problem. But suppose I want to implement a > limiter or other non-linear function in the digital domain. The > limiter will create harmonics that can exceed 22 kHz and will therefore > cause aliasing. Even if the very next block in the signal chain is a > low pass filter, the damage is already done. So I can increase the > sampling rate to reduce the aliasing but it seems I would need to > over-sample excessively to the point where the harmonics are naturally > at a very low level when they are created. Is there another way around > this problem? > I'm thinking some change to the non-linearity function itself so that > it is incapable of creating components above 22 kHz but still provides > a limiting function. Any comments?I think you should be very careful about the assumptions you're making. Yes, it will create harmonics. But, to what extent? Postulated answer: "only to frequencies below fs/2". Here's a question. I don't have a definitive answer. Start with a bandlimited signal such as a sinusoid at frequency f0 Sample it with fs=10*f0 - plenty of excess bandwidth in doing the sampling. Now, clip the *samples* of the sinusoid so that it is either positive or zero. If you had done the clipping *before* sampling then the waveform would have infinite bandwidth and you could compute an infinite Fourier Series because it is also periodic. However, you waited until the sampling had been done. Now the resulting sequence looks as though it came from a bandlimited sequence doesn't it? How can you tell differently? If it were not bandlimited to begin with then the sampling created aliasing which isn't generally reversible. AND, usually a *new* bandlimited signal is defined that includes the aliasing. It's that new bandlimited signal that's interesting if we accept the aliasing. A key question is: Is that clipped sequence different than samples that came from sampling some arbitrary bandlimited signal? [I am ignoring for now that it must be of infinite extent if it's bandlimited - just as most of us do. Let's just say that it's practically bandlimited OR bandlimited for all practical purposes]. If you can prove there is a bandlimited sequence that results in the same samples then the problem is solved. That should be easy by computing a sinc-interpolated result from the samples. If you can prove that there is *not* a bandlimited sequence that results in the same samples then the problem is solved also (I don't know how to do this). That should be possible by computing a sinc-interpolated result that doesn't blow up. We know that if you sample a sinusoid whose frequency is exactly fs/2 that there can be anomalies in reconstruction if there are phase changes. Thus the bandwidth needs to be less than fs/2 for this to be avoided - IF it's going to happen. That is not to say that a sinusoid at fs/2 cannot be recontructed - but I don't know that for sure. At least one problem is that the amplitude and phase are not known - so the result isn't unique. So, the magnitude of the fft at fs/2 is of some importance. I'm assuming a DFT that has an 0dd number of samples and thus a sample exactly at fs/2. What if you manipulate a sequence of proper samples by doing something like the limiting described above. Is the value of their fft identically zero at fs/2? Maybe it will be. What if it isn't? Does that mean that the sampling is somehow pathological? I don't know but it suggests that the rules for sampling have been broken. What if the DFT has an even number of samples. Can you tell? Can the sequence be reconstructed successfully using a sinc or Dirichlet family that's related to fs - without blowing up? I think this is an interesting question and I don't have an answer. Fred

Reply by ●April 27, 20062006-04-27

Fred Marshall wrote:> "Mark" <makolber@yahoo.com> wrote in message > news:1146170572.014630.87610@u72g2000cwu.googlegroups.com... > > How to prevent aliasing caused by non-linear function implemented in > > the digital domain > > > > > > Consider an audio input signal band limited to 20 kHz and sampled at > > 44.1 kHz for example. No problem. But suppose I want to implement a > > limiter or other non-linear function in the digital domain. The > > limiter will create harmonics that can exceed 22 kHz and will therefore > > cause aliasing. Even if the very next block in the signal chain is a > > low pass filter, the damage is already done. So I can increase the > > sampling rate to reduce the aliasing but it seems I would need to > > over-sample excessively to the point where the harmonics are naturally > > at a very low level when they are created. Is there another way around > > this problem? > > I'm thinking some change to the non-linearity function itself so that > > it is incapable of creating components above 22 kHz but still provides > > a limiting function. Any comments? > > I think you should be very careful about the assumptions you're making. > Yes, it will create harmonics. But, to what extent? Postulated answer: > "only to frequencies below fs/2". >Yes, in a sampled system, no signals can exists above fs/2 but the non-linearity TRIED to create harmonics above fs/2 and since they cannont exist, they are aliased or folded down below fs/2 and create aliasing.> Here's a question. I don't have a definitive answer. > > Start with a bandlimited signal such as a sinusoid at frequency f0 > Sample it with fs=10*f0 - plenty of excess bandwidth in doing the sampling. > > Now, clip the *samples* of the sinusoid so that it is either positive or > zero. > > If you had done the clipping *before* sampling then the waveform would have > infinite bandwidth and you could compute an infinite Fourier Series because > it is also periodic. > > However, you waited until the sampling had been done. Now the resulting > sequence looks as though it came from a bandlimited sequence doesn't it? > How can you tell differently? >Yes agreed, but it is not the CORRECT bandlimted signal.... Yes if you have say 16 bits at 44.1 kHz there are only a finite number of data sequences, but the signal that corresponds to the data sequence that results here is one that has frequency components that are not harmonics of the fundamental and these are undesired alias products.> If it were not bandlimited to begin with then the sampling created aliasing > which isn't generally reversible. AND, usually a *new* bandlimited signal > is defined that includes the aliasing. It's that new bandlimited signal > that's interesting if we accept the aliasing.Yes there is a new bandlimited signal but it is the WRONG one and generally we cannont accept the aliasing.> > A key question is: > Is that clipped sequence different than samples that came from sampling some > arbitrary bandlimited signal?No there is a bandlimited sequence that corresponds to the data sequence but it contains components at frequencies that are alisaes.> [I am ignoring for now that it must be of infinite extent if it's > bandlimited - just as most of us do. Let's just say that it's practically > bandlimited OR bandlimited for all practical purposes]. > If you can prove there is a bandlimited sequence that results in the same > samples then the problem is solved.Again, it is the wrong sequence corresponding to the wrong signal.> That should be easy by computing a sinc-interpolated result from the > samples. > > If you can prove that there is *not* a bandlimited sequence that results in > the same samples then the problem is solved also (I don't know how to do > this). > That should be possible by computing a sinc-interpolated result that doesn't > blow up. > > We know that if you sample a sinusoid whose frequency is exactly fs/2 that > there can be anomalies in reconstruction if there are phase changes. Thus > the bandwidth needs to be less than fs/2 for this to be avoided - IF it's > going to happen. > That is not to say that a sinusoid at fs/2 cannot be recontructed - but I > don't know that for sure. At least one problem is that the amplitude and > phase are not known - so the result isn't unique. > > So, the magnitude of the fft at fs/2 is of some importance. I'm assuming a > DFT that has an 0dd number of samples and thus a sample exactly at fs/2. > > What if you manipulate a sequence of proper samples by doing something like > the limiting described above. > Is the value of their fft identically zero at fs/2? > Maybe it will be. > What if it isn't? > Does that mean that the sampling is somehow pathological? > I don't know but it suggests that the rules for sampling have been broken. > What if the DFT has an even number of samples. Can you tell? > > Can the sequence be reconstructed successfully using a sinc or Dirichlet > family that's related to fs - without blowing up?I don't know.> > I think this is an interesting question and I don't have an answer. > > FredOK I will sum up like this....if you take a non-bandlimited signal and sample it, (or create it in the digital domain) it will create a data sequence that corresponds to some other bandlimted signal, but this other bandlimted signal contains alias frequency components that are generally very undesireable. thanks for the discussion... Mark

Reply by ●April 28, 20062006-04-28

Fred Marshall wrote: ...> I think this is an interesting question and I don't have an answer.I think I do, at least if I understand what you're driving at. Every possible set of samples represents some bandlimited signal. To determine what that is, just feed them to the reconstruction process and examine the result. So a set of samples that originally represented a sinusoid but is modified by zeroing out all negative samples represents *some* bandlimited signal, but probably not the same signal that results from half-wave rectifying followed by band limiting. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●April 28, 20062006-04-28

"Jerry Avins" <jya@ieee.org> wrote in message news:84-dnQsCK-uTGszZnZ2dnUVZ_uWdnZ2d@rcn.net...> Fred Marshall wrote: > > ... > >> I think this is an interesting question and I don't have an answer. > > I think I do, at least if I understand what you're driving at. Every > possible set of samples represents some bandlimited signal. To determine > what that is, just feed them to the reconstruction process and examine the > result. So a set of samples that originally represented a sinusoid but is > modified by zeroing out all negative samples represents *some* bandlimited > signal, but probably not the same signal that results from half-wave > rectifying followed by band limiting. > > JerryJerry and Mark, OK - I think we're (or I'm) getting somewhere. Jerry. We had this discussion some time back. Not every possible set of samples represents some bandlimited signal. I had thought so too but was stopped cold with the sequence: ......1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1....... **** Note the flip in the sign sequence in the middle at ****. When this is reconstructed with sincs, it blows up. It demonstrates that not every sequence represents a bandlimited signal. It's the counter-example pathological case. But, we are practical guys and I'm going to "remember it while forgetting about it" .. that is, "remember it while ignoring it - for practical situations". ----end of digression----- I emphasized and Jerry responded to the bandlimitedness question. But it seems I had missed the point because Mark is focused on aliasing and wants to reduce the resulting aliasing in selecting a limiting process. Gee, I didn't know that hard limiting *samples* would necessarily cause aliasing! So, I'm starting from scratch. Clearly if one takes a sinusoid and samples it at a very high rate then there will be harmonics. The question I had was "will be aliases from limiting as well"? A similar question would be "can one define a spectral character at all in this situation"? OK - so here's a way to look at it: Hard limiting of samples cause aliasing because the negative frequency components contribute harmonics in the negative direction (moving to lower frequencies from fs). This puts aliased components below fs/2. Simple but clear I hope. At least I learned something.... So, how to mitigate this without lowpass filtering the results of limiting? Here's a flip answer: The "nonlinearity" can include linear components, thus a lowpass filter.... But that isn't what Mark asks for. In some respects the specification contradicts itself. To limit means to add harmonics and, thus, aliases in the sampled signal. To lowpass filter means to remove some of those added frequencies and, thus, to *not* really limit. Try this: Apply a sinusoid to a hard limiter such as a half-wave rectifier. Compute the Fourier Series of the resulting waveform. Eliminate all the higher order terms of the series. Construct the resulting waveform. [In general, there will be the Gibbs phenomenon due to truncation of the series.] This observation may lend some insight because you want to have the Gibbs phenomenon in order to meet your specification. Now, ask the question: what process will cause this new waveform to be generated? We know that a half-wave rectifier followed by a lowpass filter is one answer. Are there others? I think probably not because it would imply there is a multiplicity of processes that will result in the same waveform. But there aren't a multiplicity of lowpass filters of the exact same response - unless you get into implementation details and they aren't the point here. I suppose it might be argued that there may be a multiplicity of nonlinearities combined with filters that might have identical outputs ... and that leads to making a soft limiter that requires less filtering I suppose. Then there is the complication of input waveforms that aren't sinusoids...... I think this is the killer if the waveforms are complicated composites. Too much amplitude dependence, etc. I would imagine that power supply designers have pondered this kind of question in an attempt to make things less expensive. Fred

Reply by ●April 28, 20062006-04-28

Fred Marshall wrote:> "Jerry Avins" <jya@ieee.org> wrote in message > news:84-dnQsCK-uTGszZnZ2dnUVZ_uWdnZ2d@rcn.net... > >>Fred Marshall wrote: >> >> ... >> >> >>>I think this is an interesting question and I don't have an answer. >> >>I think I do, at least if I understand what you're driving at. Every >>possible set of samples represents some bandlimited signal. To determine >>what that is, just feed them to the reconstruction process and examine the >>result. So a set of samples that originally represented a sinusoid but is >>modified by zeroing out all negative samples represents *some* bandlimited >>signal, but probably not the same signal that results from half-wave >>rectifying followed by band limiting. >> >>Jerry > > > Jerry and Mark, > > OK - I think we're (or I'm) getting somewhere. > > Jerry. We had this discussion some time back. Not every possible set of > samples represents some bandlimited signal. I had thought so too but was > stopped cold with the sequence: > ......1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 -1 1 -1 1 -1 1 -1 1 -1 1 -1 > 1 -1....... > **** > Note the flip in the sign sequence in the middle at ****. > When this is reconstructed with sincs, it blows up. It demonstrates that > not every sequence represents a bandlimited signal. It's the > counter-example pathological case.I do remember the discussion; it embarrasses me to have forgotten. I hereby make another unfounded claim which has a better chance to be true. Any set of actual samples, even if corrupted by aliasing, represents a bandlimited signal (that may not closely resemble the sampled signal).> But, we are practical guys and I'm going to "remember it while forgetting > about it" .. that is, "remember it while ignoring it - for practical > situations". > > ----end of digression----- > > I emphasized and Jerry responded to the bandlimitedness question. But it > seems I had missed the point because Mark is focused on aliasing and wants > to reduce the resulting aliasing in selecting a limiting process. Gee, I > didn't know that hard limiting *samples* would necessarily cause aliasing! > So, I'm starting from scratch. > Clearly if one takes a sinusoid and samples it at a very high rate then > there will be harmonics. > The question I had was "will be aliases from limiting as well"? > A similar question would be "can one define a spectral character at all in > this situation"? > > OK - so here's a way to look at it: > > Hard limiting of samples cause aliasing because the negative frequency > components contribute harmonics in the negative direction (moving to lower > frequencies from fs). This puts aliased components below fs/2. > Simple but clear I hope. At least I learned something.... > > So, how to mitigate this without lowpass filtering the results of limiting? > > Here's a flip answer: > The "nonlinearity" can include linear components, thus a lowpass filter.... > But that isn't what Mark asks for. > > In some respects the specification contradicts itself. > To limit means to add harmonics and, thus, aliases in the sampled signal. > To lowpass filter means to remove some of those added frequencies and, thus, > to *not* really limit.Things are muddled. Limiting produces harmonics of the limited signal, but those harmonics needn't be aliases if the sample rate is high enough. Consider what hams do (did?) to get more "punch" in their transmissions. Crank the audio gain up to where overmodulation would be frequent, then clip the audio to preclude overmodulation. The resulting waveform is rich in harmonics that cause out-of-band sidebands ("splatter"), which are removed by a low-pass filter. The final signal (which can still have a mystery flaw: do you see it?) is obviously clipped -- a scope shows that -- but bandlimited.> Try this: > Apply a sinusoid to a hard limiter such as a half-wave rectifier. > Compute the Fourier Series of the resulting waveform. > Eliminate all the higher order terms of the series. > Construct the resulting waveform. > [In general, there will be the Gibbs phenomenon due to truncation of the > series.]I don't like the stark example because most limiters for practical purposes are symmetrical.> This observation may lend some insight because you want to have the Gibbs > phenomenon in order to meet your specification. > > Now, ask the question: what process will cause this new waveform to be > generated? > We know that a half-wave rectifier followed by a lowpass filter is one > answer. > Are there others? > I think probably not because it would imply there is a multiplicity of > processes that will result in the same waveform. But there aren't a > multiplicity of lowpass filters of the exact same response - unless you get > into implementation details and they aren't the point here. > I suppose it might be argued that there may be a multiplicity of > nonlinearities combined with filters that might have identical outputs ... > and that leads to making a soft limiter that requires less filtering I > suppose. > > Then there is the complication of input waveforms that aren't > sinusoids...... I think this is the killer if the waveforms are complicated > composites. Too much amplitude dependence, etc. > > I would imagine that power supply designers have pondered this kind of > question in an attempt to make things less expensive.Aren't you impressed by the elegant simplicity of R.B-J.'s observation that the highest order harmonic generated by a soft limiter is the same as the order of the polynomial that represents it? Most practical limiter polynomials will be symmetric, hence consist of only odd powers. Jerry -- Engineering is the art of making what you want from things you can get. �����������������������������������������������������������������������

Reply by ●April 28, 20062006-04-28

robert bristow-johnson wrote:> e.g. let your nonlinearity be a 5th order polynomial that > represents some approximation to some curve for "soft" clipping. > pass a sinusoid of frequency below Fs/2 and there will be no > resulting frequency components with frequency greater than > 5*(Fs/2). so if your new upsampled sampling frequency is 5*Fs > before applying the upsampled input to the 5th order polynomial, > there will be no aliasing.You can get by with less. As long as the highest-frequency non- negligible aliasing component stays in the decimation filter's stopband, it does no harm. So, with a decimation filter whose transition band is fully below Fs/2 (or assuming a brickwall filter if you're fudging it), n-fold oversampling is good for (2n-1)-fold expected spectrum expansion. Martin -- Sphinx of black quartz, judge my vow! --David Lemon

Reply by ●April 28, 20062006-04-28

"Jerry Avins" <jya@ieee.org> wrote in message news:MpqdnUOlX4SW5M_ZnZ2dnUVZ_tydnZ2d@rcn.net...> > Aren't you impressed by the elegant simplicity of R.B-J.'s observation > that the highest order harmonic generated by a soft limiter is the same as > the order of the polynomial that represents it? Most practical limiter > polynomials will be symmetric, hence consist of only odd powers. > > Jerry > --Yes, very. Fred