<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Tue, Dec 20, 2016 at 11:09 AM, ROBERT WOLF <span dir="ltr"><<a href="mailto:robert.wolf@hercsmusicsystems.com.au" target="_blank">robert.wolf@hercsmusicsystems.com.au</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
  

    
  
  <div bgcolor="#FFFFFF" text="#000000">
    Dear All,<br></div></blockquote><div><br></div><div>Hi Robert,<br></div><div>  <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    What exactly is the difference between <b>jack_midi_event_reserve</b>
    and <b>jack_midi_event_write</b> ?<br></div></blockquote><div><br></div><div>From my understanding:<br></div><div>- event_reserve() takes "size" number of bytes from JACKs internal MIDI buffers for a particular port, and returns the address to that buffer. Your application can now write to that pointer, and once the RT callback is done, JACK will transmit the data.<br><br></div><div>- event_write() takes a pointer from your application, and copies the data pointed to into the JACK internal midi buffer. Your application can re-use or delete the buffer you passed to the event_write() function now, as JACK has a copy of the data.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    In particular, if I call <b>jack_midi_event_write</b>, does it
    actually copy the data from the buffer, which I provide?<br>
    Or does it use that same buffer.<br></div></blockquote><div><br></div><div>See above.<br></div><div>  <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div bgcolor="#FFFFFF" text="#000000">
    Another question is how can I send midi events generated from GUI,
    (which does not run in the audio callback)?<br>
    My guess is to cache them somewhere and transmit them inside the
    callback?<br>
    Am I guessing correctly?<a href="http://lists.jackaudio.org/listinfo.cgi/jack-devel-jackaudio.org" rel="noreferrer" target="_blank"></a></div></blockquote></div><br></div><div class="gmail_extra">In short: Yes. You need to transfer the MIDI data to be sent between two threads - this can be trivial with mutexs/semaphors/locking systems, but keep in mind that your real-time thread must *never* block. Personally, I am a big proponent of message passing, instead of locking based systems.<br><br></div><div class="gmail_extra">To answer your question, I would use a ringbuffer (jack has a ringbuffer t) to move a message (struct with some metadata) to transfer an event (midi note one) between the GUI to JACK thread.<br></div><div class="gmail_extra"><br></div><div class="gmail_extra">Hope that helps, -Harry<br clear="all"></div><div class="gmail_extra"><br>-- <br><div class="gmail_signature" data-smartmail="gmail_signature"><br><a href="http://www.openavproductions.com" target="_blank">http://www.openavproductions.com</a></div>
</div></div>