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:

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.wav

3. 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_4

4. 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_4

Key Considerations