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:
- Map MIDI Continuous Controller (CC) messages to effect parameters (such as volume, pan, and filter cutoff).
- Control engine transport states (start, stop) using MIDI Machine Control (MMC).
- Route and record raw MIDI data streams.
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:
- Run a lightweight MIDI listener (such as a Python script using
midoorpython-rtmidi). - Map incoming Note-On numbers to specific audio files or chains.
- Send interactive Ecasound commands through ECI (such as
cs-add,ai-add sample.wav, andstart, or seeking existing chains to position0usingsetpos 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.
- Each chain loads a specific audio file as an input.
- A volume/gain effect (
-ea) or gate is placed on each chain. - You bind the MIDI CC to control the chain's volume.
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:
- LinuxSampler or FluidSynth: Standalone command-line instruments that translate Note-On events directly into sample playback.
- Mididings: A Python-based MIDI router that can listen to your keyboard and execute system-level commands or trigger external audio tools.
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.