Explanation For SoX Filter Controls

Even with a Ph.D. in electrical engineering and particular expertise in physical acoustics, this isn’t an easy question. SoX is just an open source tool for digital audio signal processing. Unfortunately, I suspect that even most people who use it don’t know exactly what it’s doing under the hood. For example, upsampling can be done in a number of ways, including linear quadratic or parabolic interpolation. There are also more sophisticated methods of upsampling that might be used. I have no idea which method or methods SoX uses. Upsampling increases the sample rate of the data stream. For example, 2X upsampling of a 96kHZ bit-rate signal turns it into a 192kHz bit-rate signal, but it’s only an estimate, as it’s impossible to recreate data points that aren’t there. The advantage of upsampling is that it increases the Nyquist frequency. The drawback is that it introduces a degree of quantization error, which can result in distortion.

The Nyquist frequency is the maximum hypothetical frequency of the audio signal that can be encoded at a given sample rate. Per the sampling theorem, the Nyquist frequency is exactly half the sample rate, and with a perfect filter, one could in theory recover signals that are 100% of the Nyquist frequency. Digital filters can be designed to mimic an ideal frequency response curve, which is flat right up to the Nyquist frequency, and zero above it. The only limitation on that is the length of the filter, but longer filters result in a lag between the input and output signals, and require more processing power.

Aliasing refers to the phenomenon in which sampled signals with frequency components greater than the nyquist frequency may sneak through as the difference between the actual frequency and the Nyquist frequency. This is the same thing as a beat frequency in AM radio. Ideally, aliasing can be prevented by filtering out such frequencies before the audio is sampled. Antialiasing is a strategy to detect and filter out aliased signal components, but there is the potential to reject some of the signal too. Phase refers to the variation in phase across the bandwidth of the filter. Ideally, the phase should be completely linear.

So in laypersons terms, a 95% bandwidth, even for a signal sampled at only 44.1kHz, will have a bandwidth well above the range of human hearing. If you happen to have superhuman hearing, you can increase the bandwidth up to 100% of the Nyquist frequency, but at the expense of needing a longer filter length and additional processing power.

1 Like