How Ecasound Handles LADSPA Sample Rate Conversion
Ecasound handles sample rate requirements for LADSPA plugins by managing audio format parameters at the chain level rather than providing transparent, per-plugin sample rate conversion. Because the LADSPA standard expects the host to supply the operating sample rate upon instantiation, Ecasound instantiates every plugin in a chain using the sample rate defined for that specific processing graph. When a plugin strictly requires a sample rate different from the source audio, users must explicitly manage sample rate conversion using Ecasound’s internal resampling capabilities or intermediate loop devices.
LADSPA Sample Rate Negotiation
The LADSPA (Linux Audio Developer's Simple Plugin API) architecture
does not natively perform sample rate conversion. When a host
initializes a plugin, it calls the instantiate() function
and passes the host's current sample rate as an argument. The plugin
then adapts its internal calculations (such as filter cutoff frequencies
or delay lines) to match this rate.
However, some LADSPA plugins are hardcoded or calibrated to function properly only at specific rates (such as 44.1 kHz or 48 kHz). Ecasound does not detect or intercept these specific plugin limitations automatically; it simply passes the active chain's configured sample rate to the plugin during initialization.
Host-Level Format Consistency
In Ecasound, audio processing occurs within chains, where all
operators, controllers, and LADSPA plugins in that chain process buffers
at a uniform format (bit depth, channels, and sample rate). This format
is set using the -f option (e.g.,
-f:s16_le,2,44100) or inherited automatically from the
input file or audio device.
Because Ecasound executes plugins sequentially over shared audio buffers, it cannot feed a plugin a sample rate that deviates from the rest of the chain without dedicated conversion steps before and after that plugin.
Implementing Sample Rate Conversion for Plugins
If an audio stream must pass through a LADSPA plugin that requires a different sample rate, the conversion must be handled structurally within the Ecasound configuration:
- Global Chain Resampling: The simplest approach is
running the entire chain setup at the sample rate required by the
plugin. If Ecasound's input source differs from this rate, Ecasound can
resample the input on ingest using its built-in resampling capabilities,
provided it was compiled with
libsamplerate(Secret Rabbit Code) support. - Multi-Chain Routing with Loop Devices: For
workflows requiring different rates at different stages, Ecasound uses
loop devices (
loop,id). Audio can be captured in one chain at a native rate, routed to an intermediate loop device that handles resampling, processed by the LADSPA plugin at its target rate in a secondary chain, and then routed back or output to a destination device.
By requiring explicit format management rather than applying hidden, automatic sample rate conversions, Ecasound maintains minimal processing overhead and gives users full control over when and where computationally expensive resampling algorithms are applied.