I understand an ideal analog square wave contains sine-wave-components above Nyquist frequency (and towards infinity) and is thus subject to aliasing. So obviously we need an anti-aliasing-filter. Or do we? Why do we need one?

Intuition tells us that a square wave can hardly be aliased. It is so simple and there's no chance for a cycle or half cycle to be "skipped" unless the base frequency was above Nyquist... yet listening to a non low-passed-square-wave after sampling tells us otherwise. Many low pitches are heard, because of aliasing.

How is this possible?

Each successive sine wave seems to counteract the previous one, reducing the ringing at the nulls of the square-wave

Why does superposition hold on such a simple construct?

  • $\begingroup$ SE.DSP wishes you a happy new year 2017, with a kind reminding signal that your question or its answers may require some action (update, votes, acceptance, etc.) $\endgroup$ Jan 2, 2017 at 22:57

2 Answers 2


Possibly intuitive answer, skipping the math:

There is at least one problem with sampling a non-antialiased square wave at a sampling frequency not a strict multiple of the square wave's frequency. Because a fixed number of samples don't fit into 1 period of the square wave at these ratios, and a non anti-aliased square wave quantizes to just 2 levels, there will be jitter in the number of samples between edges and thus the position of the 2 sample values representing the rising and falling edges relative to the square wave's frequency. This jitter in position results in the sound of aliasing after reconstruction (cycle to cycle phase and amplitude modulation, depending on the ratio between the two frequencies.

Anti-aliasing a square wave "rounds off" the rising and falling edges so that a "just missed" edge results in an interpolated value during sampling, thus reducing the effects of jitter modulation during reconstruction.

Another problem is that an ideal reconstruction filter has overshoot on step inputs. A "rounded off" input to this filter will result in less or no overshoot. Anti-aliasing supplies the at least the theoretically minimum amount of signal "rounding" to do this.

  • $\begingroup$ Yes para1. Although it was easy to mistakenly think about this as a change in duty cycle, it's not so simple as it happens periodically and thus introduces an aliased waveform. I'm not sure exactly what you mean by that last paragraph. The sampling theorem provides the maximum frequency that should be allowed to enter the ADC. So in this case a square wave has infinite frequencies in the steps and must be filtered! $\endgroup$ Jan 8, 2016 at 4:25
  • 1
    $\begingroup$ i don't think the Gibb's ringing is an audible problem as long as the bandlimited square wave has all the harmonics up to nearly 20 kHz (at least up to 16 kHz). the audible problem are the harmonics that are folded back to non-harmonic frequencies. $\endgroup$ Jan 8, 2016 at 20:05

In addition to @hotpaw2 explanation, a graphic. There are two analog square waves (red and green), with different lengths. They are depicted with a fine sampling, denoted by crosses. Their actual sampling is denoted by circles. The red one is shorter than the green one, as can be seen in the interval $]0.7\;0.8[$. Yet, the sample points are the same. Thus, from the circled samples, you cannot tell one from the other. This would happen for any square wave whose end falls inside the blue segment. You can see here the loss of information.

Two analog square waves

With the most simple schemes (using cardinal sines), these different sampled squares would be reconstructed as a single analog signal (as their discrete samples are the same.) Depending on the precision on the sampling, several analog-digital-analog signals can be theoretically recovered, possessing a certain amount of ripples, or overshoot, or Gibbs phenomena.


You can reduce the ripples in the interior of the square wave (as seen going from blue to red to green), but the amplitude of the overshoot will remain constant at the vicinity of the edges.

As commented by @robert bristow-johnson, there are a number of alternative techniques. The document Alias-Free Digital Synthesis of Classic Analog Waveforms (Stilson and Smith) provides some of them. I add a recent technique, based on Finite-Rate-Innovation: Feasibility of {FRI}-based square-wave reconstruction with quantization error and integrator noise, B. He et al., ICASSP 2015.

Finally, for your last question "Why does superposition hold on such a simple construct?" This can be regarded as a problem of approximating a non-continuous function on a basis on continuous ones: you can get pointwise convergence (all samples converge), but no uniform convergence (not all converge at the same rate).

  • 1
    $\begingroup$ i'm not gonna take the time to set up a MATLAB program and create demo plots, but the thing that needs be to looked at is the spectrum of a naive square wave (or any other waveforms with harmonics above Nyquist) that is sampled and there is no relationship between the sampling frequency and the fundamental of the square wave. the harmonics that are above Nyquist will fold back to non-harmonic frequencies and sound like excrement. $\endgroup$ Jan 8, 2016 at 20:04
  • 1
    $\begingroup$ there are a whole pile of synthesis techniques ("BLIT", etc) intended to synthesize an approximation to a square wave that will sound like a square wave, and doesn't have non-harmonic frequency components to gunk up the sound. my preference is wavetable synthesis where the wavetable is the same as that for a square wave (or whatever waveform) except missing harmonics above Nyquist (or perhaps a frequency somewhat below Nyquist) so they won't be there to fold back. as the pitch increases, one has to sorta cross-fade to another wavetable with even fewer harmonics. $\endgroup$ Jan 8, 2016 at 20:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.