Changeset ebbf5a0 for examples/utils.c


Ignore:
Timestamp:
Sep 25, 2009, 9:56:22 PM (15 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
Children:
bab0a12
Parents:
c201306
Message:

examples/utils.{c,h}: remove old midi_player stuff, use new jack midi function

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/utils.c

    rc201306 rebbf5a0  
    8383smpl_t curlevel = 0.;
    8484smpl_t maxonset = 0.;
    85 
    86 /* midi objects */
    87 aubio_midi_player_t *mplay;
    88 aubio_midi_driver_t *mdriver;
    89 aubio_midi_event_t *event;
    9085
    9186smpl_t curnote = 0.;
     
    247242    debug ("Output file : %s\n", output_filename);
    248243  } else {
    249     if (HAVE_JACK) {
    250       debug ("Jack input output\n");
    251       usejack = 1;
    252     } else {
    253       debug
    254           ("Error: Could not switch to jack mode\n   aubio was compiled without jack support\n");
    255       exit (1);
    256     }
     244#if HAVE_JACK
     245    debug ("Jack input output\n");
     246    usejack = 1;
     247#else
     248    debug
     249        ("Error: Could not switch to jack mode\n   aubio was compiled without jack support\n");
     250    exit (1);
     251#endif
    257252  }
    258253
     
    371366}
    372367
     368#if HAVE_JACK
     369aubio_jack_t *jack_setup;
     370#endif
     371
    373372void
    374373examples_common_process (aubio_process_func_t process_func,
     
    376375{
    377376  if (usejack) {
     377
    378378#if HAVE_JACK
    379     aubio_jack_t *jack_setup;
    380379    debug ("Jack init ...\n");
    381380    jack_setup = new_aubio_jack (channels, channels,
    382         1, 1, (aubio_process_func_t) process_func);
    383     if (usepitch) {
    384       debug ("Midi init ...\n");
    385       mplay = new_aubio_midi_player ();
    386       mdriver = new_aubio_midi_driver ("alsa_seq",
    387           (handle_midi_event_func_t) aubio_midi_send_event, mplay);
    388       event = new_aubio_midi_event ();
    389     }
     381        0, 1, (aubio_process_func_t) process_func);
    390382    debug ("Jack activation ...\n");
    391383    aubio_jack_activate (jack_setup);
     
    393385    pause ();
    394386    aubio_jack_close (jack_setup);
    395     if (usepitch) {
    396       send_noteon (curnote, 0);
    397       del_aubio_midi_driver (mdriver);
    398     }
    399387#else
    400388    usage (stderr, 1);
     
    445433}
    446434
    447 
    448435void
    449436send_noteon (int pitch, int velo)
    450437{
    451438  smpl_t mpitch = floor (aubio_freqtomidi (pitch) + .5);
    452   /* we should check if we use midi here, not jack */
    453 #if HAVE_ALSA
     439#if HAVE_JACK
     440  jack_midi_event_t ev;
     441  ev.size = 3;
     442  ev.buffer = malloc (3 * sizeof (jack_midi_data_t)); // FIXME
     443  ev.time = 0;
    454444  if (usejack) {
     445    ev.buffer[2] = velo;
     446    ev.buffer[1] = mpitch;
    455447    if (velo == 0) {
    456       aubio_midi_event_set_type (event, NOTE_OFF);
     448      ev.buffer[0] = 0x80;      /* note off */
    457449    } else {
    458       aubio_midi_event_set_type (event, NOTE_ON);
    459     }
    460     aubio_midi_event_set_channel (event, 0);
    461     aubio_midi_event_set_pitch (event, mpitch);
    462     aubio_midi_event_set_velocity (event, velo);
    463     aubio_midi_direct_output (mdriver, event);
     450      ev.buffer[0] = 0x90;      /* note on */
     451    }
     452    aubio_jack_midi_event_write (jack_setup, (jack_midi_event_t *) & ev);
    464453  } else
    465454#endif
Note: See TracChangeset for help on using the changeset viewer.