[tests] add run_on_default_source_and_sink helper
[aubio.git] / examples / parse_args.h
index fd8e338..f8c33d2 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;
@@ -64,8 +65,8 @@ int parse_args (int argc, char **argv);
 // internal stuff
 extern int blocks;
 
-extern fvec_t *ibuf;
-extern fvec_t *obuf;
+extern fvec_t *input_buffer;
+extern fvec_t *output_buffer;
 
 const char *prog_name;
 
@@ -93,11 +94,11 @@ void usage (FILE * stream, int exit_code)
       "       -t      --onset-threshold  set onset detection threshold\n"
       "                 a value between 0.1 (more detections) and 1 (less); default=0.3\n"
       "       -M      --minioi           set minimum inter-onset interval\n"
-      "                 a value in millisecond; default=12.\n"
+      "                 a value in second; default=0.012\n"
 #endif /* PROG_HAS_ONSET */
 #ifdef PROG_HAS_PITCH
       "       -p      --pitch            select pitch detection algorithm\n"
-      "                 <default|yinfft|yin|mcomb|fcomb|schmitt>; default=yinfft\n"
+      "                 <default|yinfft|yinfast|yin|mcomb|fcomb|schmitt>; default=yinfft\n"
       "       -u      --pitch-unit       select pitch output unit\n"
       "                 <default|freq|hertz|Hz|midi|cent|bin>; default=freq\n"
       "       -l      --pitch-tolerance  select pitch tolerance\n"
@@ -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
@@ -115,9 +120,13 @@ void usage (FILE * stream, int exit_code)
       "       -f      --force-overwrite  overwrite output file if needed\n"
       "                 do not fail if output file already exists\n"
 #endif /* PROG_HAS_OUTPUT */
-#ifdef PROG_HAS_JACK
+#if defined(PROG_HAS_JACK) && defined(HAVE_JACK)
       "       -j      --jack             use Jack\n"
-#endif /* PROG_HAS_JACK */
+#if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
+      "       -N      --miditap-note     MIDI note; default=69.\n"
+      "       -V      --miditap-velo     MIDI velocity; default=65.\n"
+#endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */
+#endif /* defined(PROG_HAS_JACK) && defined(HAVE_JACK) */
       "       -v      --verbose          be verbose\n"
       "       -h      --help             display this message\n"
       );
@@ -136,6 +145,9 @@ parse_args (int argc, char **argv)
     "i:r:B:H:"
 #ifdef PROG_HAS_JACK
     "j"
+#if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
+    "N:V:"
+#endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */
 #endif /* PROG_HAS_JACK */
 #ifdef PROG_HAS_OUTPUT
     "o:"
@@ -150,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 */
@@ -164,6 +179,10 @@ parse_args (int argc, char **argv)
     {"hopsize",               1, NULL, 'H'},
 #ifdef PROG_HAS_JACK
     {"jack",                  0, NULL, 'j'},
+#if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
+    {"miditap-note",          1, NULL, 'N'},
+    {"miditap-velo",          1, NULL, 'V'},
+#endif /* PROG_HAS_ONSET !PROG_HAS_PITCH */
 #endif /* PROG_HAS_JACK */
 #ifdef PROG_HAS_OUTPUT
     {"output",                1, NULL, 'o'},
@@ -181,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'},
@@ -189,11 +211,11 @@ parse_args (int argc, char **argv)
     {NULL,                    0, NULL, 0}
   };
 #endif /* HAVE_GETOPT_H */
-  prog_name = argv[0];
+  // better safe than sorry
   if (argc < 1) {
     usage (stderr, 1);
-    return -1;
   }
+  prog_name = argv[0];
 #ifdef HAVE_GETOPT_H
   do {
     next_option = getopt_long (argc, argv, options, long_options, NULL);
@@ -207,6 +229,12 @@ parse_args (int argc, char **argv)
       case 'j':
         usejack = 1;
         break;
+      case 'N':
+        miditap_note = (smpl_t) atoi (optarg);
+        break;
+      case 'V':
+        miditap_velo = (smpl_t) atoi (optarg);
+        break;
       case 'i':
         source_uri = optarg;
         break;
@@ -231,7 +259,7 @@ parse_args (int argc, char **argv)
       case 't':                /* threshold value for onset */
         onset_threshold = (smpl_t) atof (optarg);
         break;
-      case 'M':                /* threshold value for onset */
+      case 'M':                /* minimum inter-onset-interval */
         onset_minioi = (smpl_t) atof (optarg);
         break;
       case 'p':
@@ -257,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;
@@ -296,7 +327,8 @@ parse_args (int argc, char **argv)
     usejack = 1;
 #else
     errmsg("Error: no arguments given (and no available audio input)\n");
-    usage ( stderr, 1 );
+    errmsg("       consider recompiling with jack support (--enable-jack)\n");
+    exit ( 1 );
 #endif /* HAVE_JACK */
 #else
     errmsg("Error: no arguments given\n");