Skip to content

rework jack input to a process() callback

Jarrad Whitaker requested to merge akdor1154/midi2input:rework-jack into master

[Preface to the following: I am neither a C/C++ guy nor a Jack guy nor even a DSP guy, may be wrong on any / all counts.]

The existing event loop based system didn't work on my machine (see #56 (closed)). I've had a look at the Jack code and I think the issue is that processing doesn't happen in a callback; Jack2 seems to want processing code to happen that way instead of a processing loop (based on what meagre documentation and examples I could find). I've rewritten the Jack input (output code remains untouched) code in the style of a couple of MIDI processing examples I found, see for reference: https://github.com/jackaudio/jackaudio.github.com/wiki/WalkThrough_Dev_SimpleMidiClient https://github.com/jackaudio/jack2/blob/develop/example-clients/midi_dump.c

The arch now is Jack process callback writes to a ringbuffer on-demand, and the read system has now been changes to just read from this ringbuffer.

An alternative approach would be to event/callback-ise the whole thing, and pull Jack processing outside of m2i's loop.. but that seems hard! Also you'd lose the symmetry of the Jack/ALSA approaches. So I didn't have much motivation to go that way :)

I've tested this by playing Double Kick Heroes for twenty minutes on my Ubuntu box with it: Latency beats ALSA MIDI and it didn't crash or miss any keyups.

As said above: I'm not a C/C++ guy, if you are gonna consider merging this I would be looking suspiciously at my code for newbie errors, sorry.

Thanks for this software, it seems really nicely architected and is great to both use and hack on. (also cpack deb building built in!!)

Edited by Jarrad Whitaker

Merge request reports