12 #include <math.h> /* for isfinite */
15 /* not supported yet */
17 #include <ladcca/ladcca.h>
18 cca_client_t * aubio_cca_client;
19 #endif /* LADCCA_SUPPORT */
22 /* badly redeclare some things */
23 aubio_onsetdetection_type type_onset;
26 const char * prog_name;
28 void usage (FILE * stream, int exit_code)
30 fprintf(stream, "usage: %s [ options ] \n", prog_name);
32 " -j --jack Use Jack.\n"
33 " -o --output Output type.\n"
34 " -i --input Input type.\n"
35 " -h --help Display this message.\n"
36 " -v --verbose Print verbose message.\n"
41 int parse_args (int argc, char **argv) {
42 const char *options = "hvjo:i:O:t:a";
44 struct option long_options[] =
46 {"help", 0, NULL, 'h'},
47 {"verbose", 0, NULL, 'v'},
48 {"jack", 0, NULL, 'j'},
49 {"output", 0, NULL, 'o'},
50 {"input", 0, NULL, 'i'},
51 {"onset", 0, NULL, 'O'},
52 {"threshold", 0, NULL, 't'},
53 {"averaging", 0, NULL, 'a'},
62 next_option = getopt_long (argc, argv, options,
64 switch (next_option) {
66 output_filename = optarg;
69 input_filename = optarg;
74 case 'v': /* verbose */
77 case 'j': /* verbose */
80 case 'O': /*onset type*/
81 if (strcmp(optarg,"energy") == 0)
83 else if (strcmp(optarg,"specdiff") == 0)
84 type_onset = specdiff;
85 else if (strcmp(optarg,"hfc") == 0)
87 else if (strcmp(optarg,"complexdomain") == 0)
88 type_onset = complexdomain;
89 else if (strcmp(optarg,"phase") == 0)
92 debug("could not get onset type.\n");
97 case 't': /* threshold value for onset */
98 threshold = (smpl_t)atof(optarg);
100 if (!isfinite(threshold)) {
101 debug("could not get threshold.\n");
109 case '?': /* unknown options */
112 case -1: /* done with options */
114 default: /*something else unexpected */
118 while (next_option != -1);
120 if (input_filename != NULL) {
121 debug ("Input file : %s\n", input_filename );
122 } else if (input_filename != NULL && output_filename != NULL) {
123 debug ("Input file : %s\n", input_filename );
124 debug ("Output file : %s\n", output_filename );
128 debug ("Jack input output\n");
131 debug ("Error: Could not switch to jack mode\n aubio was compiled without jack support\n");