Skip to content

koppi/alsa-midi-latency-test

Repository files navigation

alsa-midi-latency-test is a Linux©-based tool used to measure the roundtrip delay of MIDI messages within the ALSA (Advanced Linux© Sound Architecture) subsystem.

The tool utilizes a high-precision timer to calculate the time it takes for a MIDI message to travel from the ALSA source to the ALSA sink, and back. It's a helpful way to understand and troubleshoot MIDI latency issues, often in situations where noticeable delay is encountered between playing a MIDI keyboard and hearing the sound.

alsa-midi-latency-test

  • Roundtrip Measurement

    The tool measures the total time it takes for a MIDI message to complete a round trip, meaning from the output of one device to the input of another.

  • High-Precision Timer

    It uses a high-precision timer to accurately measure the delay, which is crucial for precise latency measurements.

  • ALSA Subsystem Focus

    The tool specifically focuses on the ALSA subsystem, allowing users to diagnose latency issues related to Linux's© audio/MIDI infrastructure.

How alsa-midi-latency-test can help:

  • Diagnosing MIDI Latency

    The tool can help users pinpoint the source of latency, whether it's related to the MIDI hardware, software drivers, or system configuration.

  • Optimizing ALSA Settings

    The measurements can guide users in adjusting ALSA settings, such as buffer sizes, to minimize latency.

  • Identifying System Bottlenecks

    In some cases, latency can be a result of system limitations, and alsa-midi-latency-test can help identify those bottlenecks.

In summary, alsa-midi-latency-test is a valuable tool for anyone working with MIDI and ALSA on Linux©, allowing them to measure and troubleshoot latency issues effectively.

Install from source code

git clone https://github.com/koppi/alsa-midi-latency-test.git
cd alsa-midi-latency-test/

The following packages are required to build alsa-midi-latency-test:

sudo apt -y install debhelper autotools-dev automake libasound2-dev

Compile alsa-midi-latency-test as follows:

sh autogen.sh
./configure
make

Install alsa-midi-latency-test as follows:

sudo make install

or build and install a Debian / Ubuntu package:

sudo apt -y install devscripts
debuild -uc -us
sudo dpkg -i ../alsa-midi-latency-test*.deb

Run alsa-midi-latency-test

  • alsa-midi-latency-test -l

    Lists available MIDI input and output ports.

  • alsa-midi-latency-test -i [input port] -o [output port]

    This runs the benchmark with the given input and output port. Note, that the input and output ports have to be connected using a MIDI cable in the real hardware to loop the MIDI message back.

  • man alsa-midi-latency-test

    The man page contains documentation for all available command line switches.

Benchmarking Results

Please share your results in the Wiki.

Definitions

See also

Thanks to

  • Arnout Engelen for initial testing,
  • Clemens Ladisch for a number of fixes with the high precision timer and ALSA midi event handling,
  • Giulio Moro for code cleanup, various fixes and support for UART I/O.

BUGS and AUTHORS

Please report bugs to the authors:

Last updated Jun 2025.

About

Measure the roundtrip delay of MIDI messages within the Advanced Linux© Sound Architecture (ALSA) subsystem

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •