comparison runner/main.cpp @ 142:6b62bae0af33 midi

Help adjustments: require extra arg for help on a writer (help text was getting too long)
author Chris Cannam
date Mon, 13 Oct 2014 13:53:00 +0100
parents f0df07da6f46
children b3d73c08b6ce
comparison
equal deleted inserted replaced
141:d7a91e07ca57 142:6b62bae0af33
209 cerr << "path, local \"file://\" URL, or remote \"http://\" or \"ftp://\" URL;" << endl; 209 cerr << "path, local \"file://\" URL, or remote \"http://\" or \"ftp://\" URL;" << endl;
210 cerr << "and <plugin> is a plugin output identified as vamp:libname:plugin:output." << endl; 210 cerr << "and <plugin> is a plugin output identified as vamp:libname:plugin:output." << endl;
211 cerr << endl; 211 cerr << endl;
212 } 212 }
213 213
214 void printHelp(QString myname) 214 void printHelp(QString myname, QString w)
215 { 215 {
216 std::string writer = w.toStdString();
217
216 printUsage(myname); 218 printUsage(myname);
217 219
218 QString extensions = AudioFileReaderFactory::getKnownExtensions(); 220 QString extensions = AudioFileReaderFactory::getKnownExtensions();
219 QStringList extlist = extensions.split(" ", QString::SkipEmptyParts); 221 QStringList extlist = extensions.split(" ", QString::SkipEmptyParts);
220 if (!extlist.empty()) { 222 if (!extlist.empty()) {
237 } 239 }
238 240
239 cerr << "Playlist files in M3U format are also supported." << endl; 241 cerr << "Playlist files in M3U format are also supported." << endl;
240 cerr << endl; 242 cerr << endl;
241 243
242 cerr << "Transformation options:" << endl;
243 cerr << endl;
244 cerr << " -t, --transform <T> Apply transform described in transform file <T> to" << endl;
245 cerr << " all input audio files. You may supply this option" << endl;
246 cerr << " multiple times. You must supply this option or -T at" << endl;
247 cerr << " least once for any work to be done. Transform format" << endl;
248 cerr << " may be SV transform XML or Vamp transform RDF/Turtle." << endl;
249 cerr << " See documentation for examples." << endl;
250 cerr << endl;
251 cerr << " -T, --transforms <T> Apply all transforms described in transform files" << endl;
252 cerr << " whose names are listed in text file <T>. You may supply" << endl;
253 cerr << " this option multiple times." << endl;
254 cerr << endl;
255 cerr << " -d, --default <I> Apply the default transform for transform id <I>. This" << endl;
256 cerr << " is equivalent to generating a skeleton transform for this" << endl;
257 cerr << " id (using the -s option, below) and then applying that," << endl;
258 cerr << " unmodified, with the -t option in the normal way. Note" << endl;
259 cerr << " that the results may vary as the implementation's default" << endl;
260 cerr << " processing parameters are not guaranteed. Do not use" << endl;
261 cerr << " this in production systems. You may supply this option" << endl;
262 cerr << " multiple times, and mix it with -t and -T." << endl;
263 cerr << endl;
264 cerr << " -w, --writer <W> Write output using writer type <W>." << endl;
265 cerr << " Supported writer types are: ";
266 set<string> writers = FeatureWriterFactory::getWriterTags(); 244 set<string> writers = FeatureWriterFactory::getWriterTags();
245
246 QString writerText = "Supported writer types are: ";
267 for (set<string>::const_iterator i = writers.begin(); 247 for (set<string>::const_iterator i = writers.begin();
268 i != writers.end(); ) { 248 i != writers.end(); ) {
269 cerr << *i; 249 writerText += i->c_str();
270 if (++i != writers.end()) cerr << ", "; 250 if (++i != writers.end()) writerText += ", ";
271 else cerr << "."; 251 else writerText += ".";
272 } 252 }
273 cerr << endl; 253 writerText = wrap(writerText, 56, 22);
274 cerr << " You may supply this option multiple times. You must" << endl; 254
275 cerr << " supply this option at least once for any work to be done." << endl; 255 if (writer == "" || writers.find(writer) == writers.end()) {
276 cerr << endl; 256
277 cerr << " -S, --summary <S> In addition to the result features, write summary feature" << endl; 257 cerr << "Transformation options:" << endl;
278 cerr << " of summary type <S>." << endl; 258 cerr << endl;
279 cerr << " Supported summary types are min, max, mean, median, mode," << endl; 259 cerr << " -t, --transform <T> Apply transform described in transform file <T> to" << endl;
280 cerr << " sum, variance, sd, count." << endl; 260 cerr << " all input audio files. You may supply this option" << endl;
281 cerr << " You may supply this option multiple times." << endl; 261 cerr << " multiple times. You must supply this option or -T at" << endl;
282 cerr << endl; 262 cerr << " least once for any work to be done. Transform format" << endl;
283 cerr << " --summary-only Write only summary features; do not write the regular" << endl; 263 cerr << " may be SV transform XML or Vamp transform RDF/Turtle." << endl;
284 cerr << " result features." << endl; 264 cerr << " See accompanying documentation for transform examples." << endl;
285 cerr << endl; 265 cerr << endl;
286 cerr << " --segments <A>,<B>[,...]" << endl; 266 cerr << " -T, --transforms <T> Apply all transforms described in transform files" << endl;
287 cerr << " Summarise in segments, with segment boundaries" << endl; 267 cerr << " whose names are listed in text file <T>. You may supply" << endl;
288 cerr << " at A, B, ... seconds." << endl; 268 cerr << " this option multiple times." << endl;
289 cerr << endl; 269 cerr << endl;
290 cerr << " -m, --multiplex If multiple input audio files are given, use mono" << endl; 270 cerr << " -d, --default <I> Apply the default transform for transform id <I>. This" << endl;
291 cerr << " mixdowns of all files as the input channels for a single" << endl; 271 cerr << " is equivalent to generating a skeleton transform for this" << endl;
292 cerr << " invocation of each transform, instead of running the" << endl; 272 cerr << " id (using the -s option, below) and then applying that," << endl;
293 cerr << " transform against all files separately. The first file" << endl; 273 cerr << " unmodified, with the -t option in the normal way. Note" << endl;
294 cerr << " will be used for output reference name and sample rate." << endl; 274 cerr << " that results may vary, as the implementation's default" << endl;
295 cerr << endl; 275 cerr << " processing parameters are not guaranteed. Do not use" << endl;
296 cerr << " -r, --recursive If any of the <audio> arguments is found to be a local" << endl; 276 cerr << " this in production systems. You may supply this option" << endl;
297 cerr << " directory, search the tree starting at that directory" << endl; 277 cerr << " multiple times, and mix it with -t and -T." << endl;
298 cerr << " for all supported audio files and take all of those as" << endl; 278 cerr << endl;
299 cerr << " input instead." << endl; 279 cerr << " -w, --writer <W> Write output using writer type <W>." << endl;
300 cerr << endl; 280 cerr << " " << writerText << endl;
301 cerr << " -n, --normalise Normalise input audio files to signal absolute max = 1.f." << endl; 281 cerr << " You may supply this option multiple times. You must" << endl;
302 cerr << endl; 282 cerr << " supply this option at least once for any work to be done." << endl;
303 cerr << " -f, --force Continue with subsequent files following an error." << endl; 283 cerr << endl;
304 cerr << endl; 284 cerr << " -S, --summary <S> In addition to the result features, write summary feature" << endl;
305 cerr << "Housekeeping options:" << endl; 285 cerr << " of summary type <S>." << endl;
306 cerr << endl; 286 cerr << " Supported summary types are min, max, mean, median, mode," << endl;
307 cerr << " -l, --list List all known transform ids to standard output." << endl; 287 cerr << " sum, variance, sd, count." << endl;
308 cerr << endl; 288 cerr << " You may supply this option multiple times." << endl;
309 cerr << " -s, --skeleton <I> Generate a skeleton transform file for transform id <I>" << endl; 289 cerr << endl;
310 cerr << " and write it to standard output." << endl; 290 cerr << " --summary-only Write only summary features; do not write the regular" << endl;
311 cerr << endl; 291 cerr << " result features." << endl;
312 cerr << " -v, --version Show the version number and exit." << endl; 292 cerr << endl;
313 cerr << endl; 293 cerr << " --segments <A>,<B>[,...]" << endl;
314 cerr << " --minversion <V> Exit with successful return code if the version of" << endl; 294 cerr << " Summarise in segments, with segment boundaries" << endl;
315 cerr << " " << myname << " is at least <V>, failure otherwise." << endl; 295 cerr << " at A, B, ... seconds." << endl;
316 cerr << " For scripts that depend on certain option support." << endl; 296 cerr << endl;
317 cerr << endl; 297 cerr << " -m, --multiplex If multiple input audio files are given, use mono" << endl;
318 cerr << " -h, --help Show help." << endl; 298 cerr << " mixdowns of all files as the input channels for a single" << endl;
319 299 cerr << " invocation of each transform, instead of running the" << endl;
320 cerr << endl; 300 cerr << " transform against all files separately. The first file" << endl;
321 cerr << "If no -w (or --writer) options are supplied, either the -l -s -v or -h option" << endl; 301 cerr << " will be used for output reference name and sample rate." << endl;
322 cerr << "(or long equivalent) must be given instead." << endl; 302 cerr << endl;
323 303 cerr << " -r, --recursive If any of the <audio> arguments is found to be a local" << endl;
324 for (set<string>::const_iterator i = writers.begin(); 304 cerr << " directory, search the tree starting at that directory" << endl;
325 i != writers.end(); ++i) { 305 cerr << " for all supported audio files and take all of those as" << endl;
326 FeatureWriter *w = FeatureWriterFactory::createWriter(*i); 306 cerr << " input instead." << endl;
307 cerr << endl;
308 cerr << " -n, --normalise Normalise input audio files to signal absolute max = 1.f." << endl;
309 cerr << endl;
310 cerr << " -f, --force Continue with subsequent files following an error." << endl;
311 cerr << endl;
312 cerr << "Housekeeping options:" << endl;
313 cerr << endl;
314 cerr << " -l, --list List all known transform ids to standard output." << endl;
315 cerr << endl;
316 cerr << " -s, --skeleton <I> Generate a skeleton transform file for transform id <I>" << endl;
317 cerr << " and write it to standard output." << endl;
318 cerr << endl;
319 cerr << " -v, --version Show the version number and exit." << endl;
320 cerr << endl;
321 cerr << " --minversion <V> Exit with successful return code if the version of" << endl;
322 cerr << " " << myname << " is at least <V>, failure otherwise." << endl;
323 cerr << " For scripts that depend on certain option support." << endl;
324 cerr << endl;
325 cerr << " -h, --help Show help." << endl;
326 cerr << " -h, --help <W> Show help for writer type W." << endl;
327 cerr << " " << writerText << endl;
328
329 cerr << endl;
330 cerr << "If no -w (or --writer) options are supplied, either the -l -s -v or -h option" << endl;
331 cerr << "(or long equivalent) must be given instead." << endl;
332
333 } else {
334
335 FeatureWriter *w = FeatureWriterFactory::createWriter(writer);
327 if (!w) { 336 if (!w) {
328 cerr << " (Internal error: failed to create writer of this type)" << endl; 337 cerr << " (Internal error: failed to create writer of known type \""
329 continue; 338 << writer << "\")" << endl;
330 } 339 return;
340 }
341 cerr << "Additional options for writer type \"" << writer << "\":" << endl;
342 cerr << endl;
331 FeatureWriter::ParameterList params = w->getSupportedParameters(); 343 FeatureWriter::ParameterList params = w->getSupportedParameters();
332 delete w; 344 delete w;
333 if (params.empty()) { 345 if (params.empty()) {
334 continue; 346 cerr << "(No special options available for this writer)" << endl;
335 } 347 return;
336 cerr << endl; 348 }
337 cerr << "Additional options for writer type \"" << *i << "\":" << endl;
338 cerr << endl;
339 for (FeatureWriter::ParameterList::const_iterator j = params.begin(); 349 for (FeatureWriter::ParameterList::const_iterator j = params.begin();
340 j != params.end(); ++j) { 350 j != params.end(); ++j) {
341 cerr << " --" << *i << "-" << j->name << " "; 351 cerr << " --" << writer << "-" << j->name << " ";
342 int spaceage = 16 - int(i->length()) - int(j->name.length()); 352 int spaceage = 16 - int(writer.length()) - int(j->name.length());
343 if (j->hasArg) { cerr << "<X> "; spaceage -= 4; } 353 if (j->hasArg) { cerr << "<X> "; spaceage -= 4; }
344 for (int k = 0; k < spaceage; ++k) cerr << " "; 354 for (int k = 0; k < spaceage; ++k) cerr << " ";
345 QString s(j->description.c_str()); 355 QString s(j->description.c_str());
346 s = wrap(s, 56, 22); 356 s = wrap(s, 56, 22);
347 cerr << s << endl; 357 cerr << s << endl;
472 482
473 QString arg = args[i]; 483 QString arg = args[i];
474 bool last = ((i + 1) == args.size()); 484 bool last = ((i + 1) == args.size());
475 485
476 if (arg == "-h" || arg == "--help" || arg == "-?") { 486 if (arg == "-h" || arg == "--help" || arg == "-?") {
477 printHelp(myname); 487 QString writer;
488 if (!last) {
489 writer = args[i+1];
490 }
491 printHelp(myname, writer);
478 return 0; 492 return 0;
479 } 493 }
480 494
481 if (arg == "-v" || arg == "--version") { 495 if (arg == "-v" || arg == "--version") {
482 std::cout << RUNNER_VERSION << std::endl; 496 std::cout << RUNNER_VERSION << std::endl;