[Jackaudio] Jack C++ midi structural considerations

Christopher Arndt chris at chrisarndt.de
Thu Jun 11 15:07:10 CEST 2020


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
call

	data->rtMidiIn->message.reserve(4)

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.

BTW, I would never use 'getMessage', but attach a callback via
'RtMidiIn::setCallback'.

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
handle.


Chris


More information about the JackAudio mailing list