Changeset df7be43 for examples


Ignore:
Timestamp:
Aug 12, 2015, 4:31:40 PM (9 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, pitchshift, sampler, timestretch, yinfft+
Children:
3ff50e5
Parents:
340cb93
Message:

examples/parse_args.h: only parse time format string once, warn if unknown

Location:
examples
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • examples/aubioonset.c

    r340cb93 rdf7be43  
    5050{
    5151  if ( is_onset ) {
    52     if (strcmp (time_format, "samples") == 0) {
    53       outmsg ("%d\n", aubio_onset_get_last (o) );
    54     } else if (strcmp (time_format, "ms") == 0) {
    55       outmsg ("%f\n", aubio_onset_get_last_ms (o) );
    56     } else {
    57       outmsg ("%f\n", aubio_onset_get_last_s (o) );
    58     }
     52    print_time(aubio_onset_get_last (o));
     53    outmsg ("\n");
    5954  }
    6055}
  • examples/parse_args.h

    r340cb93 rdf7be43  
    3636extern smpl_t pitch_tolerance;
    3737// time stuff
    38 extern char_t * time_format;
     38extern uint_t time_format;
    3939// tempo stuff
    4040extern char_t * tempo_method;
     
    209209        break;
    210210      case 'T':
    211         time_format = optarg;
     211        if (strcmp (optarg, "samples") == 0) {
     212          time_format = 2;
     213        } else if (strcmp (optarg, "ms") == 0) {
     214          time_format = 1;
     215        } else if (strcmp (optarg, "seconds") == 0) {
     216          time_format = 0;
     217        } else {
     218          errmsg ("Warning: did not get '%s' time-format string\n", optarg);
     219        }
    212220        break;
    213221      case 's':                /* silence threshold */
  • examples/utils.c

    r340cb93 rdf7be43  
    4949smpl_t pitch_tolerance = 0.0; // will be set if != 0.
    5050// time stuff
    51 char_t * time_format = "seconds";
     51uint_t time_format = 0; // for "seconds", 1 for "ms", 2 for "samples"
    5252// tempo stuff
    5353char_t * tempo_method = "default";
     
    210210void print_time (uint_t time_in_samples) {
    211211  /* output times in selected format */
    212   if (strcmp (time_format, "samples") == 0) {
     212  if (time_format == 2) {
    213213    outmsg ("%d", time_in_samples);
    214   } else if (strcmp (time_format, "ms") == 0) {
     214  } else if (time_format == 1) {
    215215    outmsg ("%f", 1000. * time_in_samples / (float) samplerate);
    216216  } else {
Note: See TracChangeset for help on using the changeset viewer.