12 #include <math.h> /* for isfinite */
16 #include <ladcca/ladcca.h>
17 cca_client_t * aubio_cca_client;
18 #endif /* LADCCA_SUPPORT */
21 /* badly redeclare some things */
22 aubio_onsetdetection_type type_onset;
25 const char * prog_name;
27 void usage (FILE * stream, int exit_code)
29 fprintf(stream, "usage: %s [ options ] \n", prog_name);
31 " -j --jack Use Jack.\n"
32 " -o --output Output type.\n"
33 " -i --input Input type.\n"
34 " -h --help Display this message.\n"
35 " -v --verbose Print verbose message.\n"
40 int parse_args (int argc, char **argv) {
41 const char *options = "hvjo:i:O:t:a";
43 struct option long_options[] =
45 {"help", 0, NULL, 'h'},
46 {"verbose", 0, NULL, 'v'},
47 {"jack", 0, NULL, 'j'},
48 {"output", 0, NULL, 'o'},
49 {"input", 0, NULL, 'i'},
50 {"onset", 0, NULL, 'O'},
51 {"threshold", 0, NULL, 't'},
52 {"averaging", 0, NULL, 'a'},
61 next_option = getopt_long (argc, argv, options,
63 switch (next_option) {
65 output_filename = optarg;
68 input_filename = optarg;
73 case 'v': /* verbose */
76 case 'j': /* verbose */
79 case 'O': /*onset type*/
80 if (strcmp(optarg,"energy") == 0)
82 else if (strcmp(optarg,"specdiff") == 0)
83 type_onset = specdiff;
84 else if (strcmp(optarg,"hfc") == 0)
86 else if (strcmp(optarg,"complexdomain") == 0)
87 type_onset = complexdomain;
88 else if (strcmp(optarg,"phase") == 0)
91 debug("could not get onset type.\n");
95 case 't': /* threshold value for onset */
96 threshold = (smpl_t)atof(optarg);
98 if (!isfinite(threshold)) {
99 debug("could not get threshold.\n");
107 case '?': /* unknown options */
110 case -1: /* done with options */
112 default: /*something else unexpected */
116 while (next_option != -1);
118 if (input_filename != NULL) {
119 errmsg ("Input file : %s\n", input_filename );
120 } else if (input_filename != NULL && output_filename != NULL) {
121 errmsg ("Input file : %s\n", input_filename );
122 errmsg ("Output file : %s\n", output_filename );
126 errmsg ("Jack input output\n");
129 errmsg ("Error: Could not switch to jack mode\n aubio was compiled without jack support\n");