From ebbf5a0ba5310e82e6f8579c3f927f8f83d7debb Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 25 Sep 2009 21:56:22 +0200 Subject: [PATCH] examples/utils.{c,h}: remove old midi_player stuff, use new jack midi function --- examples/utils.c | 59 ++++++++++++++++++++---------------------------- examples/utils.h | 6 +---- 2 files changed, 25 insertions(+), 40 deletions(-) diff --git a/examples/utils.c b/examples/utils.c index 14ac3153..64d7ee20 100644 --- a/examples/utils.c +++ b/examples/utils.c @@ -83,11 +83,6 @@ fvec_t *note_buffer2 = NULL; smpl_t curlevel = 0.; smpl_t maxonset = 0.; -/* midi objects */ -aubio_midi_player_t *mplay; -aubio_midi_driver_t *mdriver; -aubio_midi_event_t *event; - smpl_t curnote = 0.; smpl_t newnote = 0.; uint_t isready = 0; @@ -246,14 +241,14 @@ parse_args (int argc, char **argv) debug ("Input file : %s\n", input_filename); debug ("Output file : %s\n", output_filename); } else { - if (HAVE_JACK) { - debug ("Jack input output\n"); - usejack = 1; - } else { - debug - ("Error: Could not switch to jack mode\n aubio was compiled without jack support\n"); - exit (1); - } +#if HAVE_JACK + debug ("Jack input output\n"); + usejack = 1; +#else + debug + ("Error: Could not switch to jack mode\n aubio was compiled without jack support\n"); + exit (1); +#endif } return 0; @@ -370,32 +365,25 @@ examples_common_del (void) aubio_cleanup (); } +#if HAVE_JACK +aubio_jack_t *jack_setup; +#endif + void examples_common_process (aubio_process_func_t process_func, aubio_print_func_t print) { if (usejack) { + #if HAVE_JACK - aubio_jack_t *jack_setup; debug ("Jack init ...\n"); jack_setup = new_aubio_jack (channels, channels, - 1, 1, (aubio_process_func_t) process_func); - if (usepitch) { - debug ("Midi init ...\n"); - mplay = new_aubio_midi_player (); - mdriver = new_aubio_midi_driver ("alsa_seq", - (handle_midi_event_func_t) aubio_midi_send_event, mplay); - event = new_aubio_midi_event (); - } + 0, 1, (aubio_process_func_t) process_func); debug ("Jack activation ...\n"); aubio_jack_activate (jack_setup); debug ("Processing (Ctrl+C to quit) ...\n"); pause (); aubio_jack_close (jack_setup); - if (usepitch) { - send_noteon (curnote, 0); - del_aubio_midi_driver (mdriver); - } #else usage (stderr, 1); outmsg ("Compiled without jack output, exiting.\n"); @@ -444,23 +432,24 @@ flush_process (aubio_process_func_t process_func, aubio_print_func_t print) } } - void send_noteon (int pitch, int velo) { smpl_t mpitch = floor (aubio_freqtomidi (pitch) + .5); - /* we should check if we use midi here, not jack */ -#if HAVE_ALSA +#if 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] = mpitch; if (velo == 0) { - aubio_midi_event_set_type (event, NOTE_OFF); + ev.buffer[0] = 0x80; /* note off */ } else { - aubio_midi_event_set_type (event, NOTE_ON); + ev.buffer[0] = 0x90; /* note on */ } - aubio_midi_event_set_channel (event, 0); - aubio_midi_event_set_pitch (event, mpitch); - aubio_midi_event_set_velocity (event, velo); - aubio_midi_direct_output (mdriver, event); + aubio_jack_midi_event_write (jack_setup, (jack_midi_event_t *) & ev); } else #endif if (!verbose) { diff --git a/examples/utils.h b/examples/utils.h index 52e73e59..1228a152 100644 --- a/examples/utils.h +++ b/examples/utils.h @@ -24,6 +24,7 @@ #include #include #include /* for isfinite */ +#include /* for strcmp */ #include #include @@ -114,11 +115,6 @@ extern fvec_t *note_buffer2; extern smpl_t curlevel; extern smpl_t maxonset; -/* midi objects */ -extern aubio_midi_player_t *mplay; -extern aubio_midi_driver_t *mdriver; -extern aubio_midi_event_t *event; - extern smpl_t curnote; extern smpl_t newnote; extern uint_t isready; -- 2.26.2