Welcome, Guest
Username: Password: Remember me

TOPIC: ALSA MIDI latency test

ALSA MIDI latency test 2 years 4 months ago #7

alsa-midi-latency-test measures the roundtrip time of a MIDI message in the alsa subsystem of the linux kernel using a high precision timer. It calculates the worst case roundtrip time of all sent MIDI messages and displays a histogram of the rountrip time jitter.

It can be used indirectly to measure any other external system (Windows, OSX, iOS, Android, Arduino, Raspberry, black box, ..., everything).

The measuring system must be more accurate than the system being measured otherwise there will be measurement errors.
We are talking about a software solution that is neither professional nor calibrated. Despite this, you can get some very interesting comparative results. You can find that there are big differences between a MIDI device and another. In addition, the same MIDI device can behave differently in different contexts (OS, firmware, drivers).
A MIDI PCI card with Envy24 chip can guarantee excellent measurement results (jitter <5us) : M-Audio Audiophile 2496 or any other. See details below.

Essentially we must not assume that a MIDI device always works well, especially with an operating system. CPU frequency scaling enables the operating system to scale the CPU frequency up or down in order to save power. Remember that energy saving is a source of jitter.

I am attaching the default source code (with new alsa-midi-latency-test.c) which you can get the results available at the following link : MIDI latency/jitter performance .

Few people are familiar with the source code and the Linux platform. For this reason it will be soon provided a minimal real-time boot environment with alsa-midi-latency-test application for immediate use : BenchmarkMIDI .


# alsa-midi-latency-test
Usage: ./alsa-midi-latency-test -o client:port -i client:port ...

-o, --output=client:port port to send events to
-i, --input=client:port port to receive events from
-l, --list list available midi input/output ports
-R, --realtime use realtime scheduling (default: no)
-P, --priority=int scheduling priority, use with -R (default: maximum)
-S, --samples=# of samples to take for the measurement (default: 10000)
-s, --skip=# of samples to skip at the beginning (default: 0)
-w, --wait=ms time interval between measurements
-r, --random-wait use random interval between wait and 2*wait
-x, disable printf real time display measurements, improve time accuracy with VERY low latencies,
cancels the additional printf delay (<0.1ms) but to compensate with -w option to avoid CPU saturation
-1, 1/10^1ms display precision (default)
-2, 1/10^2ms display precision
-3, 1/10^3ms display precision
-4, 1/10^4ms display precision
-5, 1/10^5ms display precision
-6, 1/10^6ms display precision
-h, --help this help
-V, --version print current version
#


# alsa-midi-latency-test -o 32:0 -i 32:0 -R -w 3 -r -x -4
> random interval between measurements: 3.000 .. 6.000 ms
> latency distribution:
...
0.972300 -0.972400 ms: 1 #
0.972400 -0.972500 ms: 3 #
0.972500 -0.972600 ms: 3 #
0.972600 -0.972700 ms: 11 #
0.972700 -0.972800 ms: 12 #
0.972800 -0.972900 ms: 14 #
0.972900 -0.973000 ms: 16 ##
0.973000 -0.973100 ms: 26 ###
0.973100 -0.973200 ms: 32 ###
0.973200 -0.973300 ms: 38 ####
0.973300 -0.973400 ms: 46 #####
0.973400 -0.973500 ms: 64 ######
0.973500 -0.973600 ms: 49 #####
0.973600 -0.973700 ms: 81 ########
0.973700 -0.973800 ms: 122 ############
0.973800 -0.973900 ms: 144 ##############
0.973900 -0.974000 ms: 200 ####################
0.974000 -0.974100 ms: 259 ##########################
0.974100 -0.974200 ms: 312 ###############################
0.974200 -0.974300 ms: 420 ##########################################
0.974300 -0.974400 ms: 399 ########################################
0.974400 -0.974500 ms: 451 #############################################
0.974500 -0.974600 ms: 414 #########################################
0.974600 -0.974700 ms: 470 ###############################################
0.974700 -0.974800 ms: 494 #################################################
0.974800 -0.974900 ms: 500 ##################################################
0.974900 -0.975000 ms: 469 ###############################################
0.975000 -0.975100 ms: 479 ################################################
0.975100 -0.975200 ms: 403 ########################################
0.975200 -0.975300 ms: 454 #############################################
0.975300 -0.975400 ms: 447 #############################################
0.975400 -0.975500 ms: 426 ###########################################
0.975500 -0.975600 ms: 419 ##########################################
0.975600 -0.975700 ms: 422 ##########################################
0.975700 -0.975800 ms: 405 #########################################
0.975800 -0.975900 ms: 373 #####################################
0.975900 -0.976000 ms: 305 ###############################
0.976000 -0.976100 ms: 235 ########################
0.976100 -0.976200 ms: 207 #####################
0.976200 -0.976300 ms: 148 ###############
0.976300 -0.976400 ms: 85 #########
0.976400 -0.976500 ms: 49 #####
0.976500 -0.976600 ms: 23 ##
0.976600 -0.976700 ms: 15 ##
0.976700 -0.976800 ms: 7 #
0.976800 -0.976900 ms: 4 #
0.976900 -0.977000 ms: 2 #
0.977000 -0.977100 ms: 5 #
0.977100 -0.977200 ms: 5 #
0.977200 -0.977300 ms: 1 #
0.977300 -0.977400 ms: 2 #
0.977400 -0.977500 ms: 2 #
0.977500 -0.977600 ms: 1 #
0.977600 -0.977700 ms: 3 #
0.977700 -0.977800 ms: 3 #
0.977800 -0.977900 ms: 3 #
0.977900 -0.978000 ms: 1 #
...
0.978200 -0.978300 ms: 1 #
...
0.978400 -0.978500 ms: 1 #
...
0.978600 -0.978700 ms: 4 #
...
0.978800 -0.978900 ms: 1 #
...
0.979100 -0.979200 ms: 1 #
0.979200 -0.979300 ms: 2 #
...
0.979400 -0.979500 ms: 1 #
...
0.979600 -0.979700 ms: 1 #
...
0.980100 -0.980200 ms: 1 #
...
0.981600 -0.981700 ms: 1 #
...
1.015500 -1.015600 ms: 1 #

> SUCCESS

best latency was 0.972271 ms
worst latency was 1.015542 ms, which is great.
Attachments:
Last Edit: 2 years 1 month ago by Elia.
The administrator has disabled public write access.
Time to create page: 0.153 seconds
Powered by Kunena Forum