LinuxCommandLibrary

amidi

Send and receive MIDI messages

SYNOPSIS

amidi -p [-s |-r |-l]

PARAMETERS

-p
    Specifies the ALSA MIDI port to use. The port is identified by a string (e.g., hw:0,0,0) which you can find using `aplaymidi -l` or `amidi -l`.

-s
    Sends the contents of the specified to the MIDI port. The file should contain raw MIDI data in hexadecimal format (two hex characters per byte).

-r
    Receives MIDI data from the port and saves it to the specified in hexadecimal format.

-l
    Lists available MIDI ports on the system. Shows the port names and IDs.

-d
    Dump received data to standard output in hexadecimal format (implies receiving). Alias for -r -

-t
    Set the timeout in milliseconds for receiving data. If no data is received within the timeout period, the command will exit. Default is infinite wait.

-V
    Set verbose level. 1 for normal messages, 2 for more verbose including data traces, 3 for very verbose including ALSA traces

DESCRIPTION

The amidi command provides a simple way to interact with MIDI ports on a Linux system. It allows you to send raw MIDI data to a specified port and receive MIDI data from a port.

This is useful for testing MIDI devices, sending sysex messages, debugging MIDI applications, or building simple MIDI tools. Unlike higher-level MIDI libraries, amidi operates directly on the raw MIDI byte stream, giving the user complete control over the data being transmitted and received. It accepts input from standard input (stdin) and writes output to standard output (stdout), facilitating piping and scripting. It's a valuable tool for developers and enthusiasts working with MIDI on Linux.

The program works with ALSA sequencer framework.

CAVEATS

amidi operates on raw MIDI data. It does not interpret MIDI messages or provide any higher-level functionality like timing or sequencing. The user is responsible for ensuring that the data sent to the MIDI port is valid and well-formed. Errors in MIDI formatting may lead to unexpected results, or even damage MIDI devices.

DATA FORMAT

The input and output data for amidi (when using -s or -r) is expected to be in hexadecimal format. Each byte of MIDI data is represented by two hexadecimal characters (00-FF). For example, the MIDI note-on message for middle C (note number 60) with a velocity of 100 would be represented as 90 3C 64.

EXAMPLES

Send a sysex message from file:
amidi -p hw:0,0,0 -s sysex_message.hex
List MIDI ports:
amidi -l
Receive MIDI data and save to file:
amidi -p hw:1,0,0 -r received_data.hex

HISTORY

amidi is part of the ALSA (Advanced Linux Sound Architecture) project. It was developed to provide a low-level utility for interacting with MIDI devices within the ALSA framework. It has been used to create and debug MIDI data flows by direct reading and writing to the device. The command has been included into ALSA utilities package for some time and is used widely on Linux systems for MIDI interaction.

SEE ALSO

Copied to clipboard