From 3da81878b19a25942a8254804c6dfdb4c6d4e7f0 Mon Sep 17 00:00:00 2001 From: Paul Brossier Date: Fri, 6 Dec 2013 23:22:21 -0500 Subject: [PATCH] examples/: remove -o and -j when unused --- examples/aubionotes.c | 2 ++ examples/aubioonset.c | 7 ++++++- examples/aubiopitch.c | 14 ++++++++------ examples/aubiotrack.c | 7 ++++++- examples/parse_args.h | 36 +++++++++++++++++++++--------------- examples/utils.c | 4 ++-- 6 files changed, 45 insertions(+), 25 deletions(-) diff --git a/examples/aubionotes.c b/examples/aubionotes.c index 0aafabfd..dc57ce8e 100644 --- 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; diff --git a/examples/aubioonset.c b/examples/aubioonset.c index 7a80acc7..d8c7987e 100644 --- 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 @@ process_block(fvec_t *ibuf, fvec_t *obuf) { } 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 diff --git a/examples/aubiopitch.c b/examples/aubiopitch.c index dd615bd6..cf10babb 100644 --- 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 @@ process_block(fvec_t * ibuf, fvec_t * obuf) { 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 diff --git a/examples/aubiotrack.c b/examples/aubiotrack.c index b862c2be..48d4cdc7 100644 --- 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 @@ void process_block(fvec_t * ibuf, fvec_t *obuf) { } 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) { diff --git a/examples/parse_args.h b/examples/parse_args.h index 003f32fc..d016dd1c 100644 --- a/examples/parse_args.h +++ b/examples/parse_args.h @@ -62,11 +62,13 @@ usage (FILE * stream, int exit_code) 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 @@ usage (FILE * stream, int exit_code) " -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 @@ int 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 @@ parse_args (int argc, char **argv) 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 @@ parse_args (int argc, char **argv) } 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 @@ parse_args (int argc, char **argv) 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"); diff --git a/examples/utils.c b/examples/utils.c index f014f854..a3a72778 100644 --- a/examples/utils.c +++ b/examples/utils.c @@ -185,9 +185,9 @@ send_noteon (int pitch, int velo) } 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); } } -- 2.11.0