shithub: aubio

Download patch

ref: 3da81878b19a25942a8254804c6dfdb4c6d4e7f0
parent: 466dff300724c1e61b6aa2e3b1ae3fc398a30ed6
author: Paul Brossier <[email protected]>
date: Fri Dec 6 18:22:21 EST 2013

examples/: remove -o and -j when unused

--- a/examples/aubionotes.c
+++ b/examples/aubionotes.c
@@ -22,6 +22,8 @@
 #include "utils.h"
 #define PROG_HAS_PITCH 1
 #define PROG_HAS_ONSET 1
+#define PROG_HAS_JACK 1
+// TODO add PROG_HAS_OUTPUT
 #include "parse_args.h"
 
 uint_t median = 6;
--- a/examples/aubioonset.c
+++ b/examples/aubioonset.c
@@ -20,6 +20,8 @@
 
 #include "utils.h"
 #define PROG_HAS_ONSET 1
+#define PROG_HAS_OUTPUT 1
+#define PROG_HAS_JACK 1
 #include "parse_args.h"
 
 aubio_onset_t *o;
@@ -35,7 +37,10 @@
   } else {
     aubio_wavetable_stop ( wavetable );
   }
-  aubio_wavetable_do (wavetable, obuf, obuf);
+  if (mix_input)
+    aubio_wavetable_do (wavetable, ibuf, obuf);
+  else
+    aubio_wavetable_do (wavetable, obuf, obuf);
 }
 
 void
--- a/examples/aubiopitch.c
+++ b/examples/aubiopitch.c
@@ -20,6 +20,8 @@
 
 #include "utils.h"
 #define PROG_HAS_PITCH 1
+#define PROG_HAS_OUTPUT 1
+#define PROG_HAS_JACK 1
 #include "parse_args.h"
 
 aubio_pitch_t *o;
@@ -32,12 +34,12 @@
   aubio_pitch_do (o, ibuf, pitch);
   smpl_t freq = fvec_read_sample(pitch, 0);
   aubio_wavetable_set_amp ( wavetable, aubio_level_lin (ibuf) );
-  if (freq != 0.0) {
-    aubio_wavetable_set_freq ( wavetable, freq );
-  } else {
-    aubio_wavetable_set_freq ( wavetable, 0.0 );
-  }
-  aubio_wavetable_do (wavetable, obuf, obuf);
+  aubio_wavetable_set_freq ( wavetable, freq );
+
+  if (mix_input)
+    aubio_wavetable_do (wavetable, ibuf, obuf);
+  else
+    aubio_wavetable_do (wavetable, obuf, obuf);
 }
 
 void
--- a/examples/aubiotrack.c
+++ b/examples/aubiotrack.c
@@ -20,6 +20,8 @@
 
 #include "utils.h"
 #define PROG_HAS_TEMPO 1
+#define PROG_HAS_OUTPUT 1
+#define PROG_HAS_JACK 1
 #include "parse_args.h"
 
 aubio_tempo_t * tempo;
@@ -38,7 +40,10 @@
   } else {
     aubio_wavetable_stop ( wavetable );
   }
-  aubio_wavetable_do (wavetable, obuf, obuf);
+  if (mix_input)
+    aubio_wavetable_do (wavetable, ibuf, obuf);
+  else
+    aubio_wavetable_do (wavetable, obuf, obuf);
 }
 
 void process_print (void) {
--- a/examples/parse_args.h
+++ b/examples/parse_args.h
@@ -62,11 +62,13 @@
   fprintf (stream,
       "       -h      --help             display this message\n"
       "       -v      --verbose          be verbose\n"
-#ifdef HAVE_JACK
+#ifdef PROG_HAS_JACK
       "       -j      --jack             use Jack\n"
 #endif
       "       -i      --input            input type\n"
+#ifdef PROG_HAS_OUTPUT
       "       -o      --output           output type\n"
+#endif
       "       -r      --samplerate       select samplerate\n"
       "       -B      --bufsize          set buffer size\n"
       "       -H      --hopsize          set hopsize\n"
@@ -80,7 +82,9 @@
       "       -l      --pitch-tolerance  select pitch tolerance\n"
 #endif /* PROG_HAS_PITCH */
       "       -s      --silence          select silence threshold\n"
+#ifdef PROG_HAS_OUTPUT
       "       -m      --mix-input        mix input signal with output signal\n"
+#endif
       );
   exit (exit_code);
 }
@@ -89,10 +93,13 @@
 parse_args (int argc, char **argv)
 {
   const char *options = "hv"
-#ifdef HAVE_JACK
+    "i:r:B:H:"
+#ifdef PROG_HAS_JACK
     "j"
-#endif
-    "i:o:r:B:H:"
+#endif /* PROG_HAS_JACK */
+#ifdef PROG_HAS_OUTPUT
+    "o:"
+#endif /* PROG_HAS_OUTPUT */
 #ifdef PROG_HAS_ONSET
     "O:t:"
 #endif /* PROG_HAS_ONSET */
@@ -104,14 +111,16 @@
   struct option long_options[] = {
     {"help",                  0, NULL, 'h'},
     {"verbose",               0, NULL, 'v'},
-#ifdef HAVE_JACK
-    {"jack",                  0, NULL, 'j'},
-#endif
     {"input",                 1, NULL, 'i'},
-    {"output",                1, NULL, 'o'},
     {"samplerate",            1, NULL, 'r'},
     {"bufsize",               1, NULL, 'B'},
     {"hopsize",               1, NULL, 'H'},
+#ifdef PROG_HAS_JACK
+    {"jack",                  0, NULL, 'j'},
+#endif /* PROG_HAS_JACK */
+#ifdef PROG_HAS_OUTPUT
+    {"output",                1, NULL, 'o'},
+#endif /* PROG_HAS_OUTPUT */
 #ifdef PROG_HAS_ONSET
     {"onset",                 1, NULL, 'O'},
     {"onset-threshold",       1, NULL, 't'},
@@ -190,6 +199,7 @@
   }
   while (next_option != -1);
 
+  // if unique, use the non option argument as the source
   if ( source_uri == NULL ) {
     if (argc - optind == 1) {
       source_uri = argv[optind];
@@ -202,14 +212,10 @@
     usage ( stderr, 1 );
   }
 
-  if (source_uri != NULL) {
-    debug ("Input file : %s\n", source_uri);
-  } else if (source_uri != NULL && sink_uri != NULL) {
-    debug ("Input file : %s\n", source_uri);
-    debug ("Output file : %s\n", sink_uri);
-  } else {
+  // if no source, show a message
+  if (source_uri == NULL) {
 #if HAVE_JACK
-    debug ("Jack input output\n");
+    verbmsg("No input source given, using jack\n");
     usejack = 1;
 #else
     errmsg("Error: no arguments given (and no available audio input)\n");
--- a/examples/utils.c
+++ b/examples/utils.c
@@ -185,9 +185,9 @@
   } else
 #endif
   if (velo == 0) {
-    outmsg ("%f\n", blocks * hop_size / (float) samplerate);
+    verbmsg ("%f\n", blocks * hop_size / (float) samplerate);
   } else {
-    outmsg ("%f\t%f\t", mpitch, blocks * hop_size / (float) samplerate);
+    verbmsg ("%f\t%f\t", mpitch, blocks * hop_size / (float) samplerate);
   }
 }