Routing Multitrack Audio with Ecasound and JACK
Ecasound is fully capable of routing multitrack audio through the JACK Audio Connection Kit. As a command-line multitrack audio processing tool, Ecasound includes native support for JACK input and output objects. By assigning individual audio chains to specific JACK ports, users can capture, process, and route multiple independent audio channels simultaneously with low latency.
How Ecasound Integrates with JACK
Ecasound treats JACK as both an audio source and an audio sink. It
interfaces directly with the running JACK server using the
jack audio object type.
When routing multitrack audio, Ecasound uses an architecture based on "chains." A chain is an independent signal flow that accepts inputs, applies optional operators (such as effects or volume adjustments), and sends the result to outputs. By creating multiple chains within a single Ecasound session, you can handle multiple tracks concurrently.
Configuring Multitrack Inputs and Outputs
To route distinct tracks through JACK, you define multiple chains
using the -a option and assign distinct JACK connections to
each.
1. Naming JACK Ports
Ecasound allows you to either specify existing JACK system ports directly or create distinct JACK client ports that other applications can connect to:
- Static Connection: Connect directly to specific
JACK ports upon launch:
-i jack,system:capture_1 - Dynamic Client Ports: Create exposed ports for
manual connection in patchbays like QjackCtl or Carla:
-i jack_generic,port_name
2. Example: Multitrack Recording from JACK
To record four separate channels from JACK into individual mono WAV files, you set up four separate chains:
ecasound \
-a:1 -i jack,system:capture_1 -o track1.wav \
-a:2 -i jack,system:capture_2 -o track2.wav \
-a:3 -i jack,system:capture_3 -o track3.wav \
-a:4 -i jack,system:capture_4 -o track4.wav3. Example: Multitrack Playback to JACK
To route a multichannel file or separate track files out to distinct JACK output channels:
ecasound \
-a:1 -i track1.wav -o jack,system:playback_1 \
-a:2 -i track2.wav -o jack,system:playback_2 \
-a:3 -i track3.wav -o jack,system:playback_3 \
-a:4 -i track4.wav -o jack,system:playback_44. Handling Interleaved Multichannel Streams
If you are working with a single multichannel audio file (such as a
4-channel WAV), you can split the channels across separate JACK ports
using Ecasound's channel routing filters (-erc):
ecasound \
-a:1,2,3,4 -i multichannel.wav \
-a:1 -f:16,1,44100 -erc:1,1 -o jack,system:playback_1 \
-a:2 -f:16,1,44100 -erc:2,1 -o jack,system:playback_2 \
-a:3 -f:16,1,44100 -erc:3,1 -o jack,system:playback_3 \
-a:4 -f:16,1,44100 -erc:4,1 -o jack,system:playback_4Key Considerations
- Sample Rates and Buffer Sizes: Ecasound automatically adapts its processing to match the sample rate of the running JACK daemon. Ensure your audio files or stream definitions match the JACK buffer settings to avoid xruns (buffer underruns/overruns).
- Port Management: By default, if destination ports
are not specified, Ecasound exposes standard client ports under the name
ecasound, allowing you to route them via any JACK visual patchbay. - Automation and Scripting: Because Ecasound runs entirely from the command line or via its interactive control mode (EIAM), this setup can be scripted for headless multitrack recording and playback rigs.