There's some confusion at the end of TFA about latency.<p>What TFA refers to as latency is the time required to inject a MIDI event/message received by RtMIDI into the perl async object - basically inter-thread wakeup. You certainly expect that to be very, very fast - it's what context switching on any multitasking/multithreaded system relies. "Fractions of a millisecond" is in the right ballpark, though on some systems "Tens of microseconds" would be more appropriate as a description.<p>What "latency" normally means in the context of MIDI or audio is the delay between the user generating a MIDI event somehow and when the audio corresponding to that MIDI event (e.g. a note) is audible. This is typically measured in relatively small numbers of milliseconds (e.g. 1-30).<p>These are not really connected in any meaningful sense.
Couldn't get the code to run with Perl on Mac:<p><pre><code> $ plenv exec perl midi.pl
Not enough arguments for main::pedal_notes at midi.pl line 107, near "$note)"
BEGIN not safe after errors--compilation aborted at midi.pl line 150.
</code></pre>
I got something similar working in Supercollider though, which has a lot of tools for these sort of things, eg:<p><pre><code> MIDIIn.addFuncTo(\noteOn, ~myNoteOnHandler);</code></pre>