[examples] add quiet mode for performance measurements
authorPaul Brossier <piem@piem.org>
Thu, 31 Jan 2019 02:24:19 +0000 (03:24 +0100)
committerPaul Brossier <piem@piem.org>
Thu, 31 Jan 2019 02:24:19 +0000 (03:24 +0100)
examples/parse_args.h
examples/utils.c

index f8c33d2..2336f45 100644 (file)
@@ -25,6 +25,7 @@
 #endif
 
 extern int verbose;
 #endif
 
 extern int verbose;
+extern int quiet;
 // input / output
 extern int usejack;
 extern char_t *source_uri;
 // input / output
 extern int usejack;
 extern char_t *source_uri;
@@ -127,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) */
       "       -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"
       );
       "       -v      --verbose          be verbose\n"
       "       -h      --help             display this message\n"
       );
@@ -141,7 +143,7 @@ int
 parse_args (int argc, char **argv)
 {
 #ifdef HAVE_GETOPT_H
 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"
     "i:r:B:H:"
 #ifdef PROG_HAS_JACK
     "j"
@@ -173,6 +175,7 @@ parse_args (int argc, char **argv)
   struct option long_options[] = {
     {"help",                  0, NULL, 'h'},
     {"verbose",               0, NULL, 'v'},
   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'},
     {"input",                 1, NULL, 'i'},
     {"samplerate",            1, NULL, 'r'},
     {"bufsize",               1, NULL, 'B'},
@@ -226,6 +229,9 @@ parse_args (int argc, char **argv)
       case 'v':                /* verbose */
         verbose = 1;
         break;
       case 'v':                /* verbose */
         verbose = 1;
         break;
+      case 'q':                /* quiet */
+        quiet = 1;
+        break;
       case 'j':
         usejack = 1;
         break;
       case 'j':
         usejack = 1;
         break;
index c8e44a3..01c308d 100644 (file)
@@ -32,6 +32,7 @@
 #endif /* HAVE_JACK */
 
 int verbose = 0;
 #endif /* HAVE_JACK */
 
 int verbose = 0;
+int quiet = 0;
 int usejack = 0;
 // input / output
 char_t *sink_uri = NULL;
 int usejack = 0;
 // input / output
 char_t *sink_uri = NULL;
@@ -169,7 +170,7 @@ void examples_common_process (aubio_process_func_t process_func,
       aubio_source_do (this_source, input_buffer, &read);
       process_func (input_buffer, output_buffer);
       // print to console if verbose or no output given
       aubio_source_do (this_source, input_buffer, &read);
       process_func (input_buffer, output_buffer);
       // print to console if verbose or no output given
-      if (verbose || sink_uri == NULL) {
+      if ((verbose || sink_uri == NULL) && !quiet) {
         print();
       }
       if (this_sink) {
         print();
       }
       if (this_sink) {