How Ecasound Handles Multitrack Sample Accuracy
Ecasound achieves sample-accurate synchronization across multitrack chains through a centralized engine processing loop, unified audio format constraints, rigid block-based scheduling, and low-latency audio driver integration. By synchronizing the processing cycles of all parallel chains to discrete sample frames, the engine ensures that multiple tracks start, process, and mix concurrently without phase drift or timing jitter.
The Central Processing Loop
Ecasound coordinates multitrack audio using an architecture centered around "chains" grouped into a "chainsetup." A chain acts as a signal path containing inputs, operators (effects, filters, controllers), and outputs.
To maintain sample accuracy across separate chains:
- Synchronous Cycle Iteration: Ecasound processes
audio in discrete iterations governed by a central audio engine loop. In
every iteration, the engine requests or delivers an exact number of
sample frames—determined by the global buffer size parameter
(
-b)—simultaneously across all active inputs and outputs. - Block Alignment: Because all chains run within the same engine cycle, input buffers are processed and written to output buffers in identical time slices. No individual chain advances its timeline independently of the others.
Unified Sample Rates and Transport Formats
Sample accuracy requires all parallel streams to share an identical
time base. Ecasound enforces this through strict format declarations
(-f:sample_format,channels,sample_rate):
- Engine Sample Rate: An active chainsetup operates at a single, fixed sample rate. If an input file or device does not match the engine sample rate, Ecasound requires resampling (either internally via built-in resamplers or externally) before the audio enters the synchronous signal path.
- Sample-to-Time Mapping: Time calculations within the engine are strictly derived from the global sample rate. Commands specifying time values (seconds) are converted internally into exact integer sample counts (\(Sample = Time \times Rate\)), eliminating fractional rounding errors over long sessions.
Precise Positioning and Offset Alignment
When aligning independent audio clips or live tracks along a shared timeline, Ecasound utilizes sample-exact positioning controls:
- Position Offsets: Using the
-y:secondschain operator or positioning flags, users can define precise entry points for individual sources. Ecasound translates these values directly into sample-frame offsets. - Trigger Mechanics: When an input has an offset, Ecasound does not process audio for that chain until the global sample counter hits the specified start frame. Until that frame arrives, zero-value (silent) buffers are pushed to preserve global synchronization.
Driver-Level Synchronization: JACK vs. ALSA
The audio driver backend selected dictates how the engine translates its internal sample alignment to the hardware layer:
- JACK Audio Connection Kit: When using JACK
(
-i jack,-o jack), Ecasound delegates master clock synchronization to the JACK server. JACK runs a synchronized callback graph where every client must process an identical buffer length per period. Ecasound's chains directly map to JACK ports, yielding hardware-enforced, zero-drift sample accuracy across both internal chains and external JACK applications. - ALSA and Direct Hardware: When interfacing directly
with ALSA devices (
-i alsa,-o alsa), Ecasound manages hardware buffers directly. For multi-channel devices operating on a single soundcard clock, all tracks remain sample-locked. If bridging multiple physical soundcards, hardware clock drift may occur unless the physical audio interfaces are word-clock synchronized, as software buffering alone cannot resolve independent crystal oscillator drift.