[ci] add pip install to readthedocs.yaml
[aubio.git] / examples / parse_args.h
index d7dce4a..2336f45 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 
 extern int verbose;
+extern int quiet;
 // input / output
 extern int usejack;
 extern char_t *source_uri;
@@ -47,6 +48,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 +66,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;
 
@@ -107,6 +109,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
@@ -122,6 +128,7 @@ void usage (FILE * stream, int exit_code)
       "       -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) */
+      "       -q      --quiet            be quiet\n"
       "       -v      --verbose          be verbose\n"
       "       -h      --help             display this message\n"
       );
@@ -136,7 +143,7 @@ int
 parse_args (int argc, char **argv)
 {
 #ifdef HAVE_GETOPT_H
-  const char *options = "hv"
+  const char *options = "hvq"
     "i:r:B:H:"
 #ifdef PROG_HAS_JACK
     "j"
@@ -157,6 +164,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 */
@@ -165,6 +175,7 @@ parse_args (int argc, char **argv)
   struct option long_options[] = {
     {"help",                  0, NULL, 'h'},
     {"verbose",               0, NULL, 'v'},
+    {"quiet",                 0, NULL, 'q'},
     {"input",                 1, NULL, 'i'},
     {"samplerate",            1, NULL, 'r'},
     {"bufsize",               1, NULL, 'B'},
@@ -192,6 +203,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'},
@@ -200,11 +214,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);
@@ -215,6 +229,9 @@ parse_args (int argc, char **argv)
       case 'v':                /* verbose */
         verbose = 1;
         break;
+      case 'q':                /* quiet */
+        quiet = 1;
+        break;
       case 'j':
         usejack = 1;
         break;
@@ -274,6 +291,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;