So if you generate a square wave by just switching a signal between two values, at sample boundaries, it produces an infinite series of harmonics, which alias and produce tones below your fundamental, which is very audible. The solution is Band-Limited Synthesis, either using additive synthesis or band-limited steps to produce waveforms that are the same as if you had band-limited the ideal mathematical square wave before sampling it:
But I just realized that if you apply large amplification to a digital sine wave and then clip it digitally, it will produce the same square wave shape, without the Gibbs phenomenon ripples. So it's then also producing aliased distortion products, right? So any non-linear distortion in the digital domain that produces harmonics outside of the Nyquist limits will produce aliased distortion products? (Edit: I've done some tests and confirmed that this part is true.)
Is there such a thing as band-limited distortion, to simulate (in the digital domain) the effects of distorting (in the analog domain) before band-limiting and sampling? If so, how do you do it? If I search for "bandlimited distortion" I find some references to Chebyshev polynomials, but I don't know how to use them or if they only work for sine waves or what:
This instrument does not attempt to generate band-limited distortion. Those interested in band-limited distortion should investigate the use of Chebyshev polynomials to generate the effect. Hyperbolic Tangent Distortion
"Chebyshev polynomial" -- shaping functions with the important property that they are intrinsically band-limited i.e. they do not introduce spurious spectral harmonics due to overlapping etc. Wave Shaper