Changeset 155cc10 for examples/parse_args.h
- Timestamp:
- Mar 10, 2017, 2:26:32 PM (7 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, sampler
- Children:
- ee8a57c
- Parents:
- 00d0275 (diff), 67b6618 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/parse_args.h
r00d0275 r155cc10 18 18 19 19 */ 20 21 #include "config.h" 22 23 #ifdef HAVE_GETOPT_H 24 #include <getopt.h> 25 #endif 20 26 21 27 extern int verbose; … … 31 37 extern char_t * onset_method; 32 38 extern smpl_t onset_threshold; 39 extern smpl_t onset_minioi; 33 40 // pitch stuff 34 41 extern char_t * pitch_method; … … 42 49 extern smpl_t silence_threshold; 43 50 extern uint_t mix_input; 51 // midi tap 52 extern smpl_t miditap_note; 53 extern smpl_t miditap_velo; 44 54 45 55 extern uint_t force_overwrite; … … 64 74 void usage (FILE * stream, int exit_code) 65 75 { 76 #ifdef HAVE_GETOPT_H 66 77 fprintf (stream, "usage: %s [ options ] \n", prog_name); 67 78 fprintf (stream, … … 82 93 " -t --onset-threshold set onset detection threshold\n" 83 94 " a value between 0.1 (more detections) and 1 (less); default=0.3\n" 95 " -M --minioi set minimum inter-onset interval\n" 96 " a value in second; default=0.012\n" 84 97 #endif /* PROG_HAS_ONSET */ 85 98 #ifdef PROG_HAS_PITCH … … 91 104 " (yin, yinfft only) a value between 0.1 and 0.7; default=0.3\n" 92 105 #endif /* PROG_HAS_PITCH */ 106 #ifdef PROG_HAS_SILENCE 93 107 " -s --silence select silence threshold\n" 94 108 " a value in dB, for instance -70, or -100; default=-90\n" 109 #endif /* PROG_HAS_SILENCE */ 95 110 " -T --time-format select time values output format\n" 96 111 " (samples, ms, seconds) default=seconds\n" … … 100 115 " -f --force-overwrite overwrite output file if needed\n" 101 116 " do not fail if output file already exists\n" 102 #endif 117 #endif /* PROG_HAS_OUTPUT */ 103 118 #ifdef PROG_HAS_JACK 104 119 " -j --jack use Jack\n" 105 #endif 120 #if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) 121 " -N --miditap-note MIDI note; default=69.\n" 122 " -V --miditap-velo MIDI velocity; default=65.\n" 123 #endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */ 124 #endif /* PROG_HAS_JACK */ 106 125 " -v --verbose be verbose\n" 107 126 " -h --help display this message\n" 108 127 ); 128 #else /* HAVE_GETOPT_H */ 129 fprintf (stream, "warning: compiled with getopt.h, no argument parsing\n"); 130 fprintf (stream, "usage: %s <filename> \n", prog_name); 131 #endif /* HAVE_GETOPT_H */ 109 132 exit (exit_code); 110 133 } … … 113 136 parse_args (int argc, char **argv) 114 137 { 138 #ifdef HAVE_GETOPT_H 115 139 const char *options = "hv" 116 140 "i:r:B:H:" 117 141 #ifdef PROG_HAS_JACK 118 142 "j" 143 #if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) 144 "N:V:" 145 #endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */ 119 146 #endif /* PROG_HAS_JACK */ 120 147 #ifdef PROG_HAS_OUTPUT … … 122 149 #endif /* PROG_HAS_OUTPUT */ 123 150 #ifdef PROG_HAS_ONSET 124 "O:t: "151 "O:t:M:" 125 152 #endif /* PROG_HAS_ONSET */ 126 153 #ifdef PROG_HAS_PITCH … … 128 155 #endif /* PROG_HAS_PITCH */ 129 156 "T:" 130 "s:mf"; 157 #ifdef PROG_HAS_SILENCE 158 "s:" 159 #endif /* PROG_HAS_SILENCE */ 160 #ifdef PROG_HAS_OUTPUT 161 "mf" 162 #endif /* PROG_HAS_OUTPUT */ 163 ; 131 164 int next_option; 132 165 struct option long_options[] = { … … 139 172 #ifdef PROG_HAS_JACK 140 173 {"jack", 0, NULL, 'j'}, 174 #if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) 175 {"miditap-note", 1, NULL, 'N'}, 176 {"miditap-velo", 1, NULL, 'V'}, 177 #endif /* PROG_HAS_ONSET !PROG_HAS_PITCH */ 141 178 #endif /* PROG_HAS_JACK */ 142 179 #ifdef PROG_HAS_OUTPUT … … 146 183 {"onset", 1, NULL, 'O'}, 147 184 {"onset-threshold", 1, NULL, 't'}, 185 {"onset-minioi", 1, NULL, 'M'}, 148 186 #endif /* PROG_HAS_ONSET */ 149 187 #ifdef PROG_HAS_PITCH … … 152 190 {"pitch-tolerance", 1, NULL, 'l'}, 153 191 #endif /* PROG_HAS_PITCH */ 192 #ifdef PROG_HAS_SILENCE 154 193 {"silence", 1, NULL, 's'}, 194 #endif /* PROG_HAS_SILENCE */ 155 195 {"time-format", 1, NULL, 'T'}, 196 #ifdef PROG_HAS_OUTPUT 156 197 {"mix-input", 0, NULL, 'm'}, 157 198 {"force-overwrite", 0, NULL, 'f'}, 199 #endif /* PROG_HAS_OUTPUT */ 158 200 {NULL, 0, NULL, 0} 159 201 }; 202 #endif /* HAVE_GETOPT_H */ 160 203 prog_name = argv[0]; 161 204 if (argc < 1) { … … 163 206 return -1; 164 207 } 208 #ifdef HAVE_GETOPT_H 165 209 do { 166 210 next_option = getopt_long (argc, argv, options, long_options, NULL); … … 175 219 usejack = 1; 176 220 break; 221 case 'N': 222 miditap_note = (smpl_t) atoi (optarg); 223 break; 224 case 'V': 225 miditap_velo = (smpl_t) atoi (optarg); 226 break; 177 227 case 'i': 178 228 source_uri = optarg; … … 198 248 case 't': /* threshold value for onset */ 199 249 onset_threshold = (smpl_t) atof (optarg); 250 break; 251 case 'M': /* minimum inter-onset-interval */ 252 onset_minioi = (smpl_t) atof (optarg); 200 253 break; 201 254 case 'p': … … 236 289 } 237 290 while (next_option != -1); 291 #else /* HAVE_GETOPT_H */ 292 int optind = 1; 293 #endif /* HAVE_GETOPT_H */ 238 294 239 295 // if unique, use the non option argument as the source
Note: See TracChangeset
for help on using the changeset viewer.