aconnect
Connect and disconnect ALSA MIDI ports
SYNOPSIS
aconnect [OPTIONS] [SENDER_CLIENT:PORT] [RECEIVER_CLIENT:PORT]
aconnect -l
aconnect -i
aconnect -o
aconnect -d SENDER_CLIENT:PORT RECEIVER_CLIENT:PORT
aconnect -x
PARAMETERS
-l, --list
Lists all active ALSA sequencer connections.
-i, --input
Lists only ALSA sequencer input ports available.
-o, --output
Lists only ALSA sequencer output ports available.
-d, --disconnect
Disconnects the specified SENDER_CLIENT:PORT from RECEIVER_CLIENT:PORT.
-x, --disconnect-all
Disconnects all active ALSA sequencer connections.
-r, --real-time
Attempts to use real-time scheduling for connection setup (may require elevated privileges).
-s, --system
Shows system ports (e.g., 'Midi Through').
-q, --quiet
Suppresses non-error messages.
-v, --verbose
Prints more detailed information about ports and connections.
-h, --help
Displays a help message and exits.
-V, --version
Displays version information and exits.
SENDER_CLIENT:PORT
The source ALSA sequencer port, specified as client_id:port_id or "client_name":"port_name".
RECEIVER_CLIENT:PORT
The destination ALSA sequencer port, specified as client_id:port_id or "client_name":"port_name".
DESCRIPTION
aconnect is a command-line utility used to manage connections between ALSA (Advanced Linux Sound Architecture) sequencer ports. It serves as a crucial tool for configuring MIDI routing within Linux, enabling communication between various MIDI applications and hardware devices. For instance, you can connect a physical MIDI keyboard's output to a software synthesizer's input, or route MIDI data between different software applications. The command can list available input and output ports, display existing connections, and dynamically establish new connections or tear down old ones. This flexibility makes it indispensable for creating complex MIDI setups. Part of the alsa-utils package, aconnect provides a simple yet powerful interface to the ALSA sequencer API, allowing users to fully control their MIDI signal flow without needing a graphical frontend. It's often used in scripting for automated MIDI environment setup.
CAVEATS
Connections made with aconnect are not persistent across system reboots or ALSA driver reloads; they must be re-established. Port client and ID numbers can sometimes change upon reboot or device reconnection, making automated scripting challenging. Using port names (e.g., "Midi Through" "Midi Through Port-0") instead of numeric IDs can offer more stability but requires careful handling of spaces and quotes. The -r (real-time) option may require root privileges or specific user capabilities to function correctly.
<B><I>PORT IDENTIFICATION AND NAMING</I></B>
ALSA sequencer ports can be identified by their numeric client_id:port_id (e.g., 129:0) or by a descriptive name (e.g., "FLUIDSYNTH" "FluidSynth synth"). When using names containing spaces, they must be enclosed in double quotes. Using names is generally more robust for scripts as client/port IDs can occasionally change across system reboots or hardware reconfigurations.
<B><I>AUTOMATING CONNECTIONS</I></B>
To ensure MIDI connections are automatically established when the system starts, users can create shell scripts containing aconnect commands. These scripts can then be executed via systemd user units, global systemd services, or traditional init scripts. This allows for a consistent MIDI environment without manual intervention after each reboot.
HISTORY
aconnect is an integral part of the alsa-utils package, which developed alongside the ALSA (Advanced Linux Sound Architecture) project. ALSA emerged in the late 1990s as a successor to OSS (Open Sound System) to provide more robust and modern audio capabilities for Linux. The ALSA sequencer, which aconnect manages, was designed to handle MIDI events and routing effectively. Since its inception, aconnect has remained a fundamental command-line tool for Linux users and developers needing precise control over MIDI connections, especially in server environments or scripted setups where graphical tools are not available or desired. Its role has been consistently important in the Linux audio ecosystem.