[Jackaudio] Jack C++ midi structural considerations
k.s.matheussen at gmail.com
Thu Jun 11 15:18:32 CEST 2020
On Thu, Jun 11, 2020 at 3:05 PM Christopher Arndt <chris at chrisarndt.de> wrote:
> Am 11.06.20 um 11:59 schrieb Kjetil Matheussen:
> > On Thu, Jun 11, 2020 at 11:55 AM Kjetil Matheussen <k.s.matheussen at gmail.com> wrote:
> >> On Thu, May 14, 2020 at 6:37 PM Christopher Arndt <chris at chrisarndt.de> wrote:
> >>> http://www.music.mcgill.ca/~gary/rtmidi/index.html
> >> Last time I checked (2012), rtmidi allocated memory here and there
> >> from the system in the realtime thread when sending and receiving MIDI
> >> messages.
> > Yes, it's still using std::vector to store messages in:
> > https://github.com/thestk/rtmidi/blob/master/RtMidi.cpp#L640
> If I interpret the code correctly, you could prevent allocations, if you
Yes, but I don't think this is documented that you should do this. At
least it wasn't in 2012. And why doesn't RtMidi just call reserve(4)
by itself when initializing a message? I reported this problem to the
author, but this was ignored. But even with this workaround, it's a
bad decision to use std::vector in the first place since it allows for
> in 'MidiInJack::initialize'
> (https://github.com/thestk/rtmidi/blob/master/RtMidi.cpp#L3088) and
> ignore SysEx messages. The usual (or at least a common) way to use
> RtMidi is to copy it into your project anway, so you can make any
> changes you like to it.
I think it may call push_back() in the receiver thread whenever you
receive SysEx. Or maybe you can set a flag to always ignore SysEx?
Anyhow, it's messy.
> BTW, I would never use 'getMessage', but attach a callback via
> If you need to handle SysEx messages, you could set the maximum capacity
> with 'reserve' to the size of the biggest SysEx message you expect to
Still messy, but maybe it's possible to avoid allocation now. I don't
think it was in 2012.
More information about the JackAudio