ref: 9562f08dfbe9c2ceb0ac8cb1d8973831fda53dd2
parent: f280ebd4782996de802dd45fb6e624c43b8c402e
author: Paul Brossier <piem@piem.org>
date: Fri Jul 22 17:30:31 EDT 2016
examples/utils.c: change send_noteon to accept floating point midi note number
--- a/examples/aubionotes.c
+++ b/examples/aubionotes.c
@@ -26,7 +26,7 @@
#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)
{
@@ -33,12 +33,13 @@
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 @@
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);
--- a/examples/utils.c
+++ b/examples/utils.c
@@ -181,9 +181,8 @@
}
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 @@
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 @@
print_time (blocks * hop_size);
outmsg ("\n");
} else {
- outmsg ("%f\t", mpitch);
+ outmsg ("%f\t", pitch);
print_time (blocks * hop_size);
outmsg ("\t");
}
--- 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);