Handling Non-Interleaved Audio in Ecasound
This article provides an overview of how Ecasound handles non-interleaved multi-channel audio streams from hardware devices. While Ecasound's internal processing pipelines and standard ALSA input/output layers are structured around interleaved sample formats, it accommodates non-interleaved hardware streams through driver abstraction layers, ALSA plugins, JACK integration, and internal channel routing operators.
Interleaved vs. Non-Interleaved Architecture
In interleaved audio streams, sample frames alternate across channels sequentially in a single memory buffer (e.g., Left, Right, Left, Right). In non-interleaved (planar) audio, hardware writes separate memory blocks for each channel—Buffer 1 contains all samples for Channel 1, Buffer 2 contains all samples for Channel 2, and so on. Professional multi-channel sound cards frequently operate natively in non-interleaved direct memory access (DMA) modes to optimize bus bandwidth.
Direct ALSA Device
Limitations and plughw
Ecasound's native ALSA engine defaults to interleaved read/write
operations (SND_PCM_ACCESS_RW_INTERLEAVED or
SND_PCM_ACCESS_MMAP_INTERLEAVED). When attempting to access
raw hardware directly via the ALSA hardware parameter
(-i:alsa,hw:0,0), Ecasound will fail if the underlying
hardware exclusively requires non-interleaved access
(SND_PCM_ACCESS_MMAP_NONINTERLEAVED).
To resolve this hardware limitation, Ecasound relies on ALSA's
plughw layer:
ecasound -f:s32_le,8,48000 -i:alsa,plughw:0,0 -o:output.wavThe ALSA plug layer acts as a transparent,
kernel-to-userspace translation bridge. It reads the planar,
non-interleaved buffers directly from the sound card's memory addresses
and multiplexes them on the fly into an interleaved stream that Ecasound
can ingest.
Handling Non-Interleaved Audio via JACK
For systems requiring low-latency routing without the software overhead of ALSA's conversion plugins, running Ecasound on top of the JACK Audio Connection Kit provides native support for non-interleaved processing.
JACK abstracts audio hardware by treating every input and output channel as an independent, single-channel floating-point buffer. Because JACK already splits hardware channels into distinct mono ports:
- The hardware’s non-interleaved configuration is handled at the driver level by JACK.
- Ecasound binds to individual JACK ports via the
jackaudio object (-i:jack,system:capture_1). - Each hardware channel enters Ecasound as an isolated signal chain, bypassing manual stream interleaving entirely.
Channel De-Interleaving and Routing Inside Ecasound
Once multi-channel audio is pulled into Ecasound, the software must often separate or redistribute the combined stream into individual tracks or chains for processing. Ecasound uses dedicated channel-routing operators to address individual channels within an aggregate stream:
-erc:from_channel,to_channel: Copies audio from one channel index to another.-chcopy:from_channel,to_channel: Duplicates channel data within a signal chain.-chmove:from_channel,to_channel: Shifts a channel, zeroing the source position.-chorder:ch1,ch2,...: Reorders channels to match targeted routing paths.
For example, to split an 8-channel hardware capture into separate processing chains:
ecasound -a:1 -i:alsa,plughw:0,0 -f:s32_le,8,48000 -chorder:1 -o:chan1.wav \
-a:2 -i:alsa,plughw:0,0 -f:s32_le,8,48000 -chorder:2 -o:chan2.wavBy leveraging ALSA's plug conversion layer or delegating
transport management to JACK, Ecasound processes non-interleaved
hardware inputs predictably and routes individual audio channels
efficiently.