Can Ecasound Record Incoming Raw MIDI Streams?

This article examines whether the command-line audio processing tool Ecasound can record incoming raw MIDI streams simultaneously with multitrack audio. While Ecasound excels at multitrack audio recording, routing, and real-time effects processing, it has strict architectural limitations regarding MIDI data. Below is a breakdown of Ecasound's native MIDI capabilities, why it cannot directly capture raw MIDI tracks, and how to achieve synchronized audio and MIDI recording using standard Linux utilities.

The Direct Answer

No, Ecasound cannot natively record incoming raw MIDI data streams to a file (such as a Standard MIDI File, .mid) alongside multitrack audio.

Ecasound is designed fundamentally as an audio signal network. It reads, processes, and writes linear audio sample streams (PCM via ALSA, JACK, OSS, or audio files like WAV and FLAC). It does not contain an internal MIDI sequencer engine capable of capturing timestamped MIDI events, note messages, or raw binary SysEx streams into a track.

Ecasound's Actual MIDI Capabilities

Ecasound does interact with MIDI, but its MIDI support is strictly limited to control and synchronization:

None of these subsystems write incoming MIDI notes, pitch bends, or controller events to disk for later playback or editing.

How to Record MIDI and Audio Simultaneously

To record raw MIDI streams alongside multitrack audio managed by Ecasound, you must run a dedicated MIDI recording utility in parallel. In a Linux environment, this is achieved through ALSA or JACK synchronization.

Method 1: Using arecordmidi with ALSA

For ALSA-based setups, run arecordmidi alongside your Ecasound command:

  1. Identify your MIDI hardware or virtual port using arecordmidi -l.
  2. Launch arecordmidi targeted to that port to output a standard .mid file.
  3. Simultaneously start your Ecasound audio capture chain.

You can trigger both concurrently using a basic shell script:

#!/bin/sh
# Start MIDI capture in the background
arecordmidi -p 24:0 my_midi_track.mid &
MIDI_PID=$!

# Start Ecasound multitrack audio recording
ecasound -c -f:s16_le,2,44100 \
  -a:1 -i alsa,hw:0,0 -o track1.wav \
  -a:2 -i alsa,hw:0,1 -o track2.wav

# Terminate MIDI capture when Ecasound exits
kill $MIDI_PID

Method 2: Using JACK Transport

If precise sample-accurate synchronization between the audio and MIDI streams is required, use JACK Audio Connection Kit:

  1. Configure Ecasound to use JACK for both audio inputs and transport control (ecasound -G:jack ...).
  2. Use a dedicated JACK MIDI recorder, such as jack_capture (for audio) paired with jack-keyboard/mididings setups, or lightweight command-line MIDI recorders like jack_midi_dump or non-timeline.
  3. When the JACK Transport starts, both Ecasound and your chosen MIDI capture utility will roll simultaneously, keeping tracks aligned.