Dynamically Add Audio Chains in Ecasound

This article explores whether audio chains can be dynamically added to Ecasound during active audio playback. While Ecasound offers powerful real-time control through its interactive interface, altering the underlying processing topology—such as introducing a new chain—requires specific engine states. Below, you will find a clear explanation of how the Ecasound engine handles chain modifications, why true live additions require a momentary halt, and practical workarounds to achieve dynamic routing without audible disruption.

In Ecasound, you cannot add a new audio chain while the engine is actively in the running state. The processing architecture locks the signal graph during execution to maintain deterministic real-time audio processing and avoid buffer underruns. Any commands that modify the chainsetup structure—such as creating a chain with c-add, or attaching new audio inputs (ai-add) and outputs (ao-add)—will return an error or be rejected if sent while audio is actively streaming.

To add a new chain to a session that is already in progress, the engine must temporarily transition from running to stopped. Using the Ecasound Interactive Mode (EIAM) via the terminal, a control socket, or the libecasoundc API, you must execute the following sequence:

  1. Issue the stop command to pause engine processing.
  2. Create and configure the new chain using structural commands (e.g., c-add, c-select, ai-add, cop-add).
  3. Re-evaluate the setup with cs-connect if necessary.
  4. Issue the start command to resume playback.

Because Ecasound executes commands via local sockets or scripts with microsecond latency, this stop-reconfigure-start cycle can happen almost instantaneously. However, depending on your buffer size and the audio backend (such as ALSA or JACK), this process can introduce a brief audible gap or click.

If your use case requires continuous playback with zero interruption, the standard workaround is pre-allocation. Rather than creating chains on the fly, you define all potential audio chains before starting the engine. You can then dynamically alter their behavior during live playback by manipulating chain operators and controllers, which are fully supported while the engine is running. Using runtime commands like cop-select, cop-set, and dynamic controller routing, you can bypass effects, adjust volume levels from zero, or mute and unmute specific chains without ever stopping the audio stream.