From: Paul Brossier Date: Thu, 12 Jan 2017 22:56:28 +0000 (+0100) Subject: examples/utils.c: allocate note event once X-Git-Tag: 0.4.5~106 X-Git-Url: https://git.aubio.org/?p=aubio.git;a=commitdiff_plain;h=8f0db97aa21e79992fda5b3a790991e9f2015834 examples/utils.c: allocate note event once --- diff --git a/examples/utils.c b/examples/utils.c index 296c6c36..39adef9d 100644 --- a/examples/utils.c +++ b/examples/utils.c @@ -76,6 +76,7 @@ extern int parse_args (int argc, char **argv); #if HAVE_JACK aubio_jack_t *jack_setup; +jack_midi_event_t ev; #endif /* HAVE_JACK */ void examples_common_init (int argc, char **argv); @@ -127,6 +128,9 @@ void examples_common_init (int argc, char **argv) void examples_common_del (void) { +#ifdef HAVE_JACK + if (ev.buffer) free(ev.buffer); +#endif del_fvec (ibuf); del_fvec (obuf); aubio_cleanup (); @@ -142,6 +146,9 @@ void examples_common_process (aubio_process_func_t process_func, if (usejack) { #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); debug ("Processing (Ctrl+C to quit) ...\n"); @@ -185,10 +192,6 @@ void send_noteon (smpl_t pitch, smpl_t velo) { #ifdef HAVE_JACK - jack_midi_event_t ev; - ev.size = 3; - ev.buffer = malloc (3 * sizeof (jack_midi_data_t)); // FIXME - ev.time = 0; if (usejack) { ev.buffer[2] = velo; ev.buffer[1] = pitch;