Trigger Audio Cues with MIDI in Ecasound

While Ecasound is a powerful command-line multitrack recorder and audio processing tool, it does not natively function as a standard sample player or soundboard. An external MIDI keyboard cannot trigger one-shot audio cues out of the box inside Ecasound without external middleware or custom scripting. However, by using the Ecasound Control Interface (ECI) or specialized MIDI routing utilities, you can achieve MIDI-triggered audio playback.

Native MIDI Capabilities and Limitations

Ecasound includes built-in support for MIDI, but its implementation focuses on real-time parameter automation and transport synchronization rather than polyphonic sample triggering.

Natively, Ecasound allows you to:

Because Ecasound manages audio via continuous processing chains rather than an internal cue buffer or sample-triggering engine, a standard MIDI Note-On message will not automatically load, seek, and fire a specific audio file natively.

Method 1: Using the Ecasound Control Interface (ECI)

The most direct way to trigger cues inside Ecasound using a keyboard is through the Ecasound Control Interface (ECI). Ecasound can run in interactive mode (-c) or as a background daemon accepting commands via Python, C, Perl, or Netcat.

To implement this:

  1. Run a lightweight MIDI listener (such as a Python script using mido or python-rtmidi).
  2. Map incoming Note-On numbers to specific audio files or chains.
  3. Send interactive Ecasound commands through ECI (such as cs-add, ai-add sample.wav, and start, or seeking existing chains to position 0 using setpos 0).

This approach gives you low-latency cue triggering while still utilizing Ecasound's real-time routing and DSP architecture.

Method 2: Chain Unmuting via MIDI Controllers

If your keyboard or controller has assignable pads or faders that transmit MIDI CC messages, you can set up pre-loaded chains inside an Ecasound chainsetup.

While this allows you to bring cues in and out using MIDI, it is limited: long samples will loop or run continuously in the background rather than restarting from the beginning upon each press.

Alternative CLI Solutions

If you require precise, low-latency one-shot sample playback without developing custom ECI scripts, consider using a dedicated Linux audio sampler alongside Ecasound:

You can then pipe the audio output from these tools directly into an Ecasound JACK or ALSA input chain for recording and real-time audio processing.