Ecasound Dynamic Sample Rate Conversion and Anti-Aliasing
This article explains how the Ecasound digital audio processing utility performs dynamic sample rate conversion while preserving signal fidelity and preventing aliasing artifacts. It details the underlying mathematical principles, the filtering mechanisms used during upsampling and downsampling, and how the software manages time-varying resampling ratios cleanly across continuous real-time audio streams.
Dynamic sample rate conversion (SRC) in Ecasound occurs whenever an input stream, an internal processing chain, and an output device operate at disparate or fluctuating sampling frequencies. Without proper handling, mapping discrete samples across different sampling grids produces mirror frequencies that fold back into the audible spectrum, creating severe harmonic distortion known as aliasing.
To eliminate aliasing, Ecasound integrates band-limited sinc
interpolation algorithms, predominantly utilizing high-performance
external libraries such as Secret Rabbit Code
(libsamplerate). Rather than applying basic linear or
polynomial interpolation—which introduce audible phase distortion and
high-frequency roll-off—the engine relies on normalized sinc function
kernels that accurately reconstruct continuous-time band-limited
waveforms between discrete time points.
The core anti-aliasing mechanism depends on the direction of conversion:
- Downsampling (Decimation): When moving from a higher sample rate to a lower sample rate, high-frequency components present in the source that exceed the Nyquist frequency of the destination rate (\(f_{s,\text{target}} / 2\)) must be eliminated. Ecasound's resampling engine applies a steep, linear-phase finite impulse response (FIR) low-pass filter prior to downsampling. This cuts off all content above the target Nyquist boundary, preventing high frequencies from folding into the lower register.
- Upsampling (Interpolation): When moving from a lower rate to a higher rate, the process of inserting intermediate points creates spectral imaging artifacts above the original Nyquist limit (\(f_{s,\text{source}} / 2\)). The engine suppresses these harmonic images by running the stream through a post-interpolation low-pass filter configured to eliminate everything above the original sampling boundary.
Dynamic conversion requires handling changing frequency ratios on the fly, such as during variable-speed playback, real-time pitch-shifting, or clock drift compensation between independent audio interfaces. Ecasound manages dynamic ratio changes by tracking fractional sample positions using sub-sample phase accumulators. Instead of recalculating heavy filter coefficients for every slight fluctuation, the sinc kernel is stored as a polyphase filter table.
As the ratio changes, the engine interpolates between adjacent pre-computed filter phases. This enables seamless, continuous-time tracking across buffer boundaries without causing sample drops, phase cancellations, or zipper noise. The filter's cutoff frequency dynamically scales with the ratio to ensure that the cutoff threshold always corresponds to the minimum of either the input or output Nyquist limit.
Through this combination of polyphase sinc interpolation, rigorous linear-phase FIR filtering, and continuous phase tracking, Ecasound achieves high dynamic range and noise suppression well below the threshold of human hearing, maintaining clean audio signals across dynamic sample rate shifts.