From 9562f08dfbe9c2ceb0ac8cb1d8973831fda53dd2 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 22 Jul 2016 21:30:31 +0200 Subject: [PATCH] examples/utils.c: change send_noteon to accept floating point midi note number --- examples/aubionotes.c | 11 ++++++----- examples/utils.c | 7 +++---- examples/utils.h | 2 +- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/examples/aubionotes.c b/examples/aubionotes.c index 31e52512..75410987 100644 --- a/examples/aubionotes.c +++ b/examples/aubionotes.c @@ -26,19 +26,20 @@ #include "parse_args.h" aubio_notes_t *notes; -uint_t lastnote = 0; +smpl_t lastmidi = 0.; void process_block (fvec_t *ibuf, fvec_t *obuf) { aubio_notes_do (notes, ibuf, obuf); // did we get a note off? if (obuf->data[2] != 0) { - send_noteon(obuf->data[2], 0); + lastmidi = aubio_freqtomidi (obuf->data[2]) + .5; + send_noteon(lastmidi, 0); } // did we get a note on? if (obuf->data[0] != 0) { - send_noteon(obuf->data[0], obuf->data[1]); - lastnote = (uint_t) floor(obuf->data[0]); + lastmidi = aubio_freqtomidi (obuf->data[0]) + .5; + send_noteon(lastmidi, obuf->data[1]); } } @@ -67,7 +68,7 @@ int main(int argc, char **argv) { examples_common_process((aubio_process_func_t)process_block, process_print); // send a last note off - send_noteon (lastnote, 0); + send_noteon (lastmidi, 0); del_aubio_notes (notes); diff --git a/examples/utils.c b/examples/utils.c index 39d46bba..dc273867 100644 --- a/examples/utils.c +++ b/examples/utils.c @@ -181,9 +181,8 @@ void examples_common_process (aubio_process_func_t process_func, } void -send_noteon (int pitch, int velo) +send_noteon (smpl_t pitch, smpl_t velo) { - smpl_t mpitch = floor (aubio_freqtomidi (pitch) + .5); #ifdef HAVE_JACK jack_midi_event_t ev; ev.size = 3; @@ -191,7 +190,7 @@ send_noteon (int pitch, int velo) ev.time = 0; if (usejack) { ev.buffer[2] = velo; - ev.buffer[1] = mpitch; + ev.buffer[1] = pitch; if (velo == 0) { ev.buffer[0] = 0x80; /* note off */ } else { @@ -204,7 +203,7 @@ send_noteon (int pitch, int velo) print_time (blocks * hop_size); outmsg ("\n"); } else { - outmsg ("%f\t", mpitch); + outmsg ("%f\t", pitch); print_time (blocks * hop_size); outmsg ("\t"); } diff --git a/examples/utils.h b/examples/utils.h index c9587dd9..e911bef4 100644 --- a/examples/utils.h +++ b/examples/utils.h @@ -63,7 +63,7 @@ #endif typedef void (aubio_print_func_t) (void); -void send_noteon (int pitch, int velo); +void send_noteon (smpl_t pitch, smpl_t velo); /** common process function */ typedef int (*aubio_process_func_t) (fvec_t * input, fvec_t * output); -- 2.11.0