aplaymidi
Play MIDI files using ALSA sequencer
SYNOPSIS
aplaymidi [-V] [-l] [-p port] [-P name] [-d dev] [-r n] file ...
aplaymidi [-V] [-l] [-p port] [-P name] [-d dev] [-r n] -f data
PARAMETERS
-h, --help
Show summary of options.
-V, --version
Print current version information.
-l, --list
List all available sequencer client ports.
-p, --port=#
Send to specific client:port (e.g., 128:0). Multiple allowed.
-P, --port-name=name
Send to port by human-readable name. Multiple allowed.
-d, --device=name
Use specified sequencer device (default: 'default').
-r, --rate=n
Set event timer resolution in Hz (default: 1000).
-f, --data
Read raw MIDI data from stdin instead of files.
DESCRIPTION
aplaymidi is a command-line utility from the ALSA (Advanced Linux Sound Architecture) utils package designed to play Standard MIDI Files (SMF) by sending their events to ALSA sequencer ports. It reads MIDI data from files or standard input and routes it to specified sequencer clients or ports, enabling playback through connected synthesizers, hardware MIDI devices, or software soundfonts.
Unlike audio playback tools like aplay, which handle WAV or PCM files, aplaymidi operates at the MIDI event level, preserving timing, note velocities, controller changes, and other MIDI messages. It's ideal for testing MIDI setups, scripting playback sequences, or integrating into larger audio workflows. Users must ensure ALSA sequencer ports are properly connected (e.g., via aconnect) to a sound source like FluidSynth or a hardware synth.
The tool supports multiple files, port selection by number or name, custom timer rates for precise timing, and raw data input for non-SMF formats. It lists available ports for easy setup and provides verbose output options for debugging.
CAVEATS
Requires running ALSA sequencer and connected output ports (use aconnect -l to check). No built-in synth; pair with timidity, fluidsynth, or hardware. Timing accuracy depends on system load and rate setting.
USAGE EXAMPLE
aplaymidi -p 128:0 song.mid plays MIDI file to port 128:0.
aplaymidi -l lists ports first.
PORT DISCOVERY
Ports like 128:0 are virtual synth inputs; connect via aconnect 128:0 14:0 for system playback.
HISTORY
Developed as part of alsa-utils, first appeared around ALSA 0.9.x (early 2000s) to support MIDI playback in user space. Evolved with ALSA 1.x for better multi-port handling and naming support; maintained in modern distributions like Ubuntu/Fedora.
SEE ALSO
arecordmidi(1), aseqdump(1), aconnect(1), amidi(1), alsamixer(1)


