ref: d47ad546cd9e72f37de236ae07684690e5512b2b
parent: 8c4918aeede6ca3a73d61c5a8aa49c4c12f25c9b
parent: f7771c6b56efec1966fc01a4a56169d9325af040
author: Paul Brossier <piem@piem.org>
date: Mon Sep 17 09:47:22 EDT 2018
Merge branch 'jack-midi-buffer-fix' of https://github.com/cyclopsian/aubio into fix/jack-midi-buffer
--- 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) {