Combine Ecasound and SoX for Audio Production
This article provides an overview of how to build an advanced command-line audio production pipeline by combining Ecasound and SoX (Sound eXchange). By chaining these two powerful utilities through UNIX pipes, audio engineers can leverage SoX's extensive format conversion and sample-level signal processing alongside Ecasound’s multitrack routing, real-time effect chains, and LADSPA plugin hosting.
The Roles of Ecasound and SoX
SoX operates as a command-line "Swiss Army knife" for audio. It specializes in quick conversions, trimming, sample rate changes, and algorithmic effects such as dynamic range compression, filtering, and normalization.
Ecasound is a multitrack audio processing tool designed for real-time routing, mixing, recording, and applying complex effect networks. It can host LADSPA plugins, manage multiple independent audio chains, and automate parameters over time.
When used alone, each tool has limitations: SoX lacks multitrack session architecture, and Ecasound has stricter input format requirements and fewer standalone analysis tools. Pairing them combines the strengths of both.
The Pipeline Architecture
Communication between SoX and Ecasound occurs via standard input and
output streams (stdout and stdin) passing
uncompressed raw PCM (Pulse Code Modulation) data. This eliminates
intermediate disk writes, ensuring fast processing and zero generation
loss.
Both utilities must agree on the audio format parameters:
- Sample format (e.g., signed linear 16-bit or 24-bit)
- Channel count (e.g., mono or stereo)
- Sample rate (e.g., 44,100 Hz or 48,000 Hz)
Practical Pipeline Examples
1. Pre-Processing with SoX and Multitrack Routing with Ecasound
In this pipeline, SoX decodes a compressed audio file, normalizes it, trims silence, and streams raw PCM directly into Ecasound, where a LADSPA plugin applies time-based processing:
sox input.flac -t raw -r 48000 -c 2 -b 24 -e signed-integer - silence 1 0.1 1% | \
ecasound -i:stdin -f:s24_le,2,48000 -el:tap_reverb,2500,-10,0,1 -o:master.wavsox input.flac ... -: SoX reads the input file and writes raw 24-bit PCM data tostdout(-).-f:s24_le,2,48000: Ecasound configures its input engine to expect 24-bit little-endian stereo at 48 kHz.-el:tap_reverb,...: Ecasound routes the stream through a LADSPA reverb plugin before saving it tomaster.wav.
2. Ecasound Multitrack Mixdown to SoX Mastering Chain
In this workflow, Ecasound mixes multiple independent stems with separate gain staging, then pipes the master bus into SoX for final compression and limiting:
ecasound \
-a:1 -i:drums.wav -ea:90 \
-a:2 -i:bass.wav -ea:85 \
-a:3 -i:lead.wav -ea:100 \
-a:all -o:stdout -f:s32_le,2,48000 | \
sox -t raw -r 48000 -c 2 -b 32 -e signed-integer - -t wav final_master.wav \
compand 0.3,1 6:-70,-60,-20 -5 -90 0.2 \
gain -n -0.5-a:1, -a:2, -a:3: Creates three distinct chains for different stems, adjusting volume using-ea.-a:all -o:stdout: Mixes all chains down to the master output directed tostdout.compand ... gain -n -0.5: SoX receives the stream, applies dynamic range compression, and normalizes the final master to -0.5 dBFS.
Workflow Tips
- Buffer Tuning: For live monitoring or ultra-low
latency, adjust Ecasound’s internal buffers using the
-b:buffersizeflag to prevent underruns between processes. - Format Consistency: Always explicitly declare the
format parameters (
-t raw, rate, channels, bit depth) on both sides of the pipe, as raw streams carry no header metadata.