- Timestamp:
- May 23, 2005, 3:38:02 PM (20 years ago)
- Branches:
- feature/autosink, feature/cnn, feature/cnn_org, feature/constantq, feature/crepe, feature/crepe_org, feature/pitchshift, feature/pydocstrings, feature/timestretch, fix/ffmpeg5, master, pitchshift, sampler, timestretch, yinfft+
- Children:
- f382ac6
- Parents:
- 2a33cc9
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/utils.c
r2a33cc9 ree0cc27b 86 86 void usage (FILE * stream, int exit_code) 87 87 { 88 89 90 91 92 93 94 95 96 88 fprintf(stream, "usage: %s [ options ] \n", prog_name); 89 fprintf(stream, 90 " -j --jack Use Jack.\n" 91 " -o --output Output type.\n" 92 " -i --input Input type.\n" 93 " -h --help Display this message.\n" 94 " -v --verbose Print verbose message.\n" 95 ); 96 exit(exit_code); 97 97 } 98 98 99 99 int parse_args (int argc, char **argv) { 100 const char *options = "hvjo:i:O:t:a"; 101 int next_option; 102 struct option long_options[] = 103 { 104 {"help", 0, NULL, 'h'}, 105 {"verbose", 0, NULL, 'v'}, 106 {"jack", 0, NULL, 'j'}, 107 {"output", 0, NULL, 'o'}, 108 {"input", 0, NULL, 'i'}, 109 {"onset", 0, NULL, 'O'}, 110 {"threshold", 0, NULL, 't'}, 111 {"averaging", 0, NULL, 'a'}, 112 {NULL, 0, NULL, 0} 113 }; 114 prog_name = argv[0]; 115 if( argc < 1 ) { 116 usage (stderr, 1); 117 return -1; 118 } 119 do { 120 next_option = getopt_long (argc, argv, options, 121 long_options, NULL); 122 switch (next_option) { 123 case 'o': 124 output_filename = optarg; 125 break; 126 case 'i': 127 input_filename = optarg; 128 break; 129 case 'h': /* help */ 130 usage (stdout, 0); 131 return -1; 132 case 'v': /* verbose */ 133 verbose = 1; 134 break; 135 case 'j': /* verbose */ 136 usejack = 1; 137 break; 138 case 'O': /*onset type*/ 139 if (strcmp(optarg,"energy") == 0) 140 type_onset = energy; 141 else if (strcmp(optarg,"specdiff") == 0) 142 type_onset = specdiff; 143 else if (strcmp(optarg,"hfc") == 0) 144 type_onset = hfc; 145 else if (strcmp(optarg,"complexdomain") == 0) 146 type_onset = complexdomain; 147 else if (strcmp(optarg,"phase") == 0) 148 type_onset = phase; 149 else { 150 debug("could not get onset type.\n"); 151 abort(); 100 const char *options = "hvjo:i:O:t:s:a"; 101 int next_option; 102 struct option long_options[] = 103 { 104 {"help" , 0, NULL, 'h'}, 105 {"verbose" , 0, NULL, 'v'}, 106 {"jack" , 0, NULL, 'j'}, 107 {"output" , 0, NULL, 'o'}, 108 {"input" , 0, NULL, 'i'}, 109 {"onset" , 0, NULL, 'O'}, 110 {"threshold", 0, NULL, 't'}, 111 {"silence" , 0, NULL, 's'}, 112 {"averaging", 0, NULL, 'a'}, 113 {NULL , 0, NULL, 0} 114 }; 115 prog_name = argv[0]; 116 if( argc < 1 ) { 117 usage (stderr, 1); 118 return -1; 152 119 } 153 usedoubled = 0; 154 break; 155 case 't': /* threshold value for onset */ 156 threshold = (smpl_t)atof(optarg); 157 /* 158 if (!isfinite(threshold)) { 159 debug("could not get threshold.\n"); 160 abort(); 120 do { 121 next_option = getopt_long (argc, argv, options, 122 long_options, NULL); 123 switch (next_option) { 124 case 'o': 125 output_filename = optarg; 126 break; 127 case 'i': 128 input_filename = optarg; 129 break; 130 case 'h': /* help */ 131 usage (stdout, 0); 132 return -1; 133 case 'v': /* verbose */ 134 verbose = 1; 135 break; 136 case 'j': /* verbose */ 137 usejack = 1; 138 break; 139 case 'O': /*onset type*/ 140 if (strcmp(optarg,"energy") == 0) 141 type_onset = energy; 142 else if (strcmp(optarg,"specdiff") == 0) 143 type_onset = specdiff; 144 else if (strcmp(optarg,"hfc") == 0) 145 type_onset = hfc; 146 else if (strcmp(optarg,"complexdomain") == 0) 147 type_onset = complexdomain; 148 else if (strcmp(optarg,"phase") == 0) 149 type_onset = phase; 150 else { 151 debug("could not get onset type.\n"); 152 abort(); 153 } 154 usedoubled = 0; 155 break; 156 case 's': /* threshold value for onset */ 157 threshold2 = (smpl_t)atof(optarg); 158 break; 159 case 't': /* threshold value for onset */ 160 threshold = (smpl_t)atof(optarg); 161 /* 162 if (!isfinite(threshold)) { 163 debug("could not get threshold.\n"); 164 abort(); 165 } 166 */ 167 break; 168 case 'a': 169 averaging = 1; 170 break; 171 case '?': /* unknown options */ 172 usage(stderr, 1); 173 break; 174 case -1: /* done with options */ 175 break; 176 default: /*something else unexpected */ 177 abort (); 178 } 161 179 } 162 */ 163 break; 164 case 'a': 165 averaging = 1; 166 break; 167 case '?': /* unknown options */ 168 usage(stderr, 1); 169 break; 170 case -1: /* done with options */ 171 break; 172 default: /*something else unexpected */ 173 abort (); 174 } 175 } 176 while (next_option != -1); 177 178 if (input_filename != NULL) { 179 debug ("Input file : %s\n", input_filename ); 180 } else if (input_filename != NULL && output_filename != NULL) { 181 debug ("Input file : %s\n", input_filename ); 182 debug ("Output file : %s\n", output_filename ); 183 } else { 184 if (JACK_SUPPORT) 185 { 186 debug ("Jack input output\n"); 187 usejack = 1; 188 } else { 189 debug ("Error: Could not switch to jack mode\n aubio was compiled without jack support\n"); 190 exit(1); 191 } 192 } 193 return 0; 180 while (next_option != -1); 181 182 if (input_filename != NULL) { 183 debug ("Input file : %s\n", input_filename ); 184 } else if (input_filename != NULL && output_filename != NULL) { 185 debug ("Input file : %s\n", input_filename ); 186 debug ("Output file : %s\n", output_filename ); 187 } else { 188 if (JACK_SUPPORT) 189 { 190 debug ("Jack input output\n"); 191 usejack = 1; 192 } else { 193 debug ("Error: Could not switch to jack mode\n aubio was compiled without jack support\n"); 194 exit(1); 195 } 196 } 197 return 0; 194 198 } 195 199
Note: See TracChangeset
for help on using the changeset viewer.