Changeset 340cb93


Ignore:
Timestamp:
Aug 12, 2015, 4:15:39 PM (5 years ago)
Author:
Paul Brossier <piem@piem.org>
Branches:
feature/autosink, feature/constantq, feature/pitchshift, feature/pydocstrings, feature/timestretch, master, pitchshift, sampler, timestretch, yinfft+
Children:
df7be43
Parents:
a90e9d4
Message:

examples/: add time format option

Location:
examples
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • examples/aubiomfcc.c

    ra90e9d4 r340cb93  
    4141void process_print (void)
    4242{
    43   /* output times in seconds and extracted mfccs */
    44   outmsg("%f\t",blocks*hop_size/(float)samplerate);
    45   fvec_print(mfcc_out);
     43  /* output times in selected format */
     44  print_time (blocks * hop_size);
     45  outmsg ("\t");
     46  /* output extracted mfcc */
     47  fvec_print (mfcc_out);
    4648}
    4749
  • examples/aubioonset.c

    ra90e9d4 r340cb93  
    5050{
    5151  if ( is_onset ) {
    52     outmsg ("%f\n", aubio_onset_get_last_s (o) );
     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    }
    5359  }
    5460}
  • examples/aubiopitch.c

    ra90e9d4 r340cb93  
    4747{
    4848  smpl_t pitch_found = fvec_get_sample(pitch, 0);
    49   outmsg("%f %f\n",(blocks)
    50       *hop_size/(float)samplerate, pitch_found);
     49  print_time(blocks * hop_size);
     50  outmsg(" %f\n", pitch_found);
    5151}
    5252
  • examples/aubioquiet.c

    ra90e9d4 r340cb93  
    3939void process_print (void) {
    4040  int curblocks = (blocks - 4) > 0 ? blocks - 4 : 0;
    41   if (issilence == -1) {
    42     outmsg("NOISY: %f\n",curblocks*hop_size/(float)samplerate);
    43   } else if (issilence == 2) {
    44     outmsg("QUIET: %f\n",curblocks*hop_size/(float)samplerate);
     41  if (issilence == -1 || issilence == 2) {
     42    if (issilence == -1) {
     43      outmsg ("NOISY: ");
     44    } else { // if (issilence == 2) {
     45      outmsg ("QUIET: ");
     46    }
     47    print_time (curblocks * hop_size);
     48    outmsg ("\n");
    4549  }
    4650}
  • examples/aubiotrack.c

    ra90e9d4 r340cb93  
    5151void process_print (void) {
    5252  if ( is_beat && !is_silence ) {
    53     outmsg("%f\n", aubio_tempo_get_last_s(tempo) );
     53    print_time (aubio_tempo_get_last (tempo));
     54    outmsg ("\n");
    5455  }
    5556}
  • examples/parse_args.h

    ra90e9d4 r340cb93  
    3535extern char_t * pitch_unit;
    3636extern smpl_t pitch_tolerance;
     37// time stuff
     38extern char_t * time_format;
    3739// tempo stuff
    3840extern char_t * tempo_method;
     
    9193      "       -s      --silence          select silence threshold\n"
    9294      "                 a value in dB, for instance -70, or -100; default=-90\n"
     95      "       -T      --time-format      select time values output format\n"
     96      "                 (samples, ms, seconds) default=seconds\n"
    9397#ifdef PROG_HAS_OUTPUT
    9498      "       -m      --mix-input        mix input signal with output signal\n"
     
    123127    "p:u:l:"
    124128#endif /* PROG_HAS_PITCH */
     129    "T:"
    125130    "s:mf";
    126131  int next_option;
     
    148153#endif /* PROG_HAS_PITCH */
    149154    {"silence",               1, NULL, 's'},
     155    {"time-format",           1, NULL, 'T'},
    150156    {"mix-input",             0, NULL, 'm'},
    151157    {"force-overwrite",       0, NULL, 'f'},
     
    201207      case 'l':
    202208        pitch_tolerance = (smpl_t) atof (optarg);
     209        break;
     210      case 'T':
     211        time_format = optarg;
    203212        break;
    204213      case 's':                /* silence threshold */
  • examples/utils.c

    ra90e9d4 r340cb93  
    4848char_t * pitch_method = "default";
    4949smpl_t pitch_tolerance = 0.0; // will be set if != 0.
     50// time stuff
     51char_t * time_format = "seconds";
    5052// tempo stuff
    5153char_t * tempo_method = "default";
     
    197199#endif
    198200  if (velo == 0) {
    199     outmsg ("%f\n", blocks * hop_size / (float) samplerate);
    200   } else {
    201     outmsg ("%f\t%f\t", mpitch, blocks * hop_size / (float) samplerate);
    202   }
    203 }
    204 
     201    print_time (blocks * hop_size);
     202    outmsg ("\n");
     203  } else {
     204    outmsg ("%f\t", mpitch);
     205    print_time (blocks * hop_size);
     206    outmsg ("\t");
     207  }
     208}
     209
     210void print_time (uint_t time_in_samples) {
     211  /* output times in selected format */
     212  if (strcmp (time_format, "samples") == 0) {
     213    outmsg ("%d", time_in_samples);
     214  } else if (strcmp (time_format, "ms") == 0) {
     215    outmsg ("%f", 1000. * time_in_samples / (float) samplerate);
     216  } else {
     217    outmsg ("%f", time_in_samples / (float) samplerate);
     218  }
     219}
  • examples/utils.h

    ra90e9d4 r340cb93  
    5757void process_block (fvec_t *ibuf, fvec_t *obuf);
    5858void process_print (void);
     59
     60void print_time (uint_t samples);
Note: See TracChangeset for help on using the changeset viewer.