How Ecasound Synchronizes Parallel Audio Tracks

Ecasound synchronizes audio playheads across parallel recorded tracks by processing all audio streams through a unified, sample-based engine loop driven by a single master clock. Rather than allowing individual tracks to manage their own playback timers, Ecasound binds every active chain into a centralized chainsetup that advances input and output playheads simultaneously by an identical number of samples per processing cycle. This design prevents phase drift, guarantees sample-accurate alignment, and allows seamless integration with both internal audio drivers and external transport protocols like JACK.

The Chainsetup Architecture

At the core of Ecasound's synchronization model is the chainsetup. A chainsetup acts as the master container that holds all audio inputs, processing chains, and outputs for a multitrack session. When multiple tracks are routed through Ecasound in parallel:

Because all streams must match the global sampling frequency, the engine can measure the passage of time strictly in audio frames (samples per channel) rather than relying on inconsistent system clocks.

The Sample-Buffer Processing Loop

Ecasound advances audio playheads using a fixed-size buffer processing loop determined by the engine buffer size parameter (-b:buffersize).

  1. Cycle Initialization: During each iteration of the engine loop, Ecasound requests a fixed block of audio frames (e.g., 512 or 1024 samples) from every input source simultaneously.
  2. Parallel Processing: The samples pass through any assigned chain operators (effects, filters, volume envelopes) allocated to each track.
  3. Synchronized Output: The resulting frames are routed simultaneously to the assigned output devices or recorded files.

Because the engine processes exactly \(N\) samples across all parallel tracks in each loop cycle, the relative position of each playhead remains locked. If an input or output stream encounters latency or buffer starvation, the entire engine loop pauses, preventing one track from moving ahead of another.

Master Clocking and Hardware Timing

Playhead synchronization requires a reliable timing reference to govern when each buffer cycle executes. Ecasound establishes this timing using one of two methods:

Alignment Offsets and Positional Tracking

Ecasound tracks the timeline using absolute sample positions calculated from the start of the session. When tracks require offset alignment (such as bringing a delayed recording into sync with existing material), Ecasound utilizes offset controls (-y:seconds or sample-based equivalents).

When an offset is defined for a specific chain, the engine holds that chain's playhead inactive until the global sample counter reaches the designated position. Once reached, the playhead begins advancing in strict sample lockstep with the other running chains, maintaining parallel phase alignment for the remainder of the session.