LinuxCommandLibrary

arecordmidi

Record MIDI data from a MIDI port

SYNOPSIS

arecordmidi [-hV] [-l] [-p name] [-d #] [-r #] [-f file] port0 [port1 ...]

PARAMETERS

-h, --help
    Print usage summary and exit

-V, --version
    Print version information

-l, --list
    List all available ALSA sequencer ports

-p, --port=NAME
    Specify sequencer port name (overrides first argument)

-d, --duration=#
    Record for specified seconds, then exit

-r, --rate=#
    Set MIDI clock rate in Hz (default: 1000)

-f, --file=FILE
    Output file path (default: arecordmidi-N.midi)

DESCRIPTION

arecordmidi is a command-line utility from the alsa-utils package used to record MIDI events from ALSA sequencer ports into standard MIDI files (SMF format 0 or 1). It runs in the background, capturing real-time MIDI input from devices like keyboards, controllers, or software synths routed through ALSA's sequencer.

Primarily useful for capturing live performances, debugging MIDI streams, or archiving sequences for later playback with aplaymidi. It supports multiple ports and automatic file naming. Recording starts immediately upon invocation and stops via SIGINT (Ctrl+C), timeout with -d, or when stdin closes.

The tool handles MIDI clock rates and verbose logging for detailed event tracking. Output files include headers for tempo, time signature, and track data, ensuring compatibility with most MIDI software. It's lightweight, non-interactive, and ideal for scripts or automated capture in Linux audio workflows.

CAVEATS

Records until interrupted (Ctrl+C) if no -d specified; requires ALSA sequencer access; multi-port recording multiplexes tracks; SMF format may split multi-channel input into format 1.

PORT NAMING

Ports follow 'hw:X,Y' or client:port syntax; use aseqdump -l or -l for discovery.
Example: hw:2,0 for second card's first port.

USAGE EXAMPLE

arecordmidi -p hw:1,0 -d 30 -f session.mid
Records 30 seconds from hw:1,0 to session.mid.

HISTORY

Developed as part of ALSA utilities around 2002 (alsa-lib 1.0 era); maintained in alsa-utils package for Linux kernels with ALSA support; minor updates for sequencer API changes in ALSA 1.0+.

SEE ALSO

aplaymidi(1), aseqdump(1), amidi(1), aconnect(1)

Copied to clipboard