shithub: aubio

Download patch

ref: f7771c6b56efec1966fc01a4a56169d9325af040
parent: 230101d2de1f7e3c993dc16e3ac57d3cbacdd07c
author: cyclopsian <cycl0ps@tuta.io>
date: Sun Sep 16 18:31:55 EDT 2018

Fix examples failing to send more than one JACK midi event per frame

--- a/examples/utils.c
+++ b/examples/utils.c
@@ -75,8 +75,11 @@
 extern int parse_args (int argc, char **argv);
 
 #if HAVE_JACK
+#define MAX_MIDI_EVENTS 128
 aubio_jack_t *jack_setup;
 jack_midi_event_t ev;
+jack_midi_data_t midi_data[MAX_MIDI_EVENTS * 3];
+size_t midi_event_count = 0;
 #endif /* HAVE_JACK */
 
 void examples_common_init (int argc, char **argv);
@@ -128,9 +131,6 @@
 
 void examples_common_del (void)
 {
-#ifdef HAVE_JACK
-  if (ev.buffer) free(ev.buffer);
-#endif
   del_fvec (ibuf);
   del_fvec (obuf);
   aubio_cleanup ();
@@ -147,7 +147,6 @@
 
 #ifdef HAVE_JACK
     ev.size = 3;
-    ev.buffer = malloc (3 * sizeof (jack_midi_data_t));
     ev.time = 0; // send it now
     debug ("Jack activation ...\n");
     aubio_jack_activate (jack_setup, process_func);
@@ -193,6 +192,10 @@
 {
 #ifdef HAVE_JACK
   if (usejack) {
+    ev.buffer = midi_data + midi_event_count++ * 3;
+    if (midi_event_count >= MAX_MIDI_EVENTS) {
+      midi_event_count = 0;
+    }
     ev.buffer[2] = velo;
     ev.buffer[1] = pitch;
     if (velo == 0) {