Ignore:
Timestamp:
Mar 10, 2017, 2:26:32 PM (7 years ago)
Author:
Paul Brossier <piem@piem.org>
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.
Message:

Merge branch 'master' into awhitening

File:
1 edited

Legend:

Unmodified
Added
Removed
  • examples/parse_args.h

    r00d0275 r155cc10  
    1818
    1919*/
     20
     21#include "config.h"
     22
     23#ifdef HAVE_GETOPT_H
     24#include <getopt.h>
     25#endif
    2026
    2127extern int verbose;
     
    3137extern char_t * onset_method;
    3238extern smpl_t onset_threshold;
     39extern smpl_t onset_minioi;
    3340// pitch stuff
    3441extern char_t * pitch_method;
     
    4249extern smpl_t silence_threshold;
    4350extern uint_t mix_input;
     51// midi tap
     52extern smpl_t miditap_note;
     53extern smpl_t miditap_velo;
    4454
    4555extern uint_t force_overwrite;
     
    6474void usage (FILE * stream, int exit_code)
    6575{
     76#ifdef HAVE_GETOPT_H
    6677  fprintf (stream, "usage: %s [ options ] \n", prog_name);
    6778  fprintf (stream,
     
    8293      "       -t      --onset-threshold  set onset detection threshold\n"
    8394      "                 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"
    8497#endif /* PROG_HAS_ONSET */
    8598#ifdef PROG_HAS_PITCH
     
    91104      "                 (yin, yinfft only) a value between 0.1 and 0.7; default=0.3\n"
    92105#endif /* PROG_HAS_PITCH */
     106#ifdef PROG_HAS_SILENCE
    93107      "       -s      --silence          select silence threshold\n"
    94108      "                 a value in dB, for instance -70, or -100; default=-90\n"
     109#endif /* PROG_HAS_SILENCE */
    95110      "       -T      --time-format      select time values output format\n"
    96111      "                 (samples, ms, seconds) default=seconds\n"
     
    100115      "       -f      --force-overwrite  overwrite output file if needed\n"
    101116      "                 do not fail if output file already exists\n"
    102 #endif
     117#endif /* PROG_HAS_OUTPUT */
    103118#ifdef PROG_HAS_JACK
    104119      "       -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 */
    106125      "       -v      --verbose          be verbose\n"
    107126      "       -h      --help             display this message\n"
    108127      );
     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 */
    109132  exit (exit_code);
    110133}
     
    113136parse_args (int argc, char **argv)
    114137{
     138#ifdef HAVE_GETOPT_H
    115139  const char *options = "hv"
    116140    "i:r:B:H:"
    117141#ifdef PROG_HAS_JACK
    118142    "j"
     143#if defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH)
     144    "N:V:"
     145#endif /* defined(PROG_HAS_ONSET) && !defined(PROG_HAS_PITCH) */
    119146#endif /* PROG_HAS_JACK */
    120147#ifdef PROG_HAS_OUTPUT
     
    122149#endif /* PROG_HAS_OUTPUT */
    123150#ifdef PROG_HAS_ONSET
    124     "O:t:"
     151    "O:t:M:"
    125152#endif /* PROG_HAS_ONSET */
    126153#ifdef PROG_HAS_PITCH
     
    128155#endif /* PROG_HAS_PITCH */
    129156    "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    ;
    131164  int next_option;
    132165  struct option long_options[] = {
     
    139172#ifdef PROG_HAS_JACK
    140173    {"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 */
    141178#endif /* PROG_HAS_JACK */
    142179#ifdef PROG_HAS_OUTPUT
     
    146183    {"onset",                 1, NULL, 'O'},
    147184    {"onset-threshold",       1, NULL, 't'},
     185    {"onset-minioi",          1, NULL, 'M'},
    148186#endif /* PROG_HAS_ONSET */
    149187#ifdef PROG_HAS_PITCH
     
    152190    {"pitch-tolerance",       1, NULL, 'l'},
    153191#endif /* PROG_HAS_PITCH */
     192#ifdef PROG_HAS_SILENCE
    154193    {"silence",               1, NULL, 's'},
     194#endif /* PROG_HAS_SILENCE */
    155195    {"time-format",           1, NULL, 'T'},
     196#ifdef PROG_HAS_OUTPUT
    156197    {"mix-input",             0, NULL, 'm'},
    157198    {"force-overwrite",       0, NULL, 'f'},
     199#endif /* PROG_HAS_OUTPUT */
    158200    {NULL,                    0, NULL, 0}
    159201  };
     202#endif /* HAVE_GETOPT_H */
    160203  prog_name = argv[0];
    161204  if (argc < 1) {
     
    163206    return -1;
    164207  }
     208#ifdef HAVE_GETOPT_H
    165209  do {
    166210    next_option = getopt_long (argc, argv, options, long_options, NULL);
     
    175219        usejack = 1;
    176220        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;
    177227      case 'i':
    178228        source_uri = optarg;
     
    198248      case 't':                /* threshold value for onset */
    199249        onset_threshold = (smpl_t) atof (optarg);
     250        break;
     251      case 'M':                /* minimum inter-onset-interval */
     252        onset_minioi = (smpl_t) atof (optarg);
    200253        break;
    201254      case 'p':
     
    236289  }
    237290  while (next_option != -1);
     291#else /* HAVE_GETOPT_H */
     292  int optind = 1;
     293#endif /* HAVE_GETOPT_H */
    238294
    239295  // if unique, use the non option argument as the source
Note: See TracChangeset for help on using the changeset viewer.