[tools] add release_drop option to aubionotes
authorPaul Brossier <piem@piem.org>
Tue, 30 Oct 2018 11:53:49 +0000 (12:53 +0100)
committerPaul Brossier <piem@piem.org>
Tue, 30 Oct 2018 11:53:49 +0000 (12:53 +0100)
examples/aubionotes.c
examples/parse_args.h
examples/utils.c

index f74063a..339fdaf 100644 (file)
@@ -21,6 +21,7 @@
 #include "utils.h"
 #define PROG_HAS_PITCH 1
 #define PROG_HAS_ONSET 1
+#define PROG_HAS_NOTES 1
 #define PROG_HAS_SILENCE 1
 #define PROG_HAS_JACK 1
 // TODO add PROG_HAS_OUTPUT
@@ -82,6 +83,12 @@ int main(int argc, char **argv) {
           silence_threshold);
     }
   }
+  if (release_drop != 10.) {
+    if (aubio_notes_set_release_drop (notes, release_drop) != 0) {
+      errmsg ("failed setting notes release drop to %.2f\n",
+          release_drop);
+    }
+  }
 
   examples_common_process((aubio_process_func_t)process_block, process_print);
 
index d7dce4a..284a708 100644 (file)
@@ -47,6 +47,7 @@ extern uint_t time_format;
 extern char_t * tempo_method;
 // more general stuff
 extern smpl_t silence_threshold;
+extern smpl_t release_drop;
 extern uint_t mix_input;
 // midi tap
 extern smpl_t miditap_note;
@@ -107,6 +108,10 @@ void usage (FILE * stream, int exit_code)
       "       -s      --silence          select silence threshold\n"
       "                 a value in dB, for instance -70, or -100; default=-90\n"
 #endif /* PROG_HAS_SILENCE */
+#ifdef PROG_HAS_NOTES
+      "       -d      --release-drop     select release drop threshold\n"
+      "                 a positive value in dB; default=10\n"
+#endif
       "       -T      --time-format      select time values output format\n"
       "                 (samples, ms, seconds) default=seconds\n"
 #ifdef PROG_HAS_OUTPUT
@@ -157,6 +162,9 @@ parse_args (int argc, char **argv)
 #ifdef PROG_HAS_SILENCE
     "s:"
 #endif /* PROG_HAS_SILENCE */
+#ifdef PROG_HAS_NOTES
+    "d:"
+#endif /* PROG_HAS_SILENCE */
 #ifdef PROG_HAS_OUTPUT
     "mf"
 #endif /* PROG_HAS_OUTPUT */
@@ -192,6 +200,9 @@ parse_args (int argc, char **argv)
 #ifdef PROG_HAS_SILENCE
     {"silence",               1, NULL, 's'},
 #endif /* PROG_HAS_SILENCE */
+#ifdef PROG_HAS_NOTES
+    {"release-drop",          1, NULL, 'd'},
+#endif /* PROG_HAS_NOTES */
     {"time-format",           1, NULL, 'T'},
 #ifdef PROG_HAS_OUTPUT
     {"mix-input",             0, NULL, 'm'},
@@ -274,6 +285,9 @@ parse_args (int argc, char **argv)
       case 's':                /* silence threshold */
         silence_threshold = (smpl_t) atof (optarg);
         break;
+      case 'd':                /* release-drop threshold */
+        release_drop = (smpl_t) atof (optarg);
+        break;
       case 'm':                /* mix_input flag */
         mix_input = 1;
         break;
index e24d8e8..b3239d2 100644 (file)
@@ -54,6 +54,7 @@ uint_t time_format = 0; // for "seconds", 1 for "ms", 2 for "samples"
 char_t * tempo_method = "default";
 // more general stuff
 smpl_t silence_threshold = -90.;
+smpl_t release_drop = 10.;
 uint_t mix_input = 0;
 
 uint_t force_overwrite = 0;