examples/aubionotes.c: use new notes, set minioi, send last note off when needed
authorPaul Brossier <piem@piem.org>
Sat, 17 Dec 2016 11:16:59 +0000 (12:16 +0100)
committerPaul Brossier <piem@piem.org>
Sat, 17 Dec 2016 11:16:59 +0000 (12:16 +0100)
examples/aubionotes.c

index f5f3f1e..f74063a 100644 (file)
@@ -34,12 +34,12 @@ 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) {
   aubio_notes_do (notes, ibuf, obuf);
   // did we get a note off?
   if (obuf->data[2] != 0) {
-    lastmidi = aubio_freqtomidi (obuf->data[2]) + .5;
+    lastmidi = obuf->data[2];
     send_noteon(lastmidi, 0);
   }
   // did we get a note on?
   if (obuf->data[0] != 0) {
     send_noteon(lastmidi, 0);
   }
   // did we get a note on?
   if (obuf->data[0] != 0) {
-    lastmidi = aubio_freqtomidi (obuf->data[0]) + .5;
+    lastmidi = obuf->data[0];
     send_noteon(lastmidi, obuf->data[1]);
   }
 }
     send_noteon(lastmidi, obuf->data[1]);
   }
 }
@@ -70,8 +70,7 @@ int main(int argc, char **argv) {
   if (notes == NULL) { ret = 1; goto beach; }
 
   if (onset_minioi != 0.) {
   if (notes == NULL) { ret = 1; goto beach; }
 
   if (onset_minioi != 0.) {
-    errmsg ("warning: onset minioio not supported yet\n");
-    //aubio_onset_set_minioi_ms(aubio_notes_get_aubio_onset(o), onset_minioi);
+    aubio_notes_set_minioi_ms(notes, onset_minioi);
   }
   if (onset_threshold != 0.) {
     errmsg ("warning: onset threshold not supported yet\n");
   }
   if (onset_threshold != 0.) {
     errmsg ("warning: onset threshold not supported yet\n");
@@ -86,8 +85,8 @@ int main(int argc, char **argv) {
 
   examples_common_process((aubio_process_func_t)process_block, process_print);
 
 
   examples_common_process((aubio_process_func_t)process_block, process_print);
 
-  // send a last note off
-  if (usejack) {
+  // send a last note off if required
+  if (lastmidi) {
     send_noteon (lastmidi, 0);
   }
 
     send_noteon (lastmidi, 0);
   }